What type of data that is separated by \ and is in hex?
<p>I have a data set that is pulled from a pixhawk. I am trying to parse this data and plot some of them vs time. The issue is when I use this code to open one of the bin files:</p>

<pre><code>with open("px4log.bin", "rb") as binary_file:
    # Read the whole file at once
    data = binary_file.read()
    print(data)
</code></pre>

<p>I get data that looks like this:</p>

<pre><code>b'\xa3\x95\x80\x80YFMT\x00BBnNZ\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00Type,Length,Name,Format,Columns\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa3\x95\x80\x81\x17PARMNf\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00Name,Value\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa3\x95\x80\x82-GPS\x00BIHBcLLeeEefI\x00\x00\x00Status,TimeMS,Week,NSats,HDop,Lat,Lng,RelAlt,Alt,Spd,GCrs,VZ,T\x00\x00\xa3\x95\x80\x83\x1fIMU\x00Iffffff\x00\x00\x00\x00\x00\x00\x00\x00\x00TimeMS,GyrX,GyrY,GyrZ,AccX,AccY,AccZ\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0
</code></pre>

<p>I was told it is supposed to be in binary, but it's not. Unless python is doing something to the data set when it is opening it?</p>

<p>You can download this sample data set if you would from:</p>

<pre><code>https://pixhawk.org/_media/downloads/px4log_sample_1.px4log.zip
</code></pre>

<p>Python is showing you the binary data represented in <a href="https://en.wikipedia.org/wiki/Hexadecimal" rel="nofollow">hexadecimal</a> when the characters do not correspond with a regular <a href="https://en.wikipedia.org/wiki/ASCII" rel="nofollow">ascii</a> character. For example <code>\xa3</code> is a byte of hexidecimal value <code>A3</code> which is <code>10100011</code> in binary. <code>T</code> on the other hand could be printed as <code>\x54</code> which is a byte of binary value <code>01010100</code>. Since you used the <code>print</code> function, python assumes you are trying to convert the binary data to a human readable string, so instead of <code>\x54</code> it showed the corresponding character <code>T</code>.</p>

<p>You can use the following code to get an array of binary strings that represent your data:</p>

<pre><code>data = '\xa3\x95\x80\x80YFMT\x00BBnNZ\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00Type,Length,Name,Format,Columns'

decimalArray = map(ord,data)
byteArray = map(lambda x: "{0:b}".format(x), decimalArray)
print byteArray
</code></pre>

<p>Here is the output:</p>

<pre><code>['10100011', '10010101', '10000000', '10000000', '1011001', '1000110', '1001101', '1010100', '0', '1000010', '1000010', '1101110', '1001110', '1011010', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1010100', '1111001', '1110000', '1100101', '101100', '1001100', '1100101', '1101110', '1100111', '1110100', '1101000', '101100', '1001110', '1100001', '1101101', '1100101', '101100', '1000110', '1101111', '1110010', '1101101', '1100001', '1110100', '101100', '1000011', '1101111', '1101100', '1110101', '1101101', '1101110', '1110011']
</code></pre>

python