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!