This is a quick snippet of code from a serial program I've been working with to interface with a microcontroller. The code has been verified to work but I want to add the global define to make the code more modular. The excerpt shown works, until I replace the 'B1000000' in the 'cfsetispeed' with the global 'BAUDRATE'.
// Globals
struct termios tty;
char BAUDRATE = B1000000; // 1,000,000
// All of the other details omitted ( int main (), etc. )
cfsetospeed (&tty, BAUDRATE);
cfsetispeed (&tty, B1000000);
So two questions come to mind:
1) I read that Termios only allows for select baudrates, the max listed is 230,400. How is it that 1,000,000 is allowed?
2) Why would cfsetispeed( ) not allow a global char definition as an argument?
EDIT: The previous link provided died and I managed to find the equivalent in the newer version so here is the excerpt in case it dies again:
#define CBAUDEX 0010000
#define BOTHER 0010000
#define B57600 0010001
#define B115200 0010002
#define B230400 0010003
#define B460800 0010004
#define B500000 0010005
#define B576000 0010006
#define B921600 0010007
#define B1000000 0010010
#define B1152000 0010011
#define B1500000 0010012
#define B2000000 0010013
#define B2500000 0010014
#define B3000000 0010015
#define B3500000 0010016
#define B4000000 0010017