ich versuche eine RS232 Schnittstelle auszulesen.
Es scheitert schon direkt beim Import.
Folgendes möchte ich probieren:
Code: Alles auswählen
# Serial1.py
import serial
import time
port = "/dev/ttyAMA0" # Raspberry Pi 2
#port = "/dev/ttyS0" # Raspberry Pi 3
def readLine(port):
s = ""
while True:
ch = port.read()
s += ch
if ch == '\r':
return s
ser = serial.Serial(port, baudrate = 1200)
print("starting")
while True:
time.sleep(1)
print("sending synch")
ser.write("A")
rcv = readLine(ser)
print("received:"), rcv
Code: Alles auswählen
ser = serial.Serial(port, baudrate=1200)
wird unterstrichen … Problem ist .Serialserial.Serial(....)
Ich habe folgende Module installiert:
pip install pyserial
leider trotzdem ohne Erfolg.pip install serial
Ich benutze Python 3.7
Danke für die Hilfe im vorraus
