Skip to content

frombuffer byte order #306

@ubIQio

Description

@ubIQio

I have a buffer of data from an ADC, which i am trying to access as an ndarray

The 1024 byte buffer is organised in 'frames' of 8 bytes, the bytes of interest in each frame being 1 through 6, being three pairs of 16 bit samples.

If I ignore the last byte of the buffer, I can get the buffer as an ndarray uising

buffer = b'\x40\x00\xda\xff\xd6\xc1\x2e\x0d\x40\x00\xde\xff\xca\xc1\x3c\x0d\x40\x00\xe6\xff\xc4\xc1\x40\x0d\x40\x00\xe0\xff\xb8\xc1\x32'


a = np.frombuffer(buffer, dtype=np.uint16, offset=1)

but the result is byteswapped values e.g

a:	 array([55808, 55039, 11969, ..., 57344, 47359, 12993], dtype=uint16)

dtype = np.>uint16 causes a reboot, any ideas how this can be achieved?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions