Skip to content

Instantly share code, notes, and snippets.

@begriffs
Last active March 14, 2023 02:58
Show Gist options
  • Save begriffs/1cde9a47538627d25a80d66b139cd8d9 to your computer and use it in GitHub Desktop.
Save begriffs/1cde9a47538627d25a80d66b139cd8d9 to your computer and use it in GitHub Desktop.
Code from WG0A to test RTS-based PTT at a low level
#include <stdio.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
int main(int argc, char *argv[])
{
int fd;
int RTS_flag;
int error = 0;
fd = open(argv[1],O_RDWR | O_NOCTTY );
if (fd == -1 ) {
error = errno;
printf("Error opening device - %s : %s\n", argv[1], strerror(error));
exit(error);
}
RTS_flag = TIOCM_RTS;
if ( ioctl(fd,TIOCMBIS,&RTS_flag) == -1 ) {
error = errno;
printf("Error TIOCMBIS RTS device - %s : %s\n", argv[1], strerror(error));
exit(error);
}
printf("Press any key to disable PTT...");
getchar();
if ( ioctl(fd,TIOCMBIC,&RTS_flag) == -1 ) {
error = errno;
printf("Error TIOCMBIC RTS device - %s : %s\n", argv[1], strerror(error));
exit(error);
}
close(fd);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment