[slang-users] Anyone got a serial i/o module?
John E. Davis
davis at space.mit.edu
Thu Jun 8 00:11:59 EDT 2006
jmrobert5 at mchsi.com <jmrobert5 at mchsi.com> wrote:
>Does anyone have a general serial I/O module for Slang?
How general do you want it and for what OS? In the past, I have
manipulated a modem attached to a serial port using the termios and
select modules. For a while I was using the modem's caller ID ability
to map incoming numbers to musical tunes allowing me to identify the
caller by the tune that was played.
>I have a project where we (at first) want to write text out a serial port in a
>certain pattern. I figure what better way than a slang script?
The termios module (for Unix/POSIX) should work for setting up the
serial port. I noticed that it was lacking functions for manipulating
the baud-rate so I added those tonight and checked the changes into
the svn repository.
The basic idea is that you would open the serial port using, e.g.,
fd = open ("/dev/ttyS0", O_RDWR|O_NONBLOCK);
and then use the termios module to set it up. For the modem, I used:
tty = tcgetattr (fd);
termios_set_cflag (tty, CRTSCTS|CLOCAL|CREAD | termios_get_cflag (tty));
termios_set_lflag (tty, 0);
termios_set_oflag (tty, 0);
termios_set_iflag (tty, IGNBRK|ICRNL);
() = tcsetattr (fd, TCSANOW, tty);
Once you have it set up, use the read/write functions to interact with
it.
I can send you my caller-id script if you want more information.
Thanks,
--John
More information about the slang-users-l
mailing list