I am trying to port a program to linux from windows.
The problem is i cannot set the baud rate successfully (code for this can be seen below)
I have set up an oscilloscope on the cable connected to the serial port. with the windows version i can see a pattern at 25micro seconds but with the linux version i can see the same pattern at 250micro seconds telling me that the information is correct but it is sending it to slow.
I have tried setting the baud rate to several different values but i still get the same thing on the oscilloscope.
What i am looking for is a program that will set up the serial port at 115200 baud, mark parity, 1 stopbit and 8 databits and send something across the line so i can see it on hyperterminal. A program in c++ would be fantastic because then i could compare it to mine if it works.
I think there is something keeping the baud rate set at a certain value somehow and if i got a program from someone else that is confirmed to work i could say it is out setup of linux. I have tried on different computers but they are all configured the same way by our sysadmin
I have been trying this for 3 weeks and have done literally hundreds of serial port tutorials and being a linux noob i am lost at what to do now.
idComDev[i] = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);
if (idComDev[i] == -1)
{
perror("open_port: Unable to open /dev/ttyS0 - ");
ret = false;
}
else
{
fcntl(idComDev[i], F_SETFL, 0);
struct termios options;
tcgetattr(idComDev[i], &options); // get current settings
cfsetspeed(&options, B9600); // set baud rate
test = tcsetattr(idComDev[i], TCSANOW, &options);// save the settings
options.c_cflag &= ~CSIZE; // Mask the character size bits
options.c_cflag |= CS8; // 8 bit data
options.c_cflag &= ~PARENB; // set parity to no
options.c_cflag &= ~PARODD; // set parity to no
options.c_cflag |= CSTOPB; //set one stop bit
options.c_cflag |= (CLOCAL | CREAD);
options.c_oflag &= ~OPOST;
options.c_lflag &= 0;
options.c_iflag &= 0; //disable software flow controll
options.c_oflag &= 0;
tcsetattr(idComDev[i], TCSANOW, &options);// save the settings
printw("Seg %d = COM%hd",i,CommNo[i]);
if(test!= -1)
printw("test success");