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 7631737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:25:52+00:00 2026-05-31T06:25:52+00:00

I’m trying to build a callback-based serial RX driver, and am getting a compile

  • 0

I’m trying to build a callback-based serial RX driver, and am getting a compile error despite the fact that I’m using a structure which is known good and tested in other applications. I’m sure I’m doing something silly, but for the life of me I can’t see it, so a few extra pairs of eyes would be much appreciated.

The device should function as follows:

  1. On construction, pass in the comms properties
  2. For synchronous communications, do not create a new thread, just block on the TX.
  3. For receiving data, spawn a new thread, and execute a callback passed in by the user on RX.

To implement this, I have a base callback class as follows:

namespace ocular
{
 Class DeviceCallback
 {
 public:
   DeviceCallback(){}
   ~DeviceCallback(){}
   virtual void DeviceCallbackFunction(unsigned char Data){}
 };
}

And the Start Asynch RX method within the device class itself as:

void DeviceClass::StartAsynchRX( DeviceCallback* callback )
{
  m_externalCallback = callback; // Save a local copy of the callback pointer
  m_started = true;
  StartAsynchRXThread();         // Spawn the RX Thread
  return;
}

I am then deriving my own callback as:

Class DemoCallbackClass : public ocular::DeviceCallback
{
public:
  void DeviceCallbackFunction(unsigned char myData){
    std::cout << myData;
  };
}

As far as I can tell, this is textbook correct thus-far. This will compile just fine and I can construct, configure and use my device class for synchronous TX. The compile error appears when I attempt to actually start passing the callback pointer in main:

void main(void)
{
  DeviceClass MyDevice();
  MyDevice.Initialise( *settings from file* );

  DemoCallbackClass MyDemoCallback();

  MyDevice.StartAsynchRX( &MyDemoCallback );  // ERROR ON THIS LINE
}

1>……\Src\Support\AR2500 Commissioning\Main.cpp(99): error C2664: ‘ocular::DeviceClass::StartAsynchRX’ : cannot convert parameter 1 from ‘DemoCallbackClass (__cdecl *)(void)’ to ‘ocular::DeviceCallback *’

I’m reasonably sure I’ve done something silly here, but I can’t find it for the life of me. Last week I wrote an event timer class using exactly the same approach and it works just fine. If the structure/approach looks OK to everyone out there, I guess It’s a subtle typo, and I just need to rewrite a chunk at a time until I get rid of the damn error.

Yours in desparation,

DKW

  • 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-31T06:25:53+00:00Added an answer on May 31, 2026 at 6:25 am

    Remove the parenthesis from this line:

    DemoCallbackClass MyDemoCallback();
    

    So it looks like this:

    DemoCallbackClass MyDemoCallback;
    

    The error output is not helpful at all in this case, but that should fix it.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

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.