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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:37:32+00:00 2026-05-31T21:37:32+00:00

I’m writing a program to communicate with certain patient monitor using connection-less (UDP) sockets.

  • 0

I’m writing a program to communicate with certain patient monitor using connection-less (UDP) sockets. I need a suggestion for the fastest and most efficient algorithm that I should use to parse the data received from patient monitor.

Patient monitor sends data as AttributeList structure, the definition of the structure is below:-

typedef struct {
  uint16 count;
  uint16 length;
  AVAType * values;
} AttributeList;

typdef struct {
  uint16 id;
  uint16 length;
  void * data;
} AVAType

So an AttributeList contains many AVAType structures, and every AVAType structure contains id and data as void pointer (data is just an place-holder for actual data in AVAType). In fact, there are about 150 ids defined for AVAType and each ID, data must be placed in some corresponding data structure for parsing purposes.

So if ID in AVAType structure is 1, then data must be parsed using algorithm A but if ID is 2 then data must be parsed using Algorithm B and so on…

My current approach is using 150 if-else statements and loading the particular data-structure for AVAType and then parse the result. Also the patient monitor sends data in network byter order and I need unpack the AVAType as per the ID.

Please suggest some good approach to deal with this situation. It is just an university thing, I do not brother much about safety, I think safety can be improved gradually but right now my concern in speed.

Yes, it is actaully AVAType values[];. Can you be more specific on why is this different from AVAType * ? Can it be any useful if I define my structure other way around?

  • 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-31T21:37:34+00:00Added an answer on May 31, 2026 at 9:37 pm

    The usual way to map from integers to functions is just an array of function pointers

    typedef void (*Fun_ptr)(int id, void *current_byte);
    
    Fun_ptr fun_ptr[0xFFFF+1] = { funcA, funcB, ...};
    

    If the ids are only one byte, I’d map all 256 (if it can be restricted).

    Even with all 16 bit ids, it isn’t a lot of storage.

    I’d point unused id’s at an ‘error catch’ function.

    Use:

    next_buffer_position = fun_ptr[id](id, current_buffer_position);
    

    Then the function knows which id it was called for, making the error_catch function easy to write, you only need one.


    Are you sure it is AVAType * values; and void * data;?

    Is values or data supposed to be an offset within the packet?

    It is not impossible, and may be correct. Currently AVAType and AttributeList are a fixed size.

    The fields AVAType * values; and void * data; are the receiving computers size for a pointer. That could be anything, but likely 32 bits, or 64 bits. That is a potential problem if you move the software to different machines, and is why I am asking. They hold no data, they are pointers to data, but their size varies depending on the receiving machine. Suspicous. Double check what size they are defined to be.

    A common way of handling packets on a network protocol, is with an empty array as the last field in the struct, e.g.

    typdef struct {
      uint16 id;
      uint16 length;
      unsigned char data[];
    } AVAType;
    

    In that approach, there is usually a packet length in a fixed position near the start of the packet, and that gives the actual size of the remainder of the packet. So the protocol defines whether the whole packet or data[] is length bytes. It is a bit ‘hackish’ but it is easy to use. (NB IIRC unsigned char data[]; is not legal C++)

    Summary: It is likely the in-memory structs are exactly the typedefs you’ve shown, but the on-the-wire protocol is a bit odd bcause of the variable size of a pointer.

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

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In my XML file chapters tag has more chapter tag.i need to display chapters
I would like to run a str_replace or preg_replace which looks for certain words
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.