slang-users mailing list

[2006 Date Index] [2006 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [slang-users] Anyone got a serial i/o module?


jmrobert5@xxxxxxxxx <jmrobert5@xxxxxxxxx> 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

_______________________________________________
To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html


[2006 date index] [2006 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]