ich bin neu in der Programmierung und habe mich als erstes Projekt an eine Stempeluhr begeben.
Diese besteht aus folgender Hardware:
- Raspberry Pi zero W
- Mifare RC522 RFID leser
- Display einer Rückfahrkamera
- 3D gedrucktem Gehäuse
- Active Buzzer
- 5V 4A Netzteil
- Raspbian Stretch with desktop
- Small Time
Es läuft auch ganz hervorragend wenn es läuft. Allerdings hängt sich das ganze nach unbestimmter zeit einfach auf.
Kein Error oder sonstige Fehlermeldungen.
Wenn ich mich über ssh anmelde um den Fehler zu prüfen oder irgendwie mal zu schauen was sein könnte, so läuft wieder alles ganz normal.
Hier der code:
Code: Alles auswählen
#/usr/bin/env python
# -*- coding: utf8 -*-
import RPi.GPIO as GPIO
import MFRC522
import signal
import time
import os, sys
import urllib2, time
terminal = 'http://localhost/terminal.php?rfid='
continue_reading = True
# Capture SIGINT for cleanup when the script is aborted
def end_read(signal,frame):
global continue_reading
print "Ctrl+C captured, ending read."
continue_reading = False
GPIO.cleanup()
# Hook the SIGINT
signal.signal(signal.SIGINT, end_read)
# Hook the SIGINT
signal.signal(signal.SIGINT, end_read)
mifare = MFRC522.MFRC522()
os.system('clear')
print 'ready to read:'
while continue_reading:
# Scan for cards
(status,TagType) = mifare.MFRC522_Request(mifare.PICC_REQIDL)
(status,uid) = mifare.MFRC522_Anticoll()
# If a card is found
if status == mifare.MI_OK:
print "Card detected"
#time.sleep(0.1)
# If we have the UID, continue
if status == mifare.MI_OK:
# Print UID
print "Card read UID: "+str(uid[0])+","+str(uid[1])+","+str(uid[2])+","+str(uid[3])
uid_str = ''.join(str(e) for e in uid)
print terminal+uid_str
if uid_str <> '':
print '-> verbinde mit Server .......'
print ''
try:
info = urllib2.urlopen(terminal + uid_str).read()
info = info.replace('Zeit fehlt!', '\033[1;31mZeit fehlt!\033[1;32m')
print '\033[1;32m' + info + '\033[1;m'
time.sleep(3)
except:
print ('\033[1;31m' + 'Stempel - Fehler!' + '\033[1;m')
time.sleep(1)
pass
else:
print ('\033[1;31m' + 'System- Fehler!' + '\033[1;m')
time.sleep(1)
os.system('clear')
print 'ready to read:'
time.sleep(0.1)
Vielen Danke
Gruß
Olli