0
votes

Currently I am working with a POS printer mobile application. I have done text, image and barcode or qrcode printing methods. Now I am trying to retrieve printer status using ESC/POS commands. Below I have attached the code to check the status of print.


inStream = btSocket.InputStream;
outStream = btSocket.OutputStream;
                      
byte[] reader = new byte[1024];
                        
//Send command to printer
byte[] @try = "\x10\x04\x01".ToBytes();
outStream.Write(@try, 0, @try.Length);

//Read from printer
if (inStream.CanRead)
{
    //string stat_res = inStream.Read(reader).ToString();
    inStream.Read(reader, 0, reader.Length);
    string text = Encoding.UTF8.GetString(reader, 0, reader.Length);
    Debug.WriteLine($"Status res: {text}");
}

I have tested the code above and i received output as stated below. In string form it output as an up/down arrow [0:] Status res: ? or in integer form [0:] Status res: 1

May I know what mistake I did here? I have referred other questions which developed using python or java and converted to C# and it still doesn't produce correct output as I expect. May I know what I did wrong here? I am using ESCPOS Nuget in order to convert text to byte form.

The printer i am using Bixolon and model is SPP-R410. I am developing this application in Xamarin forms using ESC/POS commands.

Thanks.

1

1 Answers

1
votes

The SPP-R410 Command Manual can be obtained here.
BIXOLON | Downloads :: mobile printer, portable printer...

According to it, the first 0x10 is unnecessary, only 0x04, 0x01 seems to be good.

Since the status to be notified should be either 0x12:Online or 0x1A:Offline, it is possible that either the correct data has not been notified or your interpretation is incorrect.

Even if the correct data is notified, neither of them is a printable character code, so even if you execute Encoding.UTF8.GetString() process, you cannot grasp the contents.
In this case, what you should do is BitConverter.ToString().
Alternatively, you can reader[0].ToString("X") only the first byte of the reader buffer, since only one byte will be reported.