]> git.somenet.org - pub/jan/scripts.git/blob - barcode.py
use bug to generate deltat-game-credits.
[pub/jan/scripts.git] / barcode.py
1 #!/usr/bin/env python
2
3 import time
4 import serial
5
6 # configure the serial connections (the parameters differs on the device you are connecting to)
7 ser = serial.Serial()
8 ser.port = '/dev/ttyACM0'
9 ser.baudrate = 9600
10 ser.parity = serial.PARITY_NONE
11 ser.stopbits = serial.STOPBITS_ONE
12 ser.bytesize = serial.EIGHTBITS
13 ser.timeout = None
14 ser.open()
15
16
17 print ser
18 print 'Connected, configuring...'
19 time.sleep(1)
20 ser.write('\r')
21 ser.write('$+$!$-\r')
22 time.sleep(1)
23
24
25 try:
26     print 'Starting read loop...'
27     while True:
28         data = ser.readline()
29         print '>> '+data,
30
31 except Exception, e:
32     print "error open serial port: " + str(e)
33     ser.close()
34
35