Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <termios.h>
- #include <fcntl.h>
- #include <cstdlib>
- #include <fstream>
- #include <iostream>
- #include <cstring>
- #include <unistd.h>
- int main(int argc, char ** argv)
- {
- struct termios tio;
- memset(&tio, 0, sizeof(tio));
- tio.c_cflag = CS8 | CREAD | CLOCAL;
- tio.c_cc[VMIN] = 1;
- tio.c_cc[VTIME] = 5;
- int fd = open("/dev/ttyACM0", O_RDONLY);
- cfsetospeed(&tio, B9600);
- cfsetispeed(&tio, B9600);
- tcsetattr(fd, TCSANOW, &tio);
- while (1) {
- unsigned char byte;
- read(fd, &byte, 1);
- std::cout << byte;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement