From fb99298b54419243cf3b19f95be92533294c63ab Mon Sep 17 00:00:00 2001 From: Someone Date: Mon, 5 Sep 2016 16:21:41 +0200 Subject: [PATCH] barcode.py -- usb barcode reader stuff --- barcode.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 barcode.py diff --git a/barcode.py b/barcode.py new file mode 100755 index 0000000..a3750da --- /dev/null +++ b/barcode.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +import time +import serial + +# configure the serial connections (the parameters differs on the device you are connecting to) +ser = serial.Serial() +ser.port = '/dev/ttyACM0' +ser.baudrate = 9600 +ser.parity = serial.PARITY_NONE +ser.stopbits = serial.STOPBITS_ONE +ser.bytesize = serial.EIGHTBITS +ser.timeout = None +ser.open() + + +print ser +print 'Connected, configuring...' +time.sleep(1) +ser.write('\r') +ser.write('$+$!$-\r') +time.sleep(1) + + +try: + print 'Starting read loop...' + while True: + data = ser.readline() + print '>> '+data, + +except Exception, e: + print "error open serial port: " + str(e) + ser.close() + + -- 2.43.0