ich versuche mit Hilfe von AT-Kommandos ein SIM_Modul anzusprechen. Dabei verwende ich folgendes kleines Programm, dass über eine serielle Schnittstelle dazu Verbindung aufnimmt.
Code: Alles auswählen
import serial
import os,time
port = serial.Serial("/dev/ttyS0", baudrate = 9600, timeout = 1)
port.write('AT' + '\r\n')
rcv = port.read(10)
print (rcv)
Traceback (most recent call last):
File "/home/pi/SIm.py", line 7, in <module>
port.write('AT' + '\r\n')
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 518, in write
d = to_bytes(data)
File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 63, in to_bytes
raise TypeError('unicode strings are not supported, please encode to bytes: {!r}'.format(seq))
TypeError: unicode strings are not supported, please encode to bytes: 'AT\r\n'
Ich habe es auch schon mit der Kodierung zu Bytes versucht, allerdings auch ohne Erfolg.
Wie sendet man am besten AT-Kommandos? Bzw. Wie kodiert man sie richtig?
Viele Grüße
Lacke