fcntl, serial ports and serial signals on RS232.
mawrman at gmail.com
Fri Apr 9 14:32:19 EDT 2010
On Apr 8, 11:17 am, Grant Edwards <inva... at invalid.invalid> wrote:
> On 2010-04-07, Max Kotasek <mawr... at gmail.com> wrote:
> > I'm trying to figure out how to parse the responses fromfcntl.ioctl()
> > calls that modify the serial lines in a way that asserts that the line
> > is now changed.
> Two comments:
> 1) None of the Linux serial drivers I've worked on return line states
> except when you call TIOCMGET.
> 2) If the TIOCMBI[S|C] call returned a 'success' value, then the
> line was set to what you requested.
> If you want to read back the state that you just wrote, you can call
> TIOCMGET, but for the "output" pins it's always going to return the
> last value that was written.
> > For example I may want to drop RTS explicitly, and
> > assert that the line has been dropped before returning.
> Call TIOCMSET. If it doesn't return an error, then you're done.
> > Here is a brief snippet of code that I've been using to do that, but
> > not sure what to do with the returned response:
> What returned response?
> The only thing that is returned by TIOCMBIS/TIOCMBIC is a status value
> of 0 for success and <0 for failure. IIRC, that value is checked by
> Python'sfcntl.ioctl wrapper and it will raise an exception on
> > Is someone familiar with manipulating serial signals like this in
> > python?
> > Am I even taking the right approach by using thefcntl.ioctl call?
> Yes. When you set/clear RTS or DTR do they not go up/down?
> Even if you can't use pyserial, it's a good source for example code.
> Grant Edwards grant.b.edwards Yow! TONY RANDALL! Is YOUR
> at life a PATIO of FUN??
I appreciate the feedback. I'm working in an environment with a lot
of changing factors, it's nice to have a piece not act unexpectedly.
More information about the Python-list