Skip to end of metadata
Go to start of metadata

When processing binary fixed-width data,  comma and snark utilities use byte order of the computer on which they run. E.g. on most of the desktops (with x86 architectures), byte order is little endian, but ARM computers will have big endian byte order.

If you have fixed-width data (e.g. from some external party or a device) that have endianness (byte order) different from your computer. There is a number of ways to deal with it at various levels (e.g. using htoi()-style functions, or python serialization, or comma::packed classes, etc).

If you just want to quickly modify your data to the desired endianness, now you could use csv-bin-reverse, e.g:

> # reverse all the fields in the data
> cat big-engian-data.bin | csv-bin-reverse t,3d,2ui
> # reverse some fields in the data
> cat big-engian-data.bin | csv-bin-reverse t,3d,2ui --fields 2-4

If you need to make sense of how it works, you could run something like:

> echo 0,1,2,3,4,5,6,7 | csv-to-bin 8ub | csv-bin-reverse uw,ui,uw | csv-from-bin 8ub
1,0,5,4,3,2,7,6
 
> echo 0,1,2,3,4,5,6,7 | csv-to-bin 8ub | csv-bin-reverse uw,ui,uw --fields 2 | csv-from-bin 8ub
0,1,5,4,3,2,6,7
> # etc...
  • No labels