HEX/DEC/BIN number entry and output display
From DP
The Bus Pirate terminal interface accepts numbers in three formats: hexadecimal, decimal, and binary. It also displays values in HEX/DEC/BIN and a raw byte format. This short guide explains how to enter number values into the Bus Pirate, and how to adjust the Bus Pirate number display format.
Contents |
Number entry
The maximum value you can enter in any format is currently 255 (8bits/1byte).
HEX
0x0, 0x18, 0x4A, 0xFF
Hexadecimal values are base 16 numbers that use a-f for the numbers 10-15, this format is very common in computers and electronics. Enter HEX values as shown above, precede the value with 0x. Single digit numbers don't need 0 padding, 0x01 and 0x1 are interpreted the same.
DEC
0, 24, 74, 255
Decimal values are common base 10 numbers. Just enter the value, no special designator is required.
BIN
0b0, 0b11000, 0b1001010, 0b11111111
Binary values are commonly used in electronics because the 1's and 0's correspond to register 'switches' that control various aspects of a device. Enter a binary number as 0b and then the bits. Padding 0's are not required, 0b00000001=0b1.
Convert formats
2WIRE> =0b110
0x06 = 6 = 0b00000110
2WIRE> =0xa
0x0A = 10 = 0b00001010
2WIRE> =12
0x0C = 12 = 0b00001100
2WIRE>
The = command (firmware v2.1+) converts between number formats.
Output display
HiZ>o
1. HEX
2. DEC
3. BIN
4. RAW
(1) >1
Display format set
HiZ>
The Bus Pirate terminal will display values in BIN/HEX/DEC. Change the setting in the data display format menu (o). The default display format is HEX.
The RAW display mode sends values to the terminal as raw byte values without any text conversion. This is useful for bus sniffers and other high-speed functions where converting raw bytes to text takes too much time. Adjust the display format in your serial terminal to see the raw values as HEX/DEC/BIN.

