Created
November 16, 2016 21:19
-
-
Save dfirfpi/496406d111490ced54f9afc09eeeb839 to your computer and use it in GitHub Desktop.
Baud Rate Detector
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 <termios.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
// Author: clacke | |
// Ref: http://unix.stackexchange.com/questions/72979/how-does-cat-know-the-baud-rate-of-the-serial-port | |
// do a lookup for the value returned in termbits.h | |
int main() { | |
struct termios tios; | |
tcgetattr(0, &tios); | |
speed_t ispeed = cfgetispeed(&tios); | |
speed_t ospeed = cfgetospeed(&tios); | |
printf("baud rate in: 0%x\n", ispeed); | |
printf("baud rate out: 0%x\n", ospeed); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment