Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 808217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:31:39+00:00 2026-05-15T00:31:39+00:00

Under WindowsCE, C++ project, I’m trying to work with devices connected via both real

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T00:31:40+00:00Added an answer on May 15, 2026 at 12:31 am

    Why not perform the open in another thread? There’s no reason to do anything else in that thread – just open the port and you can use the handle for the opened port in any other thread in your process.

    However, I’m not sure what’s so screwed up that your CreateFile() call seems to hang – I wonder if this happens even on another thread whether things will still be stable in your application.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Under WindowsCE, C++ project, I'd like to get CPU utilization and memory allocation data
I'm trying to build CGAL for windows to use in my project under Visual
I'm trying to compile an open source project on windows under mingw/msys. The makefile
I'm trying to set up Code::Blocks under Windows 7 Professional SP1 to work for
I've a ASP.NET MVC 2 project that runs fine under Windows 7 and will
Trying to build Xuggler under Windows. Xuggler is core native code functions wrapped into
I am trying to use Cucumber for a Rails project on Windows. Unfortunately the
I work on a project called UAWKS (Unofficial Apple Wireless Keyboard Support) that helps
Let say I started a C# project under Windows (Visual Studio 2008) and I
I have a project that runs perfect under windows xp. Now I have tried

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.