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

  • SEARCH
  • Home
  • 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 7540499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:39:32+00:00 2026-05-30T07:39:32+00:00

I am currently trying to implement a serial port reader class using Windows (already

  • 0

I am currently trying to implement a serial port reader class using Windows (already implemented one using Boost, want to cater for the possibility that the platform may not have Boost).

All seems to be working well, except when I test my Windows serial port reader (executable) using my Boost serial port writer (a separate executable), the writer throws an access denied exception. Otherwise the reader works, as it seems to be reading whatever is on the serial port up until the point that the writer can no longer write.

It doesn’t matter whether the writer is started first or the reader is started first, once the reader opens the port for reading, the writer can no longer write to that port.

I have tried setting different arguments in the CreateFile() method but to no avail so far, I would expect the following code snippet to work but it doesn’t.

m_serial = CreateFile(
    m_port, 
    GENERIC_READ, 
    FILE_SHARE_WRITE, 
    0, 
    OPEN_EXISTING, 
    FILE_ATTRIBUTE_NORMAL, 
    0);

The writer code may be irrelevant but here it is anyway:

void writeLine(std::string line) 
{
    boost::asio::io_service io;
    boost::asio::serial_port serial(io, m_port);

    serial.set_option(boost::asio::serial_port_base::baud_rate(m_rate));

    boost::asio::write(serial, boost::asio::buffer(line.c_str(), line.size()));

}

And the .what() for the boost::system::system_error is:

open: Access is denied

Any ideas?

I’ve looked here: http://www.robbayer.com/files/serial-win.pdf (great article, but doesn’t go that far) and http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx – seems like it should be the dwShareMode argument but I can’t get it working.

Edit: I should mention I am using this serial port emulator http://www.eterlogic.com/Products.VSPE.html which may well be the cause of my woes, if so then it doesn’t matter. The emulator works as expected when using my Boost reader with my Boost writer though (from two separate executables).

  • 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-30T07:39:34+00:00Added an answer on May 30, 2026 at 7:39 am

    I can understand why there have been no replies now. For the record, the arguments to open the serial port were fine. The problem was that I was attempting to open the same port for each read without closing it, so I’ve just left it open until I’ve completed finished with it.

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

Sidebar

Related Questions

I'm currently trying to implement a class to handle secure communications between instances of
I'm trying to implement a mailing list system for my application. I'm currently using
so i'm currently trying to implement a currency conversion script using Jquery, curl, ajax
I'm currently trying to implement a editable details view using a grouped UITableView. I'd
I'm currently trying to build a class hierarchy automatically by using C++ templates. The
Hey guys, I'm currently trying to implement a function using C that takes in
I am currently trying to learn how to implement MVVM using Unity and Caliburn
I am trying to implement a function which reads from Serial Port ( Linux)
I'm currently trying to implement BOS 5.4 in one of my projects. Unfortunately I'm
I'm writing a serial port software for Windows. To improve performance I'm trying to

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.