Basically I\'m using the following code to set the baud rate of a serial port:
struct termios options;
tcgetattr(fd, &options);
cfsetispeed(&options,
I accomplished this using termios2 and ioctl() commands.
struct termios2 options;
ioctl(fd, TCGETS2, &options);
options.c_cflag &= ~CBAUD; //Remove current BAUD rate
options.c_cflag |= BOTHER; //Allow custom BAUD rate using int input
options.c_ispeed = 307200; //Set the input BAUD rate
options.c_ospeed = 307200; //Set the output BAUD rate
ioctl(fd, TCSETS2, &options);
After that, you should be able to query the port settings and see your custom BAUD rate, as well as the other settings (possible with stty commands).