Federico Leoni
Federico Leoni

Reputation: 111

Pyserial: emulate a RS232 barcode scanner

I have a cash register that can be equipped with a serial bar code scanner (EAN13) and I would like to send the code from Odoo (OpenERP) directly using a real RS232 (DB9) port. I've connected the cable but I have no idea hot to send the code to the machine. I mean I know how basically Pyserial works but I don't know if the configuration is right because the ELGIN (the producer) doesn't share any kind of technical information. All I know is that the equipment is compatible with any EAN13 serial BC scanner. The setting I'm using are the following:

--- Settings: /dev/ttyS0 9600,8,N,1 --- RTS: active DTR: active BREAK: inactive --- CTS: inactive DSR: inactive RI: active CD: inactive --- software flow control: inactive --- hardware flow control: inactive --- data escaping: raw linefeed: CR/LF

And this is how I'm trying to send the code to the cash register:

import serial
ser = serial.Serial(0)  
print ser.name          
ser.write("1001000000006")     
ser.close()

Since seems a "one-way-communication" I did't figure out where the error is because Pyhton send the code and exit without errors. Any tips?

Upvotes: 0

Views: 1753

Answers (1)

Flash Thunder
Flash Thunder

Reputation: 12045

Most RS232 barcode scanners are sending EANs in raw form, but in line by line form. Every line has to end with \r\n.

Upvotes: 1

Related Questions