views:

68

answers:

3

Hi.

I'm trying to talk to a home made card over a serial port, and is therefor using pySerial. In Hyperterminal, everything works fine. I can write:

$ audio on

and the audio is enabled, but if I use

ser = serial.Serial("COM1", 38400)
ser.write("audio on\r\n")

nothing happens. I can read incoming data however, so it's not something wrong with the communication. I doesn't help if I change \r\n to just \n or \r either.

EDIT: Sometime I actually get the feedback: No such command when sending the exact same command as works from HyperTerminal. The setup is also the exact same as in HyperTerminal.

Solved: To make it work, I had to send one and one character, and ending the transmission with \r.

A: 

Try specifying the other parameters of the connection (except BAUD rate) like bit parity (and I remember there were others).

I had the same problem with pyserial, but that was two years ago (i.e. I don't remember how I fixed it :( ).

utnapistim
In my code I have specified the port, BAUD rate, parity and timeout. I only wrote a short example. I do see however that I get some responce sometimes, but not always. It's quite weird. I have also tried flushing the output before sending the message, but even then I get completely different output. Somethimes I actually get the message 'No such command' from the device, even though the command I send works from HyperTerminal.
martiert
A: 

Get an oscilloscope (you've got one, right?) and watch the serial line. Send one character per second through it and see what comes up on the scope (set it to trigger on the start bit). Serial port bits are in the order: start, LSB .. MSB, parity, stop.

See if there are characters that don't get through, or if there's a pattern. Another possibility is that everything is actually making it out the port, and your board is dropping characters.

Mike DeSimone
A: 
  1. Triple check that the baud rate of the device is indeed 38400
  2. Triple check parity, stop bits, etc
  3. Be aware of signal degradation for serial transmissions over long distances (probably not your issue)

If all the above checkout try putting the string into a byte array and sending that through the write command. Just a guess.

nathan