[LCP] In-field program task

David Nugent davidn at datalinktech.com.au
Tue Jun 24 13:21:35 EST 2008


Howdy!

On 06/06/2008, at 8:58 PM, Kevin Shackleton wrote:

> I bought a VIOM
> (http://www.oceancontrols.com.au/controllers/phaed/viom.htm)
> device to look at working an automatic livestock drafting race.  The
> VIOM is a PIC-controlled I/O board that does things like programmable
> delays on outputs.  I need to trigger outputs on certain incoming  
> serial
> data.  Unfortunately it does not do the output delays when the  
> output is
> set to be controlled by the serial port - buyer beware, I feel a bit
> dumb for not having closely read the manual before parting with  
> cash :-(

Is there any reason for using the device in serial mode, assuming it  
supports bit mode also?

I have used a chipset with a similar idea (specifically the FTDI  
2232C), but it offers what is called "bitbang" mode that allows you to  
read/set individual bits on the controller in/outputs. This avoids the  
serial port emulation (the ports are indeed exposed, but unused). It  
sounds similar to your device, although I'm not aware of any internal  
timer function with the FTDI device.

Anyway, assuming you need to use the "serial" channel instead of  
reading the device directly...

> - I need to figure out what ioctl is all about so I can set up to  
> parse
> character by character input, rather than expecting a newline to flush
> the buffer.
~
>
> - At the moment I'm using standard input and output, but I'll need to
> do this task on ttyUSB0 and ttyUSB1.  Which means using termios.h

Yep.

> Both these libraries are a total black box to me.  "man ioctl" doesn't
> do anything.  How to I figure out what to do next?

ioctl() is a generic syscall for all types of devices, so yes the man  
page will be somewhat unhelpful other than to explain that. Ioctl is  
just an entry point, what you pass may be different. - the specifics  
as to how and when it will be used with specific devices can usually  
be found in the man pages for the device(s) concerned, and sometimes  
there are man pages that detail ioctls for groups of related devices.  
I'm surprised that "man termios" did not turn up anything useful  
though, assuming you tried it.

Google should turn up plenty of example cod. Unbuffered character mode  
is usually referred to as "cbreak" or "raw" mode, but even with raw  
mode there are various options that affect the behaviour of the device  
(whether some control chars are handled by the system or passed  
through etc), although most of these are used to control "cooked" mode  
than raw.


> Maybe <flame protection> c is not the best environment to do this work
> in? </flame protection>

You could try perl if you are familiar with it. There are perl modules  
for handling terminal and serial I/O specifically.

Hope this helps,
David




More information about the linuxCprogramming mailing list