I dont know, sorry.The printer is connected via a LAN cable.
Is it possible then with serial library?
Sub Process_Globals
Dim TMT20II As Socket 'Network library
Dim AStreams As AsyncStreams 'RandomAccessFile library
End Sub
Sub Activity_Create(FirstTime As Boolean)
TMT20II.Initialize("TMT20II")
TMT20II.Connect("192.168.0.100", 9100, 0) '100=Printer address, 9100=Port number (please look up port number)
End Sub
Sub TMT20II_Connected (Successful As Boolean)
Log(Successful)
If Successful Then
AStreams.Initialize(TMT20II.InputStream, TMT20II.OutputStream, "AStreams")
CallSub(Null, SendToPrinter)
End If
End Sub
Sub SendToPrinter
Dim SendMsg As String
SendMsg = Chr(27) & Chr(61) & Chr(1) 'Select EPSON printer
AStreams.Write(SendMsg.GetBytes("UTF8"))
SendMsg = "Hello, this is a test print" 'Send this line to the EPSON printer
AStreams.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(27) & Chr(100) & Chr(2) 'Line feed
AStreams.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(27) & Chr(109) 'Partial cut receipt paper
AStreams.Write(SendMsg.GetBytes("UTF8"))
End Sub
'You need to add more AStreams subs here.
Epson TM-T20 II
@vecino I would use the Network library and the RandonAccessFile library, see the code below.
B4X:Sub Process_Globals Dim TMT20II As Socket 'Network library Dim AStreams As AsyncStreams 'RandomAccessFile library End Sub Sub Activity_Create(FirstTime As Boolean) TMT20II.Initialize("TMT20II") TMT20II.Connect("192.168.0.100", 169, 0) '100=Printer address, 169=Port number (please look up port number) End Sub Sub TMT20II_Connected (Successful As Boolean) Log(Successful) If Successful Then AStreams.Initialize(TMT20II.InputStream, TMT20II.OutputStream, "AStreams") CallSub(Null, SendToPrinter) End If End Sub Sub SendToPrinter Dim SendMsg As String SendMsg = Chr(27) & Chr(61) & Chr(1) 'Select EPSON printer AStreams.Write(SendMsg.GetBytes("UTF8")) SendMsg = "Hello, this is a test print" 'Send this line to the EPSON printer AStreams.Write(SendMsg.GetBytes("UTF8")) SendMsg = Chr(27) & Chr(100) & Chr(2) 'Line feed AStreams.Write(SendMsg.GetBytes("UTF8")) SendMsg = Chr(27) & Chr(109) 'Partial cut receipt paper AStreams.Write(SendMsg.GetBytes("UTF8")) End Sub 'You need to add more AStreams subs here.
Once connected to the printer, you can use AsyncStreams to send escape codes and data stream directly to the receipt printer over the LAN.
Please note: I have not actually done this before, but I can't see why the above code would not work. The code should work just fine IMO...