Re: [Ftdi-usb-sio-devel] [SOLVED] Baudrate setting is broken.
Brought to you by:
bryder
From: Bill R. <bil...@gm...> - 2014-09-30 05:02:56
|
Hi there, The c_cflag settings don't set the baud rate. They set other communications modes like stop bits, parity etc. So you can't set the baudrate in c_cflag. You've solved the problem yourself by calling the speed setting functions. You should remove the baudr from your c_cflag setting also because you might be settings things you don't want to accidentally. Here's the posix documentation http://pubs.opengroup.org/onlinepubs/7908799/xsh/termios.h.html and the linux documentation http://man7.org/linux/man-pages/man3/termios.3.html Enjoy serial programming! Bill On Tue, Sep 30, 2014 at 4:58 AM, Teunis van Beelen <te...@gm...> wrote: > Dear maintainers, > > It looks like I solved the problem. > > I was using this code to set the params for the serial port: > > new_port_settings.c_cflag = baudr | cbits | cpar | bstop | CLOCAL | CREAD; > new_port_settings.c_iflag = IGNPAR; > new_port_settings.c_oflag = 0; > new_port_settings.c_lflag = 0; > new_port_settings.c_cc[VMIN] = 0; /* block untill n bytes are received */ > new_port_settings.c_cc[VTIME] = 0; /* block untill a timer > expires (n * 100 mSec.) */ > cfsetispeed(&new_port_settings, baudr); > cfsetospeed(&new_port_settings, baudr); > error = tcsetattr(Cport[comport_number], TCSANOW, &new_port_settings); > > After adding the next two lines to my sourcecode, it works fine: > > cfsetispeed(&new_port_settings, baudr); > cfsetospeed(&new_port_settings, baudr); > > So, this means that setting the baudrate with: > > new_port_settings.c_cflag = baudr | cbits | cpar | bstop | CLOCAL | CREAD; > > is not sufficient?? > > (baudr is an int that contains the value B9600 or B19200, etc.) > > Sorry for bothering, > > Best Regards, > > Teunis van Beelen > > > -- > "C'è qualcosa nella nebbia! Qualcosa nella nebbia ha preso John Lee!" > > ------------------------------------------------------------------------------ > Slashdot TV. Videos for Nerds. Stuff that Matters. > http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk > _______________________________________________ > Ftdi-usb-sio-devel mailing list > Ftd...@li... > https://lists.sourceforge.net/lists/listinfo/ftdi-usb-sio-devel |