简体   繁体   中英

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. 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. 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. 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? for example, using the smartWedgelite software, I got the barcode result "0026229420764" returned. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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