![]() |
|
#1
|
|||
|
|||
Help needed to understand the requirementHi all,
I am trying to develop an application protocol for testing. I have the requirement for the packet structure. But the data types in the requirement are little confusing to me. Can someone pls help me in identifying these data types.? Format of the statments below is ========================= Tyep Length Description ========================= Quote:
Thanks, |
|
#2
|
|||
|
|||
|
Quote:
If your compiler has <stdint.h>, use the types there. For example: CPP / C++ / C Code:
So you can do something like this for the basic data types. CPP / C++ / C Code:
Now as for the ARRAY8 array. They are storing an integer value in the first two bytes of a byte array. This is particularly yukky, since the actual order of the first two bytes stored depends on whether the system is big-endian or little-endian. The issue of byte-ordering raises its ugly head for the other arrays as well. (So we need a little more information about the specification.) I can show you a trick or two to handle this, but first: does your system have <stdint.h> so that the above code works? (If not, you have to tell me what compiler you are using. I know ways of getting to the bottom of things with Borland and Microsoft compilers --- I'll tell you how I did it if you need to see it.) Regards, dave Last edited by davekw7x : 15-Feb-2005 at 12:47.
|
|
#3
|
|||
|
|||
|
Hi Dave,
I use gcc compiler on linux. I have <stdint.h>. The data types you showed in your example works on my complier. Following is one more requirement of the protocol, "Integer values are always stored most significant byte first in the packet (‘‘Big Endian’’ order")." Thanks, |
|
#4
|
|||
|
|||
|
Quote:
So, to store quantities greater than a byte, get the bytes in order. One way is by simple bit manipulations (the other is by arithmetic operations).. CPP / C++ / C Code:
To get the bytecount back and print the array, you could have something like this: CPP / C++ / C Code:
Get the idea? (Of course you could define functions or macros to put the bytes into the larger quantities and get them back again.) Regards, Dave |
|
#5
|
|||
|
|||
|
just wondering, is it "high and low endian" or "big and little endian"?
__________________
spasms!!! |
|
#6
|
|||
|
|||
|
Hi machinated,
Its the later one... Dave, Just saw your reply. Tryin to understand it. Will get back to you. Thanks, |
|
#7
|
|||
|
|||
|
Quote:
Is it style or is it substance? (Potato or potahto?) Little-endian is a play on the old nursery rhyme "One little-, two little-, three little- Native Americans." That was OK when we said it 1973 (to distinguish between Intel and Motorola microprocessors). The Political Correction commandos may have coerced some into calling it high-end and low-end, but it just doesn't have that certain ring to it (at least to me). Regards, Dave |
|
#8
|
|||
|
|||
|
Hi Dave,
I got the presentation of CARD8 variable. But how will I represent ARRAYOFARRAY8 ? My packet looks like the one below. CPP / C++ / C Code:
I am filling the packet as below. CPP / C++ / C Code:
|
|
#9
|
|||
|
|||
|
Hi Dave,
I have figured out that the problem was in my "sendto" statement (UDP datagram socket send operation). I was calculating the wrong packet length. Thanks, |
|
#10
|
|||
|
|||
|
how are you representing any of your arrays? array8 specifies a card16 followed by card8s - which is fine if you have an array of card8s, u can join 2 card8s to form card 16. but array16 is a card8 followed by card16 elements. and same for array32 - i know they say 2*m+1 and 4*l+1 respectively, but does that imply that you are to have 2 times the number of card8 elements for array16 and 4 times the number of card8 elements for array32? how would you go about manipulating values in each element? you'd have to do a lot of bit manipulating! maybe you should have structures, that would certainly make things easier, and since contents of a structure are stored contigously in memory then manipulating the values with pointers wouldn't be a problem either if need be.
e.g. CPP / C++ / C Code:
what do you think? unless they've specified that you are to create arrays and not structures. or maybe you already have structures? then forget about this whole message! so then arrayofarray8 would be a struct that would have a card8 and an array of array8 structures. CPP / C++ / C Code:
for completeness's sake: CPP / C++ / C Code:
I'm not saying that my ideas are the best ways to implement your problem. I am just making guesses here. but it's worth a try. good luck __________________
spasms!!! |
Recent GIDBlog
Developing GUIs with wxPython (Part 2) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to use resources, general info needed. | drewdaman | MS Visual C++ / MFC Forum | 1 | 14-Dec-2004 11:57 |
| Knight tour (arrays help needed) | dilmv | C++ Forum | 7 | 18-Oct-2004 14:31 |
| urgent help needed :c + mysql insert | jack | C Programming Language | 1 | 13-Apr-2004 21:16 |
| Free 1st month / Free setup / No credit card needed...Plans start at 4.95 | LarryIsaac | Web Hosting Advertisements & Offers | 0 | 11-Oct-2003 14:03 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The