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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:30:49+00:00 2026-05-20T03:30:49+00:00

I’m currently assigned to a task to develop a software module to communicate with

  • 0

I’m currently assigned to a task to develop a software module to communicate with a stepper motor controller. The project is written in C#, I have a C++ dll to communicate with the controller. The communication runs via the Serial port. I’m planning to write the whole piece in C# by importing the necessary methods by DllImport. The key method looks something like :

ComSendReceive(pHandle, bufferIn,sizeBufferIn,bufferOut,ref bufferOut)

There are several types of messages :

  • You send message and expect confirmation (not the same for every message, sometimes it’s OK, sometimes it’s COMPLETE etc..
  • You send message and receive message – you can receive an error or data (for instance GET_CONTROLLER_ID)
  • Several other types

Of course I need to control the communication for time-outs.

My question is: Is there any “design pattern” to use for that kind of problem? I’m sure this is quite a common problem many developers have solved already.

To contribute a little – I dealt with similar problem in my last job and I solved it this way :

I had a class to communicate with the Com port and a class AT_message with bunch of overloaded constructors :

class AT_Message
{
    public bool DoResponseCheck;
    public string ExpectedResponse;
    public AT_COMMAND command;
    public string data;
    public bool AddCarriageReturn;
    ...

    //Plenty of ctors
}

class UnfriendlyInterface
{
     Response SendMessage(AT_Message msg)
     {
         //Communicates directly with C++ dll, send message, check timeouts etc....
     }
}

And I had a class the main application was communicating with, it had human friendly methods like

class FriendlyInterface
{
     bool AutodetectPortAndOpenComm();

     Result AnalyzeSignal(byte[] buffer)
     {
         Response response = UnfriendlyInterface.SendMessage(new Message(AT_Command.PrepareForSignal, (doResponseCheck)true, ExpectedResponse.Ok,Timeout.short);
         Response response = UnfriendlyInterface.SendMessage(new Message(buffer,(doResponseCheck)false,Timeout.long);

         //.... Other steps
     }

     //... other methods

}

Since last time I was really in a big hurry, I implemented first solution that came to my mind. But is there a way to do it better? Now the device I’m communicate with is more complex than the previous one so if there’s a way how to do it better, I’d like to do it that way.

  • 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-20T03:30:50+00:00Added an answer on May 20, 2026 at 3:30 am

    This seems like a textbook facade pattern. The answer to all of this is to encapsulate your variation. For example, try to create a generic interface for commands that give an acknowledgement, and write client code to use that interface. Then concrete types can decide how to interpret various acknowledgements into a uniform signal (Ok = Complete = Good, or whatever)

    Here’s a good article on the facade pattern. Also see the wikipedia article.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.