5

I am trying to connect the Raspberry Pi to a microcontroller using the USB Port. I have used the device many times and I know how the protocol works. It should reply after receiving the message that I am sending.

I am using a USB cable connected to a null cable like this one.

I am running the following python program (I am running Python 3.2):

import serial port =serial.Serial( "/dev/ttyUSB0", baudrate=57600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, writeTimeout = 0, timeout = 10) data=bytes([0x0c,0x80,0x09,0x00,0xf0,0xce,0x61,0x9d,0x01,0x00,0x01,0x00,0x00,0x00]) print(port.isOpen()) print("Port opened...") port.write(data) print("Data sent") while True: print("inside while") response=port.read(8) print(response) print ("Data Received") break 

Raspberry Pi is not receiving anything, just timeout.

In order to test the program I ran it on my windows 7 computer running Python 3.2 changing the port to the right COM. I used the same cables. It is getting the right answer from the device and printing it.

I am sure the baudrates are right.

Any help would be appreciated.

2 Answers 2

4

I just got the solution.

I updated/upgraded wheezy first. Then opened the port like this:

port =serial.Serial( "/dev/ttyUSB0", baudrate=57600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, writeTimeout = 0, timeout = 10, rtscts=False, dsrdtr=False, xonxoff=False) 
2

I am no expert with PySerial, but shouldn't the string "-dev-ttyUSB0" be "/dev/ttyUSB0" ?

1
  • Yes I am using /dev/ttyUSB0. Editing question now. Commented Sep 20, 2013 at 20:34

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.