Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
xtce explicit byte order list processing isn't correct #411
The code in packet_config.rb (line 638) which determines if the byte order is little endian seems to be definitely wrong.
In XTCE, big endian is the default ... which you have also.
But then in XTCE an explicit byte order is given by an explicit ByteOrderList -- and then big or little endian by descending or ascending list of integers -- such as 3,2,1,0 or 0,1,2,3. The cheapest check I've come up with is a loop to determine if the byte order list is ascending or descending -- and then a check if the item ends or starts at zero. Other orderings are possible but they would not be big or little endian (and you don't support them).
As best as I can tell in the current code -- big endian is the default, then if the bye order list element is found, it is looped through and if 0 is found -- the ordering is set to little endian...
I believe the current logic is correct. Is it not working for you?
The current logic is:
The key detail is that it only looks at the first Byte keyword. Little endian will always have 0 first. Single byte types don't matter if they are big or little endian so its ok if they get marked little endian.
I have this (below) and its getting it as little endian. I added some debugging to the code for it but not enough to fully illuminate. I will work on more details there -- possibly tomorrow late. But the print statements I added seem to suggest it loops through the entire list, but I may have done it incorrectly.
Here is what I see.
Inputs (example -- this is big endian):
Modified Source, PacketConfig.rb, from line 638
BTW I tried Logger and IO.write but failed to find a good (easy) way to capture print to a file... can I tell cosmos to log to a file?
here's some hack around code. I believe the real check should be:
But I didn't do that. I just collect in a list the significances and check the ends for zero... I left the original code in place as a reference pt and all my debugging prints too. Since I don't know ruby well, I suspect this can all be reduced to a single line of code, etc...
I made an attempt to provide a more comprehensive fix. I wrote 2 procedures ... but I (did a bad thing) and modified the gem directly... and now it doesn't seem to load, instead using a cached version (this is a guess). Funnily I got by by this way for all my other debugging until this last part... I had to move onto to something else and my previous band-aid allowed the XTCE to load and be mostly useful. But because I know I have some number of weird byte orders, these are not being caught by the band-aid approach above.
Anyway, these are just suggestions...
Here is the code: