Skip to content

Commit

Permalink
- Added support to python 2
Browse files Browse the repository at this point in the history
  • Loading branch information
berCamargos committed Nov 6, 2017
1 parent bf4cfb2 commit f892a62
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion peopleCounter/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
ser = serial.Serial(serialport, 115200, timeout=1)
while True:
data = ser.read(50)
if len(data) == 5 and data[0] == 48 and data[1] == 48 and data[2] == 48:
if (len(data) == 5 and data[0] == '0' and data[1] == '0' and data[2] == '0') or\
(len(data) == 5 and data[0] == 48 and data[1] == 48 and data[2] == 48 ):

nmacs = struct.unpack("<H", data[3:])[0]
line = str(datetime.datetime.now()) + ' ' + str(nmacs) + '\n'
f = open('counter.txt', 'a')
Expand All @@ -20,4 +22,7 @@
f.write(struct.pack("<H", nmacs))
f.close()
print(line)
else:
if len(data) == 5:
print(data[0])

0 comments on commit f892a62

Please sign in to comment.