Pyserial,Docs, tutorials, line terminators
yaipa h.
yaipa at yahoo.com
Wed Mar 19 12:24:56 EST 2003
Vector,
Knowing what you are doing would help, but here is something I did,
search 'yaipa Eurotherm' and limit it to c.l.p
Note that it was developed on a Unix box and is in *alpha* condition,
but all the basics are there. Also, note that this code is to replace
an existing BASIC program, so the string sent/recv'd to/from the serial
port had to be formatted accordingly.
-Alan
vector <Vector180W at netscape.net> wrote in message news:<3E77FF33.9080807 at netscape.net>...
> thanks Chris i have managed to get it kinda working. I was after a more
> broad spread doc or tut on how the whole pyserial thing works. I have
> many ifs n maybes about it. for eg if I have an error in my script and
> its after the open serial port. when i next run it the port cant be
> opened. id prefer to if open close it then reopen so i know the exact
> state of the port. I think its not helping running from pythonwin IDE.
> id also like to interegate the port error messages(as displayed on the
> interactive window), trap it and deal with it rather than just bomb out.
>
> Chris Liechti wrote:
> > vector <Vector180W at netscape.net> wrote in
> > news:3E76867F.3080002 at netscape.net:
> >
> >>Im using the windows environment. and as such once the serial port is
> >>open the readline() is missing the /r (terminating on /n) causign all
> >>sorts of greif.
> >
> >
> > its not missing it, it behaves similar to readline on files with returns a
> > '\n' terminated line, it just does not do any EOL conversion.
> >
> > do you know 'somestr'.replace('\r', '') or better 's'.strip() or rstrip()?
> > these help usualy as they easily remove the unwanted character.
> >
> > an other problem is, what behaviour should readline have? there are all
> > sorts of problems like what to do with timeouts, what if the port was
> > opened nonblocking, EOL characters etc... a good practice is to write your
> > own function that does what you exepct ;-)
> >
> > chris
> >
More information about the Python-list
mailing list