bin6_four
demonstrates how to create 4 byte pseudobinary encoded numbers¶
-
bin6_four.
bin6_four
(num, count=4, right_digits=0, is_signed=True)¶ Converts a number in to a
count
byte long 6-bit packed binary string (used for GOES formatting). The maximum number of bytes is 4, which allows a representation range of [-8388608 .. 8388607]. The moreright_digits
you request, the smaller the range. For instance with 2right_digits
, the the maximum range becomes limited to [-1310.72 .. 1310.71], and even less with fewer bytes.Examples:
>>> # Convert 1234567 to 6-bit pseudo-binary: >>> bin6_four(1234567) b'DmZG' >>> # Convert 12345 to 6-bit pseudo-binary: >>> bin6_four(12345, 3) b'C@Y' >>> # Convert BV in to a 3-byte 18-bit value: >>> BV = 12.32 >>> bin6_four(BV, 3, 2) b'@SP'
Parameters: Returns: A byte string containing 6-bit binary data.
Return type: