Hi all
I'm struggeling to get my serial port settings changed using termios.
I can change the baud rate fine, but none of the control flags respond
to my changes. As an example:
#include <stdio.h>
#Iinclude <termios.h>
int main (void) {
struct termios settings;
FILE* pPort;
if (!(pPort = fopen("/dev/ttyUSB0","r+")) ) {
printf("Oops0\n ");
return 1;
}
if (tcgetattr(file no(pPort), &settings) != 0) printf("Oops1\n ");
cfsetispeed(&se ttings, B9600);
cfsetospeed(&se ttings, B9600);
settings.c_ifla g |= CSTOPB;
if (tcsetattr(file no(pPort), TCSANOW, &settings) != 0)
printf("Oops2\n ");
fclose(pPort);
}
This will change the current baud rate to the selected 9600, but the
will not set two stop bits as I think it should. What am I doing wrong
here?
Any help would be sincerely appreciated.
Piet
I'm struggeling to get my serial port settings changed using termios.
I can change the baud rate fine, but none of the control flags respond
to my changes. As an example:
#include <stdio.h>
#Iinclude <termios.h>
int main (void) {
struct termios settings;
FILE* pPort;
if (!(pPort = fopen("/dev/ttyUSB0","r+")) ) {
printf("Oops0\n ");
return 1;
}
if (tcgetattr(file no(pPort), &settings) != 0) printf("Oops1\n ");
cfsetispeed(&se ttings, B9600);
cfsetospeed(&se ttings, B9600);
settings.c_ifla g |= CSTOPB;
if (tcsetattr(file no(pPort), TCSANOW, &settings) != 0)
printf("Oops2\n ");
fclose(pPort);
}
This will change the current baud rate to the selected 9600, but the
will not set two stop bits as I think it should. What am I doing wrong
here?
Any help would be sincerely appreciated.
Piet
Comment