The problem
I am currently working on an application which needs to send information to print on an EPSON TM-U295 printer. Said printer has Bluetooth enabled and is paired with the computer. I am currently able to send a string to it and print the needed information. However, if there is no paper in the printer the string is still sent and printed on thin air.
Current code to print
Take note that Socket
is a StreamSocket
using the method ConnectAsync()
which allows you to connect to a paired printer.
'Print
Public Async Function Write(ByVal StrToSend As String) As Task
Dim Bytestosend As Byte() = System.Text.Encoding.UTF8.GetBytes(StrToSend)
Await Socket.OutputStream.WriteAsync(Bytestosend.AsBuffer())
Await Socket.OutputStream.FlushAsync()
End Function
'Send the command to print
Private Async Sub BtnPrint_Click(sender As Object, e As RoutedEventArgs)
Await Write(txtTextTosend.Text + vbLf)
End Sub
Code wanted
I would like to be able to verify if the paper is out with a condition similar to the following :
'Send the command to print
Private Async Sub BtnPrint_Click(sender As Object, e As RoutedEventArgs)
if Status <> PRINTER_PAPER_OUT then
Await Write(txtTextTosend.Text + vbLf)
End if
End Sub
R&D
I have noticed in the Documentation (Page 10-11 of another EPSON printer model) a certain ASB Status
which is defined as follows:
Auto Status Back: This is a function of the TM printer. This is a status automatically sent from the printer when the printer status changes (opening or closing the cover, out of paper, print completed, etc.).
It is later mentioned (Page 22) that ASB_RECEIPT_END
is a constant which is linked with the printer having no paper
The Question
How do we use the ASB status
mentioned earlier to know if the printer is in a "Out of Paper" state ?
If the ASB status
is not the way to go to obtain the information could someone point me in the correct direction ?
Note that I do not mind C# or VB.NET code
What needs to be done
Learn about and use ESC/POS commands
Activate the ASB (
GS a
command)Activate the Group Separator Command
GS
This will separate the
Write
for theASB
and theWrite
for the Text avoiding to print something like :aTEXTTOPRINT
Read the status sent back from the printer
Verify if the state is out of paper
The Code
First a
READ
function is needed which will read the bytes and convert it to a stringSecondly it is needed to send the commands mentioned above for this to work
Documentation
Some commands
Some more commands
MOAR Commands
http://www.asciitable.com (ASCII table makes it easier to figure out commands)