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.