Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4960

Python • Re: send .bin file via USB Port

$
0
0

Code:

import serial# Serielle Schnittstelle und Baudrate anpassenser = serial.Serial('/dev/ttyUSB1', 115200)  # Pfad zur .bin-Dateifile_path = 'pfad/zur/datei.bin' #datei muss noch erstellt werdentry:    with open(file_path, 'rb') as file:        while chunk := file.read(1024):  # Datei in 1024-Byte-Blöcken lesen            ser.write(chunk)            # Optional: Warten auf Bestätigung vom Empfänger            # response = ser.readline()            # print(response.decode('utf-8').strip())    print("Datei erfolgreich gesendet.")except Exception as e:    print(f"Fehler beim Senden der Datei: {e}")finally:    ser.close()
kommt das hin?

danke euch!

Statistics: Posted by SIG-Ricker — Thu Jan 23, 2025 9:41 am



Viewing all articles
Browse latest Browse all 4960

Trending Articles