Instrument Control (GPIB, Serial, VISA, IVI)

Showing results for 
Search instead for 
Did you mean: 

Reading serial values and convert it to address and data



I am receiving strings of bytes from a hardware using serial read function. Now I want to rearrange these values i.e. each 4 bytes should be arranged in 10-bit address and 20-bit data. Please find attached screen shot.

Thanks in advance.

0 Kudos
Message 1 of 3

Is there more to the message protocol than just the 4 bytes?  It would be a bad protocol if that is all it is since it is easy to get out of sync and you will want some kind of data verification.


But assuming you have your 4 bytes, I would use Unflatten From String to cast the data to an I32 or U32.  Then you can use some simple digital logic to get your two parts of data.  Use AND to mask out all of the bits above bit 10 to get your address.  Shift the bits to the right 10 times to get your data (should probably mask out the upper 2 bits first).

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 3



I am reading device register values on each address and I want to know the data on each register.


SO, there are around 400 address of 10 bit having 20 bits of data. I want to arrange these 400 address and corresponding data.

0 Kudos
Message 3 of 3