Skip to content

Pack and unpack array of "Structs" #59

@ayh20

Description

@ayh20

I found an strange error when working with an array of structs.

Pack and unpack work correct as far as i can see with one issue ... it ignores the Endian setting (little).

For example unpack a byte stream that contains little endian floats ...
type LEData struct {
X float32 struc:"float32,little" // world co-ordinates of vehicle
Y float32 struc:"float32,little" // world co-ordinates of vehicle
Z float32 struc:"float32,little" // world co-ordinates of vehicle
}
unpackedData := &LEData{}
err = struc.Unpack(buf2, unpackedData)

Data is correct ... However ...

The data is actually an array of these items...

unpackedData := &[2]LEData{}
err = struc.Unpack(buf2, unpackedData)

The unpack "works" no errors at least :-) ..... but the data has been interpreted as Big Endian even though the data is tagged as Little.

Let me know if you need a working test case....

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions