Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pack and unpack array of "Structs" #59

Open
ayh20 opened this issue Apr 11, 2018 · 3 comments
Open

Pack and unpack array of "Structs" #59

ayh20 opened this issue Apr 11, 2018 · 3 comments

Comments

@ayh20
Copy link

ayh20 commented Apr 11, 2018

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....

@lunixbochs
Copy link
Owner

lunixbochs commented Apr 11, 2018 via email

@lunixbochs
Copy link
Owner

lunixbochs commented Apr 11, 2018 via email

@ayh20
Copy link
Author

ayh20 commented Apr 11, 2018

Not sure how it got like that in the first place ;-)

I'll try the Options syntax and create you a small test case, as soon as i have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants