[SunHELP] URGENT: TTL pulse on serial or parallel port
Wolfgang Engelien
sunhelp at sunhelp.org
Fri Apr 20 15:57:35 CDT 2001
>A simple example of how to toggle RTS:
>
>#include <fcntl.h>
>#include <sys/termios.h>
>
>#define OUTPUT_PORT "/dev/cua/a"
>
>main()
>{
> int fd, x;
> fd = open(OUTPUT_PORT, O_RDWR);
>
> x = TIOCM_RTS; /* enable RTS */
> ioctl(fd, TIOCMSET, &x);
> x = 0x0000; /* disable RTS */
> ioctl(fd, TIOCMSET, &x);
>
> close(fd);
>}
>
>You can use TIOCM_DTR to toggle DTR, but there appears to be an enforced
>delay in the serial driver associated with this.
>
>Naturally if you need more complex IO you would be better suited using
>actual serial or parallel port data lines, but flipping RTS will give you
>one bit of output with a minimum of effort.
>
>-James
THANKS, James,
Somehow it works. Pin 4 changes from +5.4V to -5.4V,
depending on dis- or enabling RTS.
The only other thing I had to do is turning off all
services on the serial port and make it world writable.
Thanks again,
Wolfgang
More information about the SunHELP
mailing list