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)
joan
71.9k5 gold badges76 silver badges108 bronze badges
asked Nov 27, 2019 at 12:26
5
  • 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. Commented Nov 28, 2019 at 3:13
  • 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.. Commented Nov 28, 2019 at 3:36
  • I removed the pyserial and re install it and running ok now Commented Dec 1, 2019 at 4:50
  • Thank you for your update. How nice to hear that problem solved. Cheers. Commented Dec 1, 2019 at 5:13
  • Hi tlfong01, I didnt understand very weel your comment above and so, I formatted the SD card, installed again the raspbian and re installed the pyserial and now is ok, but new problem is happen with pynput module and I put this problem in another question Commented Dec 1, 2019 at 10:02

1 Answer 1

0

Linux and Python are case sensitive.

Try ser = serial.Serial(

answered Nov 27, 2019 at 12:34
3
  • Could you edit your question and cut&paste the full traceback? Commented Nov 27, 2019 at 14:55
  • 1
    @WagnerIdeali You should edit your question to add information, not add a comment. Commented Nov 27, 2019 at 17:38
  • 1
    @WagnerIdeali There is a link below your question named edit. Please click on it and add additional information to the question. Commented Nov 27, 2019 at 20:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.