从 COM 端口读取数据
我想从条形码扫描仪获取输入,该扫描仪连接到 CHD 收银机,而 CHD 收银机通过 COM 端口连接到 Windows XP PC。我想从扫描仪和收银机读取数据,并将数据发送到一个程序,该程序有一个包含商店中商品的表格。并提供一个删除项目的功能。
我应该从哪里开始? Delphi 或 Java 中是否有代码可以将这些数据输入到程序中?
I want to get input from a barcode-scanner, which is connected to a CHD cash register, which is connected to a Windows XP PC trough a COM port. I want to read the data from the scanner and the cash register, and send the data to a program, which has a table with items in a shop. And provide a function which removes items, too.
Where should I start? Is there a code in Delphi or Java, that can get that data into a program?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
@Demonick,大多数条码扫描仪的工作原理只是作为键盘中断。您只需设置文本控件的焦点(例如 TEdit 或 < a href="http://docwiki.embarcadero.com/VCL/en/StdCtrls.TMemo" rel="nofollow noreferrer">TMemo) 将接收条形码,就像使用键盘键入一样。
无论如何,如果您需要使用 delphi 访问 com 端口,您可以使用 TurboPower Async 库 或 ComPort 库。
@Demonick, most barcode scanners work is simply as a keyboard interrupt. you need just set the focus of an text control (like an TEdit or TMemo) an will receive the barcode as if it was typed using the keyboard.
Anyway if you need access the com port using delphi you can use the TurboPower Async library or the ComPort Library.
我喜欢 TComPort,但如果您更喜欢编写自己的代码,也可以使用 ReadFile。
I like TComPort, but if you prefer to write your own code you can also use ReadFile.
还有来自 Synapse 项目的 comport 库:Synaser。我没有使用过 Synaser,但我对 Synapse 有很好的体验,Synaser 应该非常相似。
There's also comport library from Synapse project: Synaser. I haven't used Synaser, but I have good experiences with Synapse and Synaser should be pretty similar.