embedded dev. question - how to break free from a faulty serial port opening?
Posted
by user347266
on Stack Overflow
See other posts from Stack Overflow
or by user347266
Published on 2010-05-21T16:34:16Z
Indexed on
2010/05/21
16:40 UTC
Read the original article
Hit count: 176
Under WindowsCE, C++ project, I'm trying to work with devices connected via both "real" serial ports and/or serial-to-usb wrappers ("virtual" serial ports); my problem is - when I try to open the port, if something goes wrong, the function never returns and the system goes into some non-responsive state and has to be eventually rebooted. I need to open the ports from the main thread. The question is - how can I make it happen in a controlled way?? this is the opening code snippet:
std::ostringstream device_name; device_name << "\\.\COM" << port; m_port = ::CreateFile(device_name.str().c_str(), GENERIC_READ | GENERIC_WRITE, 0, // exclusive access NULL, // no security OPEN_EXISTING, FILE_FLAG_OVERLAPPED, // overlapped I/O NULL); // null template
any suggestions would be greatly appreciated
thanks!
© Stack Overflow or respective owner