确保连接到通过 COM 连接的 POSPrinter
在将数据写入数据库然后打印收据之前,我需要确保与 POS 打印机的连接成功。 POSprinter 通常为 BTP 2002NP 类型,但可能有所不同。共同点是它们都是通过 COM 端口而不是 USB 连接的,因此客户端上根本没有安装任何驱动程序。
我可以在 COM 端口上发送某种“ping”并检查设备是否已连接并打开?非常感谢任何帮助或建议。
附加信息,该应用程序是在 VB.net 和 Visual Studio 2008 中开发的
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您所能做的就是向 com 端口写出一个字符串,然后等待,看看您的打印机是否做出响应。然而,您写入的字符串和您期望的字符串将取决于打印机本身。
有关示例,请参阅 BTP 2002NP 打印机编程手册 (我查看的谷歌中的第一个链接)
通过查看手册,发送到打印机的适当字符串是“DLE EOT n”命令,该命令请求打印机发回其当前状态。
至于该系列中的其他打印机,请查看此驱动程序和手册列表
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
顺便说一句,这就是我最后想到的。
该函数返回 1 个字节。然后我可以从手册中将该字节转换为打印机当前所处的状态。这可能适用于所有 ESC/P 打印机。
btw, this is what i came up with in the end.
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.