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.

Revisions

  1. begriffs revised this gist Mar 14, 2023. 1 changed file with 17 additions and 22 deletions.
    39 changes: 17 additions & 22 deletions testserial.c
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,4 @@
    #include <sys/ioctl.h>
    #include <stdio.h>
    #include <sys/types.h>
    #include <termios.h>
    #include <sys/ioctl.h>
    #include <fcntl.h>
    #include <stdlib.h>
    @@ -11,32 +8,30 @@

    int main(int argc, char *argv[])
    {
    int fd;
    int fd;
    int RTS_flag;
    int error = 0;

    fd = open(argv[1],O_RDWR | O_NOCTTY );
    if (fd == -1 ) {
    error = errno;
    if (fd == -1 ) {
    error = errno;
    printf("Error opening device - %s : %s\n", argv[1], strerror(error));
    exit(error);
    }
    RTS_flag = TIOCM_RTS;
    ioctl(fd,TIOCMBIS,&RTS_flag);
    if (fd == -1 ) {
    error = errno;
    printf("Error TIOCMBIS RTS device - %s : %s\n", argv[1], strerror(error));
    exit(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();
    ioctl(fd,TIOCMBIC,&RTS_flag);
    if (fd == -1 ) {
    error = errno;
    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);
    exit(error);
    }
    close(fd);

    return 0;
    }
  2. begriffs created this gist Mar 14, 2023.
    42 changes: 42 additions & 0 deletions testserial.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    #include <sys/ioctl.h>
    #include <stdio.h>
    #include <sys/types.h>
    #include <termios.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;
    ioctl(fd,TIOCMBIS,&RTS_flag);
    if (fd == -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();
    ioctl(fd,TIOCMBIC,&RTS_flag);
    if (fd == -1 ) {
    error = errno;
    printf("Error TIOCMBIC RTS device - %s : %s\n", argv[1], strerror(error));
    exit(error);
    }
    close(fd);

    return 0;
    }