Code: Alles auswählen
#!/usr/bin/env python
# -*- coding: utf8 -*-
import RPi.GPIO as GPIO
import MFRC522
import signal
import time
continue_reading = True
# Capture SIGINT for cleanup when the script is aborted
def end_read(signal,frame):
global continue_reading
print "\nProgramm beendet!"
continue_reading = False
GPIO.cleanup()
# Hook the SIGINT
signal.signal(signal.SIGINT, end_read)
# Create an object of the class MFRC522
MIFAREReader = MFRC522.MFRC522()
# Welcome message
print "Programm gestartet zum Karten scannen!"
print "Drücke Ctrl-C zum beenden."
# This loop keeps checking for chips. If one is near it will get the UID and authenticate
while continue_reading:
# Scan for cards
(status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)
# If a card is found
#if status == MIFAREReader.MI_OK:
# print "Card detected"
# Get the UID of the card
(status,uid) = MIFAREReader.MFRC522_Anticoll()
# If we have the UID, continue
if status == MIFAREReader.MI_OK:
print "Karte mit Nummer " + str(uid[0]) + str(uid[1]) + str(uid[2]) + str(uid[3]) + " erkannt."
card_id2 = raw_input("Vorname: ")
card_id3 = raw_input("Nachname: ")
#print str(uid[0]) + str(uid[1]) + str(uid[2]) + str(uid[3])
card_id1 = str(uid[0]) + str(uid[1]) + str(uid[2]) + str(uid[3])
file = open("cards_ids.txt", "a")
file.write(card_id1 + "|@|" + card_id2 + "|@|" + card_id3 + "\n")
file.close()
print("Nächste Karte/Chip")
time.sleep(3)
Code: Alles auswählen
file = open("cards_ids.txt", "a")
file.write(card_id1 + "|@|" + card_id2 + "|@|" + card_id3 + "\n")
file.close()
Python 3.5.3 (/usr/bin/python3)
meine versuche es mit einer Datenank ist schief gelaufen, habe verschiedene lösungen gefunden aber keine funktionierte
import MySQLdb und mysql connector hatte ich drin was hier im code nicht vorliegt
meine tabelle
CREATE TABLE tsvw (
id INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
rfid01 VARCHAR(50) COLLATE latin1_german1_ci NOT NULL COMMENT 'RFID ID',
rfid02 VARCHAR(50) COLLATE latin1_german1_ci NOT NULL COMMENT 'Vorname',
rfid03 VARCHAR(50) COLLATE latin1_german1_ci NOT NULL COMMENT 'Nachname' )
Fehler meldungen gab es keine
nur keine einträge
daten aus db auslesen habe ich nicht versucht .
dann fand ich diesen ansatz
was ist mit dieser lösung
Code: Alles auswählen
import telnetlib
def load(self, url):
tn = telnetlib.Telnet(self.host, self.port)
tn.write('window.location="%s"' % url)
result = tn.read_until('\n')
return result
url = "http://localhost/indb.php?rfidToken=" + uidString
c.load(url)