super host status response is truncated

I am trying to get the host status from a ZQ520 printer in a cross plat form app as shown below.

string queryString = "^XA^HZA^XZ";
connection.TimeToWaitAfterRead = 60000;
connection.TimeToWaitAfterWrite = 60000;
connection.TimeToWaitForMoreData = 60000;
byte[] response = connection.SendAndWaitForResponse(Encoding.UTF8.GetBytes(queryString), 60000, 60000, "</ZEBRA-ELTRON-PERSONALITY>");
//Attempted with and without terminator
string strResponse = Encoding.UTF8.GetString(response);

The response is complete when running on an android; however, it is truncated on iOS. The iOS response is 2,170 bytes in length. The expected response is about 36K.

This is the truncated response.

<?xml version='1.0'?>

<ZEBRA-ELTRON-PERSONALITY>

<DEFINITIONS>

<MODEL>ZQ520</MODEL>

<FIRMWARE-VERSION>V76.20.15Z</FIRMWARE-VERSION>

<LINK-OS-VERSION>5.2</LINK-OS-VERSION>

<XML-SCHEMA-VERSION>1.3</XML-SCHEMA-VERSION>

<PLUG-AND-PLAY-VALUE>MANUFACTURER:Zebra Technologies ;COMMAND SET:CPCL;MODEL:ZTC ZQ520 (CPCL);CLASS:PRINTER;OPTIONS:XML;</PLUG-AND-PLAY-VALUE>

<ZBI>DISABLED</ZBI>

<DOTS-PER-MM>8</DOTS-PER-MM>

<DOTS-PER-DOTROW>832</DOTS-PER-DOTROW>

<PHYSICAL-MEMORY>

<TYPE ENUM='R, E, B, A'>R</TYPE>

<SIZE>8388608</SIZE>

<AVAILABLE>8365056</AVAILABLE>

</PHYSICAL-MEMORY>

<PHYSICAL-MEMORY>

<TYPE ENUM='R, E, B, A'>E</TYPE>

<SIZE>67108864</SIZE>

<AVAILABLE>66939392</AVAILABLE>

</PHYSICAL-MEMORY>

<OPTIONS>

<PEEL BOOL='Y,N'>N</PEEL>

</OPTIONS>

<WIRELESS-PRINTSERVER>

<PRODUCT-NAME>ZebraNet Wireless PS</PRODUCT-NAME>

<PRINTSERVER-FIRMWARE-VERSION>V76.20.15Z</PRINTSERVER-FIRMWARE-VERSION>

<PRODUCT-NUMBER>79071</PRODUCT-NUMBER>

<MFG-ID>H</MFG-ID>

<CARD-ID>H</CARD-ID>

<CARD-FIRMWARE>00.00.00</CARD-FIRMWARE>

<MAC-ADDRESS>00:00:00:00:00:00</MAC-ADDRESS>

<DATE-CODE>0161A</DATE-CODE>

<PRINTER-STATUS>Online</PRINTER-STATUS>

<CONNECTED-TO>ZTC ZQ520-203dpi ,</CONNECTED-TO>

<BIDI-STATUS-ENABLED>Y</BIDI-STATUS-ENABLED>

<SYSTEM-UPTIME>00 days 00 hours 46 mins 14 secs</SYSTEM-UPTIME>

</WIRELESS-PRINTSERVER>

</DEFINITIONS>

<SAVED-SETTINGS>

<NAME>XXRBJ192801767</NAME>

<DESCRIPTION></DESCRIPTION>

<MEDIA-DARKNESS MIN='0.0' MAX='30.0'>

<CURRENT>20.0</CURRENT>

<STORED>20.0</STORED>

<DEFAULT>10.0</DEFAULT>

</MEDIA-DARKNESS>

<TEAR-OFF-POSITION MIN='-120' MAX='120'>

<CURRENT>0</CURRENT>

<STORED>0</STORED>

<DEFAULT>0</DEFAULT>

</TEAR-OFF-POSITION>

<PRINT-MODE>

<MODE ENUM='REWIND, TEAR OFF, PEEL OFF, CUTTER, DELAYED CUT, APPLICATOR, LINERLESS-P, LINERLESS-R, LINERLESS-T, LINERLESS CUT, LINRLESS DLY CUT'>

<CURRENT>REWIND</CURRENT>

<STORED>REWIND</STORED>

<DEFAULT>REWIND</DEFAULT>

</MODE>

</PRINT-MODE>

<MEDIA-TRACKING ENUM='CONTINUOUS, NON-CONTINUOUS'>

<CURRENT>CONTINUOUS</CURRENT>

<STORED>CONT

Steven Si
Hi John,

Hi John,

Thanks for the update. The v1.2 of Link-OS SDK for Xamarin is an old version released a few years ago. The latest version of Link-OS SDK for Xamarin is v2.15.2634, which resides in ..\link_os_sdk\PC-.NET\v2.15.2634 folder of the SDK installation location. The v1.2 was released a few years ago and may have some undetected bugs. I did the test yesterday with v2.15.2634 and had no issues. I didn't need to adjust the timeouts on the connection object at all. All I did was to set the initialResponseTimeout and responseCompletionTimeout in the SendAndWaitForResponse() to 2000ms. I would suggest to use v2.15.2634 and also make sure that the ZQ520 printer has its latest firmware on it. With that, I don't think the workaround is needed.

Vote: 
Vote up!
Vote down!

Points: 1

You voted ‘up’


Steven Si
Are you using Link-OS SDK for

Are you using Link-OS SDK for Xamarin for your cross platform app? Does this happen on Bluetooth connection?

I use Link-OS SDK for iOS, in which I observed the incomplete response to ^HZA on Bluetooth with ZQ520 printer when using the default timeouts in the connection. After adding 10,000ms wait time (instead of 60000ms), I am able to get the full response back from ZQ520. Then I switched to ZQ610 printer with and without adding the extra wait-time. The responses to ^HZA from ZQ610 were complete regardless the extra wait-time. Certainly, this confirms that ZQ520 has a slower response to ^HZA, probably due to the HW & SW on ZQ520. However, adding the extra wait-time, we can still get the full response to ^HZA from ZQ520. For simplification, I passed nil to the validator parameter when calling SendAndWaitForResponse(). Could you try without the validator to see if you can get the full response from ZQ520 with 10000ms wait-time?

Updated...

Just did a test with Link-OS SDK for Xamarin v2.15.2634. The response from ZQ520 to ^HZA on Bluetooth is complete on both Android and iOS. The code used to retrieve the host status is below. In my test, the timeouts are the default timeouts for connection. The initialResponseTimeout and responseCompletionTimeout are set to 2000ms. There is no issue of incomplete or truncated response of the host status for me.

string queryString = "^XA^HZA^XZ";

byte[] response = connection.SendAndWaitForResponse(Encoding.UTF8.GetBytes(queryString), 2000, 2000, "</ZEBRA-ELTRON-PERSONALITY>");

string strResponse = Encoding.UTF8.GetString(response);

 

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


John McGinnis
work around

Hi Steve,

Thanks for the reply. Yes I am using Link OS (v1.2) and I do have a BT connection.

I have tried adjusting the timeouts and had it set as high as 180000 at one time. I also tried to get the response with and without a terminator. The problem still hasn't been resolved; however, I did stumble on a workaround using trial and error. A curious thing to note about the initial response is it is always exactly 2048 bytes in length. It kind of looks like there is a 2K limit being set somewhere. The remainder of the response is available, but you need to invoke connection.Read() to get it. The following sample returns the complete response in the byte[] response1. The first call places 2048 bytes into response1. The read statement places about 34k into response2. Both arrays are combined and placed back into response1. It is about 36k in length. This also appears to be an iOS only issue. My android device does not require a second read. The entire 36k response is returned with SendAndAwaitForResponse on my android.

string queryString = session.AppSpec.GetValue<string>("ZebraGetInfo", "^XA^HZA^XZ");

/*connection.TimeToWaitAfterRead = 180000;
connection.TimeToWaitAfterWrite = 180000;
connection.TimeToWaitForMoreData = 180000;
connection.MaxTimeoutForRead = 180000;*/;
byte[] response1 = connection.SendAndWaitForResponse(Encoding.UTF8.GetBytes(queryString), 2000, 2000, "</ZEBRA-ELTRON-PERSONALITY>");
string strResponse = Encoding.UTF8.GetString(response1);
if (!strResponse.Contains("</ZEBRA-ELTRON-PERSONALITY>"))
{
byte[] response0 = response1;
System.Threading.Thread.Sleep(2000);
byte[] response2 = connection.Read();
response1 = new byte[response0.Length + response2.Length];
response0.CopyTo(response1, 0);
response2.CopyTo(response1, response0.Length);
}

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments