මම raspberry PI එකක SPI bus එකට rfid reader එකක් සම්බන්ද කරලා Python rfid cards වල data කියවන්න code එකක් ලිව්වා.. මම While loop එකක් දාල තමයි program close එක වෙන්නේ නැතුව දිගටම card කියවන්න පුළුවන් විදියට හැදුවේ.. while loop එක ඇතුලේ තත්පර 5 ක thread sleep එකක් දැම්මා එක card එකක් reader ඇල්ලුවම ගොඩ පාරක් එකේම data කියවන එක නවත්වන්න.. එත් card 3 ක 4 ක සැරයක් error එකක් එනවා.. sleep එක අයින් කරාම නම් මේ error එක එන්නේ නෑ.. එත් මම තාම කියවන data වල history එකක් තියාගන්නේ නැති නිසා backend එකට එක යනවා..
මේක error එක නැති කරගන්න ක්රමයක් තියනවද යාලුවනේ? මිට වඩා මේක කරන්න හොද ක්රම තියනවද?
error
මේක error එක නැති කරගන්න ක්රමයක් තියනවද යාලුවනේ? මිට වඩා මේක කරන්න හොද ක්රම තියනවද?
Python:
#!/usr/bin/env python
import time
import RPi.GPIO as GPIO
from mfrc522 import SimpleMFRC522
import requests
reader = SimpleMFRC522()
try:
while True:
id, text = reader.read()
print(id)
print(text)
# call the webservice and post data
#......
#
print('Waiting for next card to read...')
print('--')
time.sleep(5)
finally:
GPIO.cleanup()
error
Bash:
706556429817
Hello World from card1
Waiting for next card to read...
--
706556429818
Hello World from card2
Waiting for next card to read...
--
706556429817
Hello World from card1
Waiting for next card to read...
--
706556429818
Hello World from card2
Waiting for next card to read...
--
706556429817
Hello World from card1
Waiting for next card to read...
--
Error while reading!
706556429818
Waiting for next card to read...
--