Re: [nottingham] Serial port data acquisition in Perl

From: Matthew Sackman (matthew@sackman.co.uk)
Date: Mon 14 Jan 2002 - 21:02:02 GMT


On Mon, Jan 14, 2002 at 08:23:01PM +0000, Robert Davies wrote:
> On Monday 14 January 2002 19:57, you wrote:
> > On Mon, Jan 14, 2002 at 07:03:17PM +0000, Tom Bird wrote:
> > > On Mon, 14 Jan 2002, Graeme Fowler wrote:
>
> >> This is probably ugly, evil and just totally wrong, but when I needed to
> >> send data to the serial port to control the little LCD screen thing I
> >> acquired, I just used /dev/ttyS0 like a file and shoved the data into
> >> that.
> > I can't see why that's necessarily so wrong - all communication is
> > via 'files' in *nix so why should doing that be so wrong?
>
> I think that's beautiful and good orthogonal behavious.
>
> Not at all, it's using ioctl's that is ugly. The I/O absolutely has to go
> through a device, which is generally accessed via a filedescriptor, openened
> on some filename. Even the tty (and many programs open /dev/tty for terminal
> i/o) for standard output has to be opened by something, either getty or login
> though the detail's not important.
>
> There was quite alot of discussion on LMKL a while back about using Plan 9
> style filenames to set IOCTL's from user space on drivers. Soemthing like
> /dev/ttyS1/speed=19200 for example. Or should you echo speed=19200 >
> /proc/sys/ttyS1?

That seems to smack of Hurd's settrans and ext2 extensions to me... not
sure if they're based on Plan9 at all..

Just been playing round with things like

perl -e 'sysopen(FH, "/dev/ide/host0/bus0/target1/lun0/part8",
        O_RDONLY); while (<FH>) { print $_;}close FH;'

which fails without error message if you're not root. Playing with minicom
actually gave me permission denied messages, so then I switched to root
and the perl worked.

It may be that Graeme is not running the perl as root, or that he's not got
the permissions on the dev file to be able to do this and perl is not giving
error messages. Any truth in that?

Matthew

-- 

Matthew Sackman Nottingham England

BOFH Excuse Board: I'd love to help you -- it's just that the Boss won't let me near the computer. -------------------------------------------------------------------- http://www.lug.org.uk http://www.linuxportal.co.uk http://www.linuxjob.co.uk http://www.linuxshop.co.uk --------------------------------------------------------------------



This archive was generated by hypermail 2.1.3 : Mon 14 Jan 2002 - 21:02:18 GMT