Created
June 16, 2010 09:59
-
-
Save johnhowe/440412 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/types.h> | |
#include <sys/ioctl.h> | |
#include <fcntl.h> | |
#include <errno.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <signal.h> | |
#include <termios.h> | |
/* Main program. */ | |
int main(int argc, char **argv) | |
{ | |
int fd; | |
int status; | |
int set_bits = 0; | |
/* Open monitor device. */ | |
if ((fd = open(argv[1], O_RDWR | O_NDELAY)) < 0) { | |
fprintf(stderr, "ar-2: %s: %s\n", | |
argv[1], sys_errlist[errno]); | |
exit(1); | |
} | |
int x = 0; | |
for ( x = 0; x < 10; x++ ) { | |
if (set_bits) { | |
set_bits = 0 ; | |
} else { | |
set_bits = 6 ; | |
} | |
ioctl(fd, TIOCMSET, &set_bits); | |
ioctl(fd, TIOCMGET, &status); | |
if (status & TIOCM_DTR) | |
puts("TIOCM_DTR is set"); | |
else | |
puts("TIOCM_DTR is not set"); | |
if (status & TIOCM_RTS) | |
puts("TIOCM_RTS is set"); | |
else | |
puts("TIOCM_RTS is not set"); | |
printf("%i",x), | |
puts(" ------------------------"); | |
sleep(60); | |
} | |
close(fd); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment