简体   繁体   English

从串口com1读取的Intermec SR61T扫描仪数据

[英]Intermec SR61T scanner data read from serial port com1

I am developing a windows app for data collection, user of my app will need to read the data from scanner, So I use SerialPort to read the barcode. 我正在开发Windows应用程序以进行数据收集,我的应用程序的用户将需要从扫描仪读取数据,因此我使用SerialPort读取条形码。 below is the data read sub, I used the event handler to handle the barcode read event. 下面是数据读取子,我使用事件处理程序来处理条形码读取事件。 I tried readExisting, but it doesn't work at all, below is the code can read and return someting but not correct yet. 我尝试了readExisting,但是它根本不起作用,下面的代码可以读取并返回内容,但还不正确。 Could you help me please? 请问你能帮帮我吗?

Private Sub mySerialPort_DataReceived(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs)
 Dim n As Integer = mySerialPort.BytesToRead 'find number of bytes in buf
 comBuffer = New Byte(n - 1) {} 're dimension storage buffer
 mySerialPort.Read(comBuffer, 0, n) 'read data from
For Each b As Byte In comBuffer   'doesn't work
 str &= CStr(comBuffer(b))  'doesn't work
Next 
End Sub

there is a software called smartWedgeLite on the computer, it can turn the scanner on and off, and get the barcode from com1. 计算机上有一个名为smartWedgeLite的软件,它可以打开和关闭扫描仪,并从com1获取条形码。 I just want this function code to be used in my app, So, I can turn com1 on and off in my App, but I cannot get the correct barcode data returned.Could you tell me what is wrong in this program, why I cannot get the entire barcode string returned? 我只想在我的应用程序中使用此功能代码,因此,我可以在我的应用程序中打开和关闭com1,但是我无法获得正确的条形码数据。您能告诉我该程序有什么问题吗,为什么我不能得到整个条形码字符串返回? for example, using the smartWedgelite software, I got the barcode result "0026229420764" returned. 例如,使用smartWedgelite软件,我得到了条形码结果“ 0026229420764”。 My program above can read and create a byte array "comBuffer", but cannot return a whole string like "0026229420764", I tried to print every byte from this byte array, the result for comBuffer(0) to comBuffer(N)is like 2,0,100,1,0,1,0,0,0,0,0,0,13,0,0,0,5,48,48,......................, it is not like the barcode at all. 我上面的程序可以读取并创建一个字节数组“ comBuffer”,但不能返回整个字符串,例如“ 0026229420764”,我试图从该字节数组中打印每个字节,comBuffer(0)到comBuffer(N)的结果是2,0,100,1,0,1,0,0,0,0,0,0,13,0,0,0,5,48,48,.............. ........,根本不像条形码。 I don't know I can only read in byte? 我不知道我只能读字节吗? how to decode it to be the string code? 如何将其解码为字符串代码?

Make sure that you initialize your serial port with the correct parameters required by the scanner (see hardware documentation). 确保使用扫描仪所需的正确参数初始化串行端口(请参阅硬件文档)。 Like baud rate, parity, data bits, stop bits. 像波特率,奇偶校验,数据位,停止位。 Manufacturers have different settings for their devices. 制造商对其设备有不同的设置。

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

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