Jump to content

Zerin

Members
  • Gesamte Inhalte

    3
  • Benutzer seit

  • Letzter Besuch

Letzte Besucher des Profils

Der "Letzte Profil-Besucher"-Block ist deaktiviert und wird anderen Benutzern nicht angezeit.

Zerin's Achievements

Newbie

Newbie (1/14)

  • First Post
  • Conversation Starter
  • One Month Later
  • Week One Done

Recent Badges

0

Reputation in der Community

  1. Thank you :) I will try "Restart=always" as you suggested
  2. Hello, I want to run a python script 24/7. I am using systemd service and it looks like this: [Unit] Description= start code After=multi-user.target [Service] Type=simple ExecStart= /usr/bin/python3 /home/pi3/code1.py Restart=on-abort [Install] WantedBy=multi-user.target When I enabled the systemd service it was running without error. but after few hours it stopped. I got the following error. ● codestart.service - start code Loaded: loaded (/lib/systemd/system/codestart.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Tue 2022-06-07 16:13:15 CEST; 20h ago Process: 859 ExecStart=/usr/bin/python3 /home/pi3/code1.py (code=exited, status=1/FAILURE) Main PID: 859 (code=exited, status=1/FAILURE) CPU: 1.086s Jun 07 16:13:15 raspberrypi python3[859]: File "/home/pi3/code1.py", line 54, in main Jun 07 16:13:15 raspberrypi python3[859]: ipcon.connect(HOST, PORT) Jun 07 16:13:15 raspberrypi python3[859]: File "/usr/local/lib/python3.9/dist-packages/tinkerforge/ip_connection.py", lin> Jun 07 16:13:15 raspberrypi python3[859]: self.connect_unlocked(False) Jun 07 16:13:15 raspberrypi python3[859]: File "/usr/local/lib/python3.9/dist-packages/tinkerforge/ip_connection.py", lin> Jun 07 16:13:15 raspberrypi python3[859]: tmp.connect((self.host, self.port)) Jun 07 16:13:15 raspberrypi python3[859]: OSError: [Errno 101] Network is unreachable Jun 07 16:13:15 raspberrypi systemd[1]: codestart.service: Main process exited, code=exited, status=1/FAILURE Jun 07 16:13:15 raspberrypi systemd[1]: codestart.service: Failed with result 'exit-code'. Jun 07 16:13:15 raspberrypi systemd[1]: codestart.service: Consumed 1.086s CPU time. ~ Can you please suggest what should I do to restart the code in case of network failure? Thanks
  3. Hallo, Ich versuche, die Sensordaten alle 10 Sekunden abzurufen und in einer CSV-Datei zu speichern. Ich brauche kontinuierliche Daten. Aber ich erhalte einen Fehler. Den Code habe ich angehängt HOST = "192.168.0.104" PORT = 4223 UID_tem = "Nwv" # Change XYZ to the UID of your Temperature Bricklet 2.0 import csv from tinkerforge.ip_connection import IPConnection def cb_temperature(temperature): print("Temperature: " + str(temperature/100.0) + " °C") output1.writerow([str(temperature/100.0)]) if __name__ == "__main__": ipcon = IPConnection() # Create IP connection t = BrickletTemperatureV2(UID_tem, ipcon) # Create device object ipcon.connect(HOST, PORT) # Connect to brickd t.set_temperature_callback_configuration(1000, False, "x", 0, 0) csvfile1= open ('/home/pi/temp1_data.csv','wb') output1 = csv.writer(csvfile1,delimiter=';', quotechar='|') output1.writerow(['temperature']) t.register_callback(t.CALLBACK_TEMPERATURE, cb_temperature) csvfile1.close() input("Press key to exit\n") # Use raw_input() in Python 2 ipcon.disconnect() Ich erhalte den folgenden Fehler: Exception in thread Callback-Processor: Traceback (most recent call last): File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner self.run() File "/usr/lib/python3.9/threading.py", line 892, in run self._target(*self._args, **self._kwargs) File "/home/pi/.local/lib/python3.9/site-packages/tinkerforge/ip_connection.py", line 1239, in callback_loop self.dispatch_packet(data) File "/home/pi/.local/lib/python3.9/site-packages/tinkerforge/ip_connection.py", line 1219, in dispatch_packet cb(unpack_payload(payload, form)) File "/home/pi/Desktop/testtempcsv.py", line 23, in cb_temperature output1.writerow([str(temperature/100.0)]) ValueError: I/O operation on closed file. Kann mir jemand freundlicherweise sagen, wie ich das beheben kann? Danke :)
×
×
  • Neu erstellen...