You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As there is inaccuracy in reading float values, I'm using some bash commands to get right value in different byte orders and endiannesses.
Maybe someone else will find this usefull:
##32 bit integer:
#commands are the same, as for 32 bit float, except:
#for signed 32bit integer, use "l" in python unpack format - "...struct.unpack("!l",...";
#for unsigned 32bit integer, use "L" in python unpack format - "...struct.unpack("!L",...".
##64 bit integer:
#commands are the same, as for 64 bit float, except:
#for signed 64bit integer, use "q" in python unpack format - "...struct.unpack("!q",...";
#for unsigned 64bit integer, use "Q" in python unpack format - "...struct.unpack("!Q",...".
As there is inaccuracy in reading float values, I'm using some bash commands to get right value in different byte orders and endiannesses.
Maybe someone else will find this usefull:
#32 bit float:
#BIG Endian
/usr/local/bin/mbpoll -t4:hex -c2 -0 -B -1 -q -r 10 127.0.0.1 -p 1502 | awk 'FNR >= 2 {print $2}' | awk '{sub(/^0x/,""); print}' | tr -d "\n" | python3 -c 'import struct; print(struct.unpack("!f", bytes.fromhex(input()))[0])'
#LITTLE Endian
/usr/local/bin/mbpoll -t4:hex -c2 -0 -B -1 -q -r 10 127.0.0.1 -p 1502 | awk 'FNR >= 2 {print $2}' | awk '{sub(/^0x/,""); print}' | fold -w2 | tac | tr -d "\n" | python3 -c 'import struct; print(struct.unpack("!f", bytes.fromhex(input()))[0])'
#BIG Endian BYTE Swapped
/usr/local/bin/mbpoll -t4:hex -c2 -0 -B -1 -q -r 10 127.0.0.1 -p 1502 | awk 'FNR >= 2 {print $2}' | awk '{sub(/^0x/,""); print}' | fold -w4 | tac | fold -w2 | tac | tr -d "\n" | python3 -c 'import struct; print(struct.unpack("!f", bytes.fromhex(input()))[0])'
#LITTLE Endian BYTE Swapped
/usr/local/bin/mbpoll -t4:hex -c2 -0 -B -1 -q -r 10 127.0.0.1 -p 1502 | awk 'FNR >= 2 {print $2}' | awk '{sub(/^0x/,""); print}' | fold -w4 | tac | tr -d "\n" | python3 -c 'import struct; print(struct.unpack("!f", bytes.fromhex(input()))[0])'
#64 bit float:
#BIG Endian
/usr/local/bin/mbpoll -t4:hex -c4 -0 -B -1 -q -r 10 127.0.0.1 -p 1502 | awk 'FNR >= 2 {print $2}' | awk '{sub(/^0x/,""); print}' | tr -d "\n" | python3 -c 'import struct; print(struct.unpack("!d", bytes.fromhex(input()))[0])'
#LITTLE Endian
/usr/local/bin/mbpoll -t4:hex -c4 -0 -B -1 -q -r 10 127.0.0.1 -p 1502 | awk 'FNR >= 2 {print $2}' | awk '{sub(/^0x/,""); print}' | fold -w2 | tac | tr -d "\n" | python3 -c 'import struct; print(struct.unpack("!d", bytes.fromhex(input()))[0])'
#BIG Endian BYTE Swapped
/usr/local/bin/mbpoll -t4:hex -c4 -0 -B -1 -q -r 10 127.0.0.1 -p 1502 | awk 'FNR >= 2 {print $2}' | awk '{sub(/^0x/,""); print}' | fold -w4 | tac | fold -w2 | tac | tr -d "\n" | python3 -c 'import struct; print(struct.unpack("!d", bytes.fromhex(input()))[0])'
#LITTLE Endian BYTE Swapped
/usr/local/bin/mbpoll -t4:hex -c4 -0 -B -1 -q -r 10 127.0.0.1 -p 1502 | awk 'FNR >= 2 {print $2}' | awk '{sub(/^0x/,""); print}' | fold -w4 | tac | tr -d "\n" | python3 -c 'import struct; print(struct.unpack("!d", bytes.fromhex(input()))[0])'
##32 bit integer:
#commands are the same, as for 32 bit float, except:
#for signed 32bit integer, use "l" in python unpack format - "...struct.unpack("!l",...";
#for unsigned 32bit integer, use "L" in python unpack format - "...struct.unpack("!L",...".
##64 bit integer:
#commands are the same, as for 64 bit float, except:
#for signed 64bit integer, use "q" in python unpack format - "...struct.unpack("!q",...";
#for unsigned 64bit integer, use "Q" in python unpack format - "...struct.unpack("!Q",...".
mbpoll_32_64bit_tests.txt
The text was updated successfully, but these errors were encountered: