views:

75

answers:

2

Hi,

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

A: 

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
man, thankyou. il just have to figure out a way to retrive that signal/status flag
Alexander
A: 

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