G
goblin
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(fileno(pPort), &settings) != 0) printf("Oops1\n");
cfsetispeed(&settings, B9600);
cfsetospeed(&settings, B9600);
settings.c_iflag |= CSTOPB;
if (tcsetattr(fileno(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(fileno(pPort), &settings) != 0) printf("Oops1\n");
cfsetispeed(&settings, B9600);
cfsetospeed(&settings, B9600);
settings.c_iflag |= CSTOPB;
if (tcsetattr(fileno(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