This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Data storage format

Hello,
I'm developing a DeviceNet application with Silicon Labs C8051F040, Keil compiler and a DeviceNet stack. The problem is the way that Keil stores var (16bit, 32 bit...). When I send data on the DeviceNet, the other devices get the inversion of my data.
For example, if i want to send 0x123456, the others Device, such as my computer, receive 0x563412.
Is there any way to solve this problem? Please don't tell me to convert the data into 8bit length because that is a very huge work (I'm using the DeviceNet stack of other company).
Thanks for reading this topic.

Parents
  • The sender and receiver have to know the message format to communicate at all. At the very least, it has to be parsable based on the early fields.

    If you know you have a 2-byte field, followed by a 6-byte field, then you can declare something like:

    typedef struct
         {
         U16 msgType;
         U8  MacAddr[6];
         }
         MyMessage;
    

    The receiver would byte-swap msgType, and perhaps swap MacAddr (or not, since it's not an integer). There would be perhaps lots of other structures, each one corresponding to a different msgType value.

Reply
  • The sender and receiver have to know the message format to communicate at all. At the very least, it has to be parsable based on the early fields.

    If you know you have a 2-byte field, followed by a 6-byte field, then you can declare something like:

    typedef struct
         {
         U16 msgType;
         U8  MacAddr[6];
         }
         MyMessage;
    

    The receiver would byte-swap msgType, and perhaps swap MacAddr (or not, since it's not an integer). There would be perhaps lots of other structures, each one corresponding to a different msgType value.

Children
No data