I have question regarding aliasing word variables and the order of the bytes as they are stored..
I have an byte array that stores incoming serial data. The data is comprised of 16 bit words, but are sent MSB first then LSB. I am trying to alias the array to several word variables using the following code..
Code: Select all
Dim Array(10) as byte
Dim Word_var_1 as Array(0).Asword
Dim Word_var2 as Array(2).Asword
However because the bytes are sent MSB-LSB, they are stored in the wrong order for the Aliasing (LSB then MSB) and any reference to my word variable is incorrect.
My first thought was just swapping the bytes as they are read and stored in the array, but i need the array in the order it was transmitted so i can preform a CRC check on the data. If i swap them, the CRC will never match and each packet will be rejected..
Other than going back through and swapping each pair using a separate routine is there any other way of doing it?
Cheers
Lee