Jump to content

Janik

Members
  • Gesamte Inhalte

    13
  • Benutzer seit

  • Letzter Besuch

Janik's Achievements

Newbie

Newbie (1/14)

0

Reputation in der Community

  1. Hallo Photron Ich habe das Problem gelöst. Ich hatte beim erstellen der Sqlite3 Tabellen keine Datentypen angegeben. Jetzt habe ich alle Spalten mit INTEGER Datentyp, es kommt die gewünschte Ausgabe im Excel-File.
  2. Das mit dem connection.close() habe ich schon gefixt.
  3. Hallo photron Ich habe den Trick mit den Prints schon gemacht. Python führt den Sqlite3 Teil aus, es steht aber nichts in der DB.
  4. In meiner Datenbank sind nur die Tabellen drin, es hat keine Einträge, obwohl ich den Tag mehrmals auf das NFC-Bricklet draufgehalten habe.
  5. Hallo zusammen Ich wage einem neuen Anlauf. Es wird alles in Python3 ausgeführt und sollte meiner Meinung nach funktionieren. Es gibt keine Fehlermeldungen. Was mach ich schon wieder Falsch??? Script auf dem Raspberry pi #!/usr/bin/env python # -*- coding: utf-8 -*- HOST = "localhost" PORT = 4223 UID = "uo1" from tinkerforge.ip_connection import IPConnection from tinkerforge.bricklet_nfc_rfid import BrickletNFCRFID import sqlite3 import time tag_type = 0 def cb_state_changed(state, idle, nfc): if idle: global tag_type tag_type = (tag_type + 1) % 3 nfc.request_tag_id(tag_type) if state == nfc.STATE_REQUEST_TAG_ID_READY: ret = nfc.get_tag_id() tp = str(" ".join(map(str, map(hex, ret.tid[:ret.tid_length])))) if tp == "0x4 0x98 0x5d 0x32 0xba 0x2f 0x80": connection = sqlite3.connect("arbeitszeit.db") cursor = connection.cursor() connection.commit() print("geklappt") try: cursor.connection.cursor() cursor.execute('''INSERT INTO kast VALUES (date('now'), time('now'))''') connection.commit() except: print('Transaktionsprobleme Andrea Kast!!!') print('Bitte in 1 Minute nochmals einstempeln') #Rot Blinken!!!!!!(Raspi Led) connection.rollback() if __name__ == "__main__": ipcon = IPConnection() nfc = BrickletNFCRFID(UID, ipcon) ipcon.connect(HOST, PORT) nfc.register_callback(nfc.CALLBACK_STATE_CHANGED, lambda x, y: cb_state_changed(x, y, nfc)) nfc.request_tag_id(tag_type) input("Beenden\n") ipcon.disconnect() Script auf dem Pc der die Daten auslesen soll, allerdings wird das Excel Sheet leer.(Hauptproblem) import sys from tkinter import * import sqlite3 from xlsxwriter.workbook import Workbook def importexcel(): workbook = Workbook('arbeitszeit.xlsx') worksheet = workbook.add_worksheet() conn=sqlite3.connect('arbeitszeit.db') c=conn.cursor() c.execute("select * from kast") mysel=c.execute("select * from kast") for i, row in enumerate(mysel): for j, value in enumerate(row): worksheet.write(i, j, row[j]); workbook.close() mLabel2 = Label(mGui,text='alles importiert, Datei liegt auf dem Desktop.').pack() mGui =Tk() mGui.geometry('450x450') mGui.title('Excel Datei Importierer') mLabel = Label(mGui,text='janik Ruggle Label').pack() mbutton = Button(mGui,text ='import excel file', command = importexcel).pack()
  6. Das geht leider nicht, weil ich Python 3 benutze.
  7. Hi photron Ich habe das ganze nochmal angepasst, soweit ich deine Angaben verstehen konnte. Leider kommt immer noch die Fehlermeldung mit dem Threading. Liegt das daran dass mein Raspberry pi nur einen Core hat? Oder Habe ich wieder einen Fehler? kann es sein, dass die Tinkerforge-Teile zu schnell nach dem Tag abgefragt werden? Danke für deine Geduld #!/usr/bin/env python # -*- coding: utf-8 -*- HOST = "localhost" PORT = 4223 UID = "uo1" from tinkerforge.ip_connection import IPConnection from tinkerforge.bricklet_nfc_rfid import BrickletNFCRFID import sqlite3 import time tag_type = 2 def cb_state_changed(state, idle, nr): if idle: nr.request_tag_id(nr.TAG_TYPE_TYPE2) if state == nr.STATE_REQUEST_TAG_ID_READY: ret = nr.get_tag_id() if (" ".join(map(str, map(hex, ret.tid[:ret.tid_length])))) == "04 98 5D 32 BA 2F 80": connection = sqlite3.connect("arbeitszeit.db") cursor = connection.cursor() connection.commit() print("geklappt") try: cursor.connection.cursor() cursor.execute('''INSERT INTO kast VALUES (date('now'), time('now'))''') connection.commit() except: print('Transaktionsprobleme Andrea Kast!!!') print('Bitte in 1 Minute nochmals einstempeln') #Rot Blinken!!!!!!(Raspi Led) connection.rollback() elif (" ".join(map(str, map(hex, ret.tid[:ret.tid_length])))) == "04 98 5D 32 BA 2F 81": connection = sqlite3.connect("arbeitszeit.db") cursor = connection.cursor() connection.commit() try: cursor.connection.cursor() cursor.execute('''INSERT INTO jud VALUES (date('now'), time('now'))''') time.sleep(2) connection.commit() print("geklappt") except: print('Transaktionsprobleme Oliver Jud!!!') print('Bitte in 1 Minute nochmals einstempeln') #Rot Blinken!!!!!!(Raspi Led) time.sleep(2) connection.rollback() if (" ".join(map(str, map(hex, ret.tid[:ret.tid_length])))) == "04 98 5D 32 BA 2F 82": connection = sqlite3.connect("arbeitszeit.db") cursor = connection.cursor() connection.commit() try: cursor.connection.cursor() cursor.execute('''INSERT INTO ruegg VALUES (date('now'), time('now'))''') time.sleep(2) connection.commit() except: print('Transaktionsprobleme Oliver Patrick Ruegg!!!') print('Bitte in 1 Minute nochmals einstempeln') #Rot Blinken!!!!!!(Raspi Led) time.sleep(4) connection.rollback() if __name__ == "__main__": ipcon = IPConnection() nr = BrickletNFCRFID(UID, ipcon) ipcon.connect(HOST, PORT) nr.register_callback(nr.CALLBACK_STATE_CHANGED, lambda x, y: cb_state_changed(x, y, nr)) nr.request_tag_id(nr.TAG_TYPE_TYPE2) input("Beenden\n") ipcon.disconnect() Noch eine der Fehlermeldungen SyntaxError: unexpected EOF while parsing Exception in thread Disconnect-Prober (most likely raised during interpreter shutdown): Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner File "/usr/lib/python2.7/threading.py", line 763, in run File "build/bdist.linux-armv6l/egg/tinkerforge/ip_connection.py", line 822, in disconnect_probe_loop File "/usr/lib/python2.7/Queue.py", line 174, in get <type 'exceptions.TypeError'>: 'NoneType' object is not callable
  8. Hallo zusammen Ich habe erfolglos versucht eine While Schleife in das Skript einzubauen. Das Skript sollte sich im Abstand von z.B. 5 Sekunden wiederholen. Wenn ich über der Definition von cb_state_changed eine While Schleife einfüge, kommen Fehlermeldungen aus der TK Library und mit multiprocessing... Vieleicht wisst ihr was es ist (was ich falsch mache) oder ich zeige noch die Fehlermeldungen.
  9. Danke für die Antwort Noch eine Frage, was muss ich machen damit das Programm sich wiederholt?
  10. Hallo zusammen Ich habe ein Problem wenn ich mein Python 3 Programm, mit dem ich einen Masterbrick mit einem NFC Bricklet ansteuern möchte, ausführe. Der Raspberry Pi hat einen Samba Server, Brickd und die Tinkerforge Library drauf. Beim Ausführen kommen komische Fehlermeldungen aus der Library. #!/usr/bin/env python # -*- coding: utf-8 -*- HOST = "localhost" PORT = 4223 UID = "uo1" from tinkerforge.ip_connection import IPConnection from tinkerforge.bricklet_nfc_rfid import BrickletNFCRFID import sqlite3 import time def cb_state_changed(state, idle, nr): if state == nr.STATE_REQUEST_TAG_ID_READY: #data = nr.get_page() ist probehalber hier# data = nr.get_page() if ("[" + " ".join(map(str, data)) + "]") == """Nummer des NFC-Tags von kast""": connection = sqlite3.connect("arbeitszeit.db") cursor = connection.cursor() connection.commit() try: cursor.connection.cursor() cursor.execute('''INSERT INTO kast VALUES (date('now'), time('now'))''') time.sleep(2) connection.commit() except: print('Transaktionsprobleme Andrea Kast!!!') print('Bitte in 1 Minute nochmals einstempeln') #Rot Blinken!!!!!!(Raspi Led) time.sleep(4) connection.rollback() if ("[" + " ".join(map(str, data)) + "]") == """Nummer des NFC-Tags von jud""": connection = sqlite3.connect("arbeitszeit.db") cursor = connection.cursor() connection.commit() try: cursor.connection.cursor() cursor.execute('''INSERT INTO jud VALUES (date('now'), time('now'))''') time.sleep(2) connection.commit() except: print('Transaktionsprobleme Oliver Jud!!!') print('Bitte in 1 Minute nochmals einstempeln') #Rot Blinken!!!!!!(Raspi Led) time.sleep(4) connection.rollback() if ("[" + " ".join(map(str, data)) + "]") == """Nummer des NFC-Tags von ruegg""": connection = sqlite3.connect("arbeitszeit.db") cursor = connection.cursor() connection.commit() try: cursor.connection.cursor() cursor.execute('''INSERT INTO ruegg VALUES (date('now'), time('now'))''') time.sleep(2) connection.commit() except: print('Transaktionsprobleme Oliver Patrick Ruegg!!!') print('Bitte in 1 Minute nochmals einstempeln') #Rot Blinken!!!!!!(Raspi Led) time.sleep(4) connection.rollback() if __name__ == "__main__": ipcon = IPConnection() nr = BrickletNFCRFID(UID, ipcon) ipcon.connect(HOST, PORT) nr.register_callback(nr.CALLBACK_STATE_CHANGED, lambda x, y: cb_state_changed(x, y, nr)) nr.request_tag_id(nr.TAG_TYPE_TYPE2) Fehlermeldung pi@stempeluhr:~ $ sudo python beta_1.2.py Exception in thread Brickd-Receiver (most likely raised during interpreter shutdo wn):Exception in thread Disconnect-Prober (most likely raised during interpreter shutdown): Traceback (most recent call last):Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner File "/ usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner File "/usr/lib/python2.7/threading.py", line 763, in run File "/usr/lib/python 2.7/threading.py", line 763, in run File "build/bdist.linux-armv6l/egg/tinkerforge/ip_connection.py", line 822, in disconnect_probe_loop File "build/bdist.linux-armv6l/egg/tinkerforge/ip_connecti on.py", line 687, in receive_loop <type 'exceptions.TypeError'>: 'NoneType' object is not callable File "/usr/lib/ python2.7/Queue.py", line 174, in get <type 'exceptions.TypeError'>: 'NoneType' object is not callable
  11. Janik

    Python 3

    Ich werde das mal probieren hatte die API nicht heruntergeladen und habe mich aufgeregt. Ich habe folgende Fehlermeldung erhalten: Traceback (most recent call last): File "C:\Python27\tinkerforge\software\examples\python\example_callback.py", line 8, in <module> from tinkerforge.ip_connection import IPConnection ImportError: No module named tinkerforge.ip_connection
  12. Janik

    Python 3

    Ich habe immer noch nicht kapiert wie ich über python auf den master zugreiffen kann. Kann mir jemand das richtig erklären.
×
×
  • Neu erstellen...