Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _XOPEN_SOURCE
- #include <stdlib.h>
- #include <fcntl.h>
- #include <stdio.h>
- #include <string.h> /* String function definitions */
- #include <unistd.h> /* UNIX standard function definitions */
- #include <errno.h> /* Error number definitions */
- #include <termios.h> /* POSIX terminal control definitions */
- int main()
- {
- int fd, n = 0, error = 0;
- int chk1 = -1, chk2 = -1;
- char *dato;
- char *PTS;
- fd = open("/dev/ptmx", O_RDWR);
- if (fd == -1)
- {
- printf ("Error opening the serial device");
- exit(0);
- }
- PTS = ptsname(fd);
- printf("The slave port name is: %s", PTS);
- chk1 = grantpt(fd);
- chk2 = grantpt(fd);
- if (chk1 == -1 | chk2 == -1)
- printf("\nPort access denied");
- getchar();
- error = read(fd,dato,4);
- if (error = 0)
- printf("\nNothing in buffer");
- else
- printf("%s",dato);
- close(fd);
- }
Advertisement
Add Comment
Please, Sign In to add comment