简体   繁体   English

从COM端口读取数据

[英]Reading data from a COM port

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. 我想从条形码扫描仪获取输入,该条形码扫描仪连接到CHD收银机,该收银机通过COM端口连接到Windows XP PC。 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? Delphi或Java中是否有代码可以将这些数据存储到程序中?

@Demonick, most barcode scanners work is simply as a keyboard interrupt. @Demonick,大多数条形码扫描仪的工作只是作为键盘中断。 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. 您只需要设置文本控件(如TEditTMemo )的焦点,就可以像使用键盘输入条形码一样接收条形码。

Anyway if you need access the com port using delphi you can use the TurboPower Async library or the ComPort Library . 无论如何,如果您需要使用delphi访问com端口,则可以使用TurboPower异步库ComPort库

我喜欢TComPort,但是如果您喜欢编写自己的代码,则也可以使用ReadFile。

There's also comport library from Synapse project: Synaser . 还有来自Synapse项目的comport库: Synaser I haven't used Synaser, but I have good experiences with Synapse and Synaser should be pretty similar. 我没有使用过Synaser,但是我对Synapse有很好的经验,Sinaser应该非常相似。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM