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)
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.
    – tlfong01
    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..
    – tlfong01
    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.
    – tlfong01
    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(

3
  • Could you edit your question and cut&paste the full traceback?
    – joan
    Commented Nov 27, 2019 at 14:55
  • 1
    @WagnerIdeali You should edit your question to add information, not add a comment.
    – joan
    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.
    – Ingo
    Commented Nov 27, 2019 at 20:35

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.