views:

61

answers:

1

[edit] Initially I thought this was a pyserial problem but it's not. Basically it's a system problem: Sending anything over the serial port (/dev/ttyS0) would need a "\n" or "\r" or else it'll just be buffered. Below is the original question. Is it a limitation of Linux driver or is there some settings I can change?

Hello there,

I'm trying to use pyserial to write some test code. In reality I'll be transmitting binary data but that's not my problem. My problem is that: it looks like pyserial write() command will only actually send the data when it sees "\n".

Take the following code for sending pure text file.

for l in file:
    print "Sending %s" % l
    s.write( l )
    s.flush()
    time.sleep(2)

Unless I insert s.write("\n") after s.write( l ), nothing would be seen on the other side. Is there a way I can make pyserial to send whatever I want whenever I want it?

Thanks,

+1  A: 

from the documentation for pyserial http://pyserial.sourceforge.net/pyserial_api.html that does not seem to be the case. which version are you using?

to clarify, which pySerial and which python seem to be relevant.

KevinDTimm
I'm using ubuntu 10.04 which says it has 2.3 installed but the actually VERSION string in the module is 1.3.2 (or something). So I upgraded to the latest 2.5 from source.
lang2
From the 'write' method - Changed in version 2.5: Accepts instances of bytes and bytearray when available (Python 2.6 and newer) and str otherwise.
KevinDTimm
I'm using python 2.6.5
lang2