0
I am trying to use the serial port on the Raspberry but when I run the example below I have the message:
TypeError: ‘module’ object is not callable
import time
import serial
ser = serial.serial(
port='/dev/ttyUSB0',
baudrate = 9600,
parity=0,
stopbits=1,
bytesize=8,
timeout=1
)
while 1:
ser.write('A')
x=ser.readline()
print (x)
time.sleep(1)
New contributor
-
Hi @Wagner Ideali, Welcome. Ah let me see. Your edited program does not seem to match the earlier error message, therefore should mislead future readers. Anyway, I tried tracin back the original picture and reproduce your situation, but failed: imgur.com/gallery/1Rh4vVk. – tlfong01 41 mins ago
-
Your original version seems to have a syntax/typo error of “serial.serial(…)” which should read “serial.Serial(…)”. So I tried to run your version 1 and got the same error as yours. So far so good. Now your version 2 have a new error. I guess it is the serial/.write and serial readline error. Anyway I have summarized version 1 and version 2 results in the following penzu link:penzu.com/p/350d51c9. If you can confirm I have understood your question correctly, then I would move on to compile my answer. Cheers.. – tlfong01 18 mins ago
0
Linux and Python are case sensitive.
Try ser = serial.Serial(
-
-
1@WagnerIdeali You should edit your question to add information, not add a comment. – joan 10 hours ago
-
1@WagnerIdeali There is a link below your question named edit. Please click on it and add additional information to the question. – Ingo 7 hours ago
Categories: Uncategorized