Menu

#10 BAUD_INVALID == BAUD_115200

closed-fixed
nobody
None
5
2011-06-28
2011-06-15
Jack Kelly
No

Hi there,

Great work with this project - it's exactly what I was looking for!

I could be wrong but I believe I've found a small bug. SerialStreamBuf.h currently contains the following enum:

enum BaudRateEnum {
BAUD_50 = SerialPort::BAUD_50,
...
BAUD_115200 = SerialPort::BAUD_115200,
BAUD_230400 = SerialPort::BAUD_230400,
BAUD_DEFAULT = SerialPort::BAUD_DEFAULT,
BAUD_INVALID
} ;

The problem is that this enum sets BAUD_INVALID to 4098 (because BAUD_DEFAULT==4097). But BAUD_115200 also equals 4098! So, in other words, BAUD_INVALID==BAUD_115200. So if you try setting the baud rate to 115200, the code wrongly decides to set the bad bit after line 78 of SerialStream.cc:

if( SerialStreamBuf::BAUD_INVALID ==
my_buffer->SetBaudRate(baudRate) )
{
setstate(badbit) ;
}

My simple (but probably ugly fix) is to change line 85 of SerialStreamBuf.h from "BAUD_INVALID" to "BAUD_INVALID = 999".

Discussion

  • Jack Kelly

    Jack Kelly - 2011-06-15

    By the way, the line numbers I quoted are for version 0.6.0rc1, not for HEAD from SVN, sorry.

     
  • Jack Kelly

    Jack Kelly - 2011-06-15

    Also, I guess I should really have posted this in "patches", sorry.

     
  • Crayzee Wulf

    Crayzee Wulf - 2011-06-28

    Haha, good catch. Thanks, jack-kelly. I will fix this and make sure that BAUD_INVALID is indeed set to an "invalid" value.

     
  • Crayzee Wulf

    Crayzee Wulf - 2011-06-28
    • status: open --> closed-fixed
     
  • Crayzee Wulf

    Crayzee Wulf - 2011-06-28

    This has been fixed in SVN trunk.

     

Log in to post a comment.

MongoDB Logo MongoDB