[ale] Serial Port

Glenn Stone taliesin at mailandnews.com
Wed Jul 7 08:28:09 EDT 1999


On 6 Jul 1999, Themack wrote:

>Thank you that worked, but can any of you help me out again. I need a little a
>C program that will send a hex value to the serial port. If someone could
>please write that for me I would greatly appreciate it. 
>Thanks again in advance.

Look at the man page for putc(3).  You'll also need fopen(3) and close(3);
they all require <stdio.h>.  You'll need fcntl(3), <unistd.h> and <fcntl.h>
to tinker with the port settings.  

You can do this with the shell, however; 

#!/bin/bash
echo -e -n "\376" >/dev/ttyS0

Now, the value "376" is in *octal*, not hex, but the final effect
is the same.  Did it just yesterday.

-- Glenn
The really cool and mind-boggling thing about Unix is that there
are usually about six million ways to do the same thing, all different.






More information about the Ale mailing list