Reputation: 467
By default what is the baud rate during serial communication. That is if a write a program where I do not mention any baud rate, then what baud rate will be taken into account?
Upvotes: 2
Views: 570
Reputation: 70911
If on a POSIX system:
open()
.tcgetattr()
to initialise a struct termios
.struct termios
from 2. to cfgetispeed()
/cfgetospeed()
to get the port's current inbound/outbound baud rate.Example:
#include <termios.h>
#include <unistd.h>
[...]
struct termios t = {0};
speed_t baudrate_in = 0;
speed_t baudrate_out = 0;
int fd = open("/dev/ttyS0", O_RDWR);
if (-1 == fd)
{
perror("open() failed");
exit(1);
}
if (-1 == tcgetattr(fd, &t))
{
perror("tcgetattr() failed");
exit(1);
}
baudrate_in = cfgetispeed(&t);
baudrate_out = cfgetospeed(&t);
Upvotes: 3
Reputation: 21
You can use setserial to find out http://linux.die.net/man/8/setserial
Upvotes: 1