[fpc-pascal] Access to RS232 ports with fpc
Marc Santhoff
M.Santhoff at web.de
Tue Nov 3 15:10:58 CET 2009
Am Dienstag, den 03.11.2009, 09:39 +0100 schrieb Tomas Hajny:
> On Tue, November 3, 2009 02:33, Holger Bruns wrote:
> > Brad Campbell schrieb:
> >>
> >> Why not try attaching your test code that is failing so we can help
> >> you get it working?
> >
> > Done. My fault was the following declaration:
> >
> > var inbuffer: array of char;
> >
> > This is a better declaration:
> >
> > var inbuffer: array[0..10] of char;
> >
> > Now I got my code working. Hidden pointers are new to me. Therefore I
> > felt in trouble with it. Secondly, it appears to be necessary to use the
> > fpc compiler as "root", not simply as a user, I guess.
>
> The compiler may be certainly run under other users (well, at least if
> installed properly), but access to ports requires root privileges as far
> as I know.
No it doesn't if the access rights are set properly.
1. make all users of the program members of a special group (e.g.
dialers)
2. as root change the ownership of the tty device node to that group
At my desk:
$ cat /etc/group|grep dialer
dialer:*:68:marc
$ ls -l /dev/cua*
crw-rw---- 1 uucp dialer 0, 71 3 Nov 14:36 /dev/cuad0
crw-rw---- 1 uucp dialer 0, 72 3 Nov 14:36 /dev/cuad0.init
crw-rw---- 1 uucp dialer 0, 73 3 Nov 14:36 /dev/cuad0.lock
crw-rw---- 1 uucp dialer 0, 77 3 Nov 14:36 /dev/cuad1
crw-rw---- 1 uucp dialer 0, 78 3 Nov 14:36 /dev/cuad1.init
crw-rw---- 1 uucp dialer 0, 79 3 Nov 14:36 /dev/cuad1.lock
As you can see I'm allowed to attach my dmm and open the serial port for
reading it's measurements without being root or using sudo.
I don't know wheter todays Lunix systems have static device nodes seen
here for ttys or if they are created dynamically and the rights have to
be set in some configuration file - consult your systems docs or a good
tutorial or book an those questions.
Try at the console:
$ man chown
$ man group
$ man ttys
at least on FreeBSD this manual pages exist and are very informative.
Have fun,
Marc
--
Marc Santhoff <M.Santhoff at web.de>
More information about the fpc-pascal
mailing list