wjwwood / serial

Cross-platform, Serial Port library written in C++
http://wjwwood.github.com/serial/
MIT License
2.11k stars 1.02k forks source link

FTDI usb serial open failed #302

Open mnswwz opened 3 months ago

mnswwz commented 3 months ago

I used the serial library of version 1.0.1 to open the FTDI USB Serial Device, but it failed. The error prompt shows garbled code. I use the library like this:


try{
    serial::Serial* m_Serial = new serial::Serial(port, baudrate, serial::Timeout::simpleTimeout(1), serial::eightbits, serial::parity_none, serial::stopbits_one);
    if(m_Serial->isOpen())
    {
          std::cout << "serial open success" << std::endl;
    }
    else
    {
         std::cout << "serial open failed" << std::endl;
    }
}
catch(std::exception& e)
{
    std::cout << "serial open failed of exception: " << e.what();
}
``I gived the parameters like this:
port : /dev/ttyUSB1
baudrate: 2500000
When I debug the code, the prompt showed in the terminal like this: 
"serial open failed of exception: oo/o"
When I used the serial port debugging assistant to connect the serial with the same parameters, it succeed. During the above test, I was clear the assistant was closed.
Before this test, I also tried to use the same library to open the CH341 usb serial device, and it succeeded. I was confused why? Thank you for any help.