added shabang to pc main.py so it can be escecuted with minimal fuzz

This commit is contained in:
Angoosh Leviocki 2023-10-03 01:10:10 +02:00
parent 364d019b3d
commit 51d19ac1f5
Signed by: angoosh
GPG Key ID: 1CCB948F5CBF1995
2 changed files with 31 additions and 5 deletions

8
SW/PC/main.py Normal file → Executable file
View File

@ -1,3 +1,5 @@
#!/usr/bin/python
import serial
import json
from datetime import datetime
@ -73,7 +75,7 @@ def write(ser):
break
def main():
s = serial.Serial(port="/dev/ttyACM1", parity=serial.PARITY_EVEN, stopbits=serial.STOPBITS_ONE, timeout=1)
s = serial.Serial(port="/dev/ttyACM0", parity=serial.PARITY_EVEN, stopbits=serial.STOPBITS_ONE, timeout=1)
s.flush()
rw = input('Read or Write tags? [R/w]')
@ -95,5 +97,5 @@ def main():
if __name__ == "__main__":
main()
if __name__ == "__main__":
main()

View File

@ -89,9 +89,22 @@ def read_nfc_loop():
ntag_string = 'Data: '
sys.stdout.write('Reading ntag \r')
leds_on = 0
for page in range(20,40):
try:
ntag2xx_page = pn532.ntag2xx_read_block(page)
if (page % 2) == 0:
if page == 0:
pass
elif page == 2:
pass
else:
led_strip[leds_on] = (0,0,255)
leds_on += 1
if leds_on > 7:
leds_on = 7
led_strip.write()
if ntag2xx_page is not None:
for char in ntag2xx_page:
@ -162,10 +175,18 @@ def loop():
write_nfc_loop(data)
elif rw == 'r':
while True:
read_nfc_loop()
ret = read_nfc_loop()
if ret == 255:
set_neopixel_color(0,0,255)
rw = None
return 1
elif rw == '':
while True:
read_nfc_loop()
ret = read_nfc_loop()
if ret == 255:
set_neopixel_color(0,0,255)
rw = None
return 1
else:
sys.stdout.write('Invalid option\r')
@ -181,6 +202,9 @@ while True:
while True:
try:
ret = loop()
if ret == 1:
poll_results = None
break
except:
set_neopixel_color(0,0,255)
break