1

I need to make sure that the connection to a POS printer is successful before writing data to the database and then printing a receipt. The POSprinter is normally of type BTP 2002NP but may differ. The common thing is that they are all connected via COM-port and NOT usb, so no drivers installed at all on the client.

Can I send some kind of "ping" on a COM-port and check if a device is connected and turned on? Any help or suggestions are very much appreciated.

Additional information, the application is developed in VB.net and Visual Studio 2008

skaffman
  • 398,947
  • 96
  • 818
  • 769
Alexander
  • 97
  • 1
  • 13
  • Is there a special serial protocol or is the printer just dumping any serial communication to the paper? Maybe you should refer to the manual first. – Frank Bollack Sep 08 '09 at 14:31
  • i will have to look into the programming manual. hopefully its the same for all their printers. ESC/P2 standard – Alexander Sep 08 '09 at 14:43
  • I also added a link to the "drivers and manuals" page of that website that shows some related printers. Use google for your requirements! – Peter M Sep 08 '09 at 14:52
  • excelent, thankyou once again! im the worste googler so ): this forum helped me alot. – Alexander Sep 08 '09 at 14:57

2 Answers2

1

About all you can do is write out a character string to the com port and wait and see if your printer responds with a reply. However the string you write and the string you expect will depend on the printer itself.

Refer to the BTP 2002NP printers programming manual for examples (the first link in google that I looked at)

From looking at the manual an appropriate string to send to the printer is the "DLE EOT n" command which requests that the printer send back its current status.

As for other printers in the range, check out this list of drivers and manuals

Peter M
  • 7,309
  • 3
  • 50
  • 91
1

btw, this is what i came up with in the end.

   Public Function ComTest() As Byte()

    Dim TXT As String
    TXT = Chr(&H10S) & Chr(&H4S) & Chr(1) 'DLE EOT 1

    If OpenCom() Then 'Connect to com
        moRS232.PurgeBuffer(Rs232.PurgeBuffers.TxClear Or Rs232.PurgeBuffers.RXClear)
        moRS232.Write(TXT)
        moRS232.Read(1)
        Return moRS232.InputStream
    Else
        Return Nothing          
    End If

End Function

the function returns 1 byte. i can then from the manual translate this byte into what state the printer is currently in. this probably works for all ESC/P printers.

Alexander
  • 97
  • 1
  • 13