Serial Port configuration with asio C++ library I've made a small interface using the asio C++ library to open serial ports and do I/O from/to them. 
It works with my Arduino Uno and other hardware as well (industrial weighing machines), but I only specify the port and baud rate. 

The following code is run in the client application, which runs both on my Windows 10 Student Edition x86_64 machine, and on old 32 bit  Win XP machines that communicate with the weighing machines:

/*this is inside a constructor*/ 
/*iosvc gets passed by reference, port_ is a member variable of type asio::serial_port,
 npuerto is the name of the port (e.g. "COM3") */

port_(iosvc_, npuerto),

/*...*/

port_.set_option(asio::serial_port_base::baud_rate(baudios));


The Arduino is programmed to do a serial echo of whatever is sent to it, for testing purposes. This is the echo code: 

void setup() {
  Serial.begin(9600);
}

void loop() 
{
  while(Serial.available())
  {
    Serial.write(Serial.read());
  }
}


It works fine with my Arduino until I unplug it and plug it back in. After replugging it all the values returned are garbage, specifically some sort of '?' character inside a black box, don't know the bit value though, but it's constant. The problem gets fixed when I open an arduino IDE Serial Port monitor.
If I close it, and once again use my own software to open up the serial port, all the values are fine.

From this I concluded that the Arduino IDE Serial Port monitor is doing something when it opens up the port that I'm not doing.

Any clues? Flow control? Handshake?
Thanks
Can you include all the other calls you make related to setting up the serial port along with asio::serial_port_base::baud_rate(baudios)? Ideally, split that out into a separate function (that takes parameters such as baud rate) that you know is the only thing doing this setup.

As I mentioned in the comment, getting back the right number of chararacters but incorrect characters looks as if the baud rate is correct but something else is wrong. The first thing that comes to mind is the bits/parity/stop bits settings. Typically you want to be using 8 bits, no parity, often referred to as "8N1".