Android Question Print via the local network

Discussion in 'Android Questions' started by vecino, Jun 2, 2015.

  1. vecino

    vecino Well-Known Member Licensed User

    Hello, is it possible to print to a local network?
    No internet. It is a local network with cable and wifi.
     
  2. DonManfred

    DonManfred Expert Licensed User

    See Serial-Library. If your printer can be accessed by wifi then it should be possible to send print commands with the serial lib to this printer.
     
    vecino likes this.
  3. vecino

    vecino Well-Known Member Licensed User

    Hi, thanks for responding.
    The printer is connected via a LAN cable.
    Is it possible then with serial library?
     
  4. DonManfred

    DonManfred Expert Licensed User

    I dont know, sorry.
     
  5. picenainformatica

    picenainformatica Active Member Licensed User

    Model of printer?
     
  6. vecino

    vecino Well-Known Member Licensed User

    A Epson TM-T20 II and other 'chinese' unbranded :)
    I need to connect via LAN cable.
     
  7. picenainformatica

    picenainformatica Active Member Licensed User

    Try to connect on port 9100. Send ASCII text directly on output stream. Be sure to close connection after send complete.
     
    vecino likes this.
  8. vecino

    vecino Well-Known Member Licensed User

    Thanks, I'll try.
     
  9. Peter Simpson

    Peter Simpson Well-Known Member Licensed User

    Epson TM-T20 II

    @vecino I would use the Network library and the RandonAccessFile library, see the code below.
    Code:
    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"91000'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.
    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...
     
    Last edited: Sep 15, 2015
    luke2012, Ed Brown, microbox and 5 others like this.
  10. vecino

    vecino Well-Known Member Licensed User

    Oh!, thank you very much, that's great. I'll try :)
     
  11. vecino

    vecino Well-Known Member Licensed User

    Fantastic, Great !!!
    Thank you very much :)

    I have a question. How I can know the port?
    I made a loop, testing port 1, 2, 3, 4, 5, etc.
    It was finally port 9100
     
    Peter Simpson likes this.
  12. picenainformatica

    picenainformatica Active Member Licensed User

    The default i 9100.
     
    Peter Simpson and vecino like this.
  13. vecino

    vecino Well-Known Member Licensed User

    I did not know :)
     
  14. vecino

    vecino Well-Known Member Licensed User

    At the moment it is running tests I'm doing.

    Thank you very much :)
     
    Peter Simpson likes this.
  15. sakissoft

    sakissoft Member Licensed User


    Ok . This sample printing Ok only latin characters but GREEK characters NO.
    I try alls greek codepage programmatically but ...nothing

    Any idea...?
     
  16. rboeck

    rboeck Well-Known Member Licensed User

  17. sakissoft

    sakissoft Member Licensed User

    I try alls greeks codepages with code from epson esc pos (pdf) but nothing. But i don't try with configuration utility. I try this
    Thanks rboeck
     
  18. Peter Simpson

    Peter Simpson Well-Known Member Licensed User

    @sakissoft have you tried changing the 'Page Code' in the printer...
     
  19. sakissoft

    sakissoft Member Licensed User

    OK
    must Be Remove this :

    SendMsg = Chr(27) & Chr(61) & Chr(1) 'Select EPSON printer
    AStreams.Write(SendMsg.GetBytes("UTF8"))

    and alls codepages (and GREEK) is worked !!

    :)
     
  20. Erel

    Erel Administrator Staff Member Licensed User

    Note that these two lines are equivalent to:
    Code:
    AStreams.Write(Array As Byte(27611))
     
    vecino and Peter Simpson like this.
Loading...