问题
I'm messing around with a Honeywell 4600 barcode scanner in python, configured as a serial device. All is well and I can read barcodes with it, but I would like to test the serial trigger option instead of pressing the trigger all the time. The manual is very brief on this feature and only states "SYN T CR" has to be written to the device to activate the serial trigger
ser.write('SYN T CR')
does not seem to do much.
Can someone point me in the right direction? Thank you!
回答1:
This happens because you coded the abstract expression written in the document as raw output data.
The document represents 3 bytes of data transmission.
'SYN' and 'CR' are the following hexadecimal numbers.
'SYN' = \x16
'CR' = \x0d or escape sequence \r
'T' is an ordinary ASCII character.
Whitespace is used to separate the data in the document, not data to send.
You should write like this. Please try it.
ser.write(b'\x16T\r')
Alternatively, perhaps even you may need to prefix it.
Send data to Honeywell Xenon 1902 barcode reader via virtual com port
In that case, please try the following transmission.
ser.write(b'\x16M\r\x16T\r')
来源:https://stackoverflow.com/questions/50807334/python-barcode-scanner-serial-trigger