pySerial help please!

bmaschino at gmail.com bmaschino at gmail.com
Tue Feb 10 19:02:40 EST 2009


On Feb 10, 5:41 pm, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> bmasch... at gmail.com schrieb:
>
>
>
>
>
> > Hello all,
>
> > I am very new to Python and I am using it because I needed an easy
> > language to control a piece of equipment that connects to my computer
> > via a serial cable. I am running Python 2.6 with pySerial 2.4 under
> > Windows. I can get Python to create a serial port on COM1, but when I
> > try to write to the device, nothing happens. Here is an example:
>
> > import serial
> > ser = serial.Serial(0)
> > ser.write("otpm 2 16 0")
> > ser.close()
>
> > If I connect to the device in Hyperterminal the device will behave as
> > expected when I give it the command 'otpm 2 16 0' but not in Python. I
> > have confirmed Python is actually controlling the port because
> > Hyperterminal will not open the port while Python has it open,
> > although I have not been able to try a loopback connector as of yet.
> > Any suggestions out there? Thanks in advance!
>
> You need to give a newline, you press return on the terminal as well,
> don't you?
>
> Diez- Hide quoted text -
>
> - Show quoted text -

Yes! That was exactly the problem. I replaced ser.write("otpm x x x")
to ("otpm x x x\n") and it WORKS!! Thank you!



More information about the Python-list mailing list