Search code examples
c#barcode-scannerpos-for-.net

How to send an enquiry command with DirectIO() in POS for .NET?


I'm currently working on a project to control a Honeywell Genesis 7580G scanner using C#, POS for .NET and the POS4NET Suite from Honeywell. I would like to get the current serial read time-out, so I called the DirectIO() method from POS4NET in the following way:

string command = "TRGSTO?.";
DirectIOData response = scanner.DirectIO(18, 1024, Encoding.ASCII.GetBytes(command));
byte[] buffer = (byte[])response.Object;
Console.WriteLine("$: Response: " + Encoding.ASCII.GetString(buffer));

This code prints:

"$: Response: TRGSTO20"

which lacks three zeros (the time unit is milliseconds) and the [ACK] character. I was expecting this...

"$: Response: TRGSTO20000[ACK]"

However, if I change the command to get a different setting...

string command = "BEPPWR?.";
DirectIOData response = scanner.DirectIO(18, 1024, Encoding.ASCII.GetBytes(command));
byte[] buffer = (byte[])response.Object;
Console.WriteLine("$: Response: " + Encoding.ASCII.GetString(buffer));

The code works as expected, and prints

"$: Response: BEPPWR1[ACK]"

What is the correct way to send an enquiry command using DirectIO()?


Solution

  • Is it possible that the response data may have arrived correctly and was converted as a character string so that it is considered to have ended with zero?

    Please check the content of byte array data using BitConverter.ToString() instead of Encoding.ASCII.GetString().