Note that there are some explanatory texts on larger screens.

plurals
  1. POSocket Programming in C and Unserialize the Response
    primarykey
    data
    text
    <p>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.</p> <p>Patient monitor sends data as AttributeList structure, the definition of the structure is below:-</p> <pre><code>typedef struct { uint16 count; uint16 length; AVAType * values; } AttributeList; typdef struct { uint16 id; uint16 length; void * data; } AVAType </code></pre> <p>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. </p> <p>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...</p> <p>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. </p> <p>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.</p> <p>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?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload