On Dec 6, 2004, at 11:12 PM, Ranga Nathan wrote:

I need to write to /dev/cpcmd and read back from it.

Can someone start me up in the right direction?

You probably want to open the file as "+</dev/cpcmd", so you can both read to and write from the filehandle.


You probably want to set command buffering on the filehandle, (my $oldfh=select(CPCMD); $|++;select $oldfh) or else you may be waiting for replies that are still hanging around your stdio buffers.

Once that is set, send commands with print() and read with <> or read().

For a device with a simple interface, that might be all that you need.

If the device has some added complexity, it might require you to syswrite rather the print and sysread rather than read. You might need to send out of bad controls with ioctl (the format of the ioctl command would have to be documented somewhere.) or some other minor change.

_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to