I am pulling byte wide data from a processor, and trying to extract one bit/flag for status. I pull the data byte from 0x1B, and then mask against 0x08, which is supposed to leave the 4th bit. In normal operation it takes some time for the bit to flip - so I iterate on pulling the bit and testing it
STATUS_FOC = []
STATUS = []
FOC_Mask = []
while x <= 100:
STATUS = bin(sys.Read(0x1B))
print 'status', STATUS
FOC_Mask = bin(0x08)
print 'FOC', FOC_Mask
STATUS_FOC = STATUS & FOC_Mask
No matter what I do to the variables Python insists in the last line that I am trying to do a logical AND of two strings. Output of STATUS and FOC_Mask are as follows:
status 0b11010000 FOC 0b1000
which I read as binaries, and yet the program crashes over the last line saying that it can't do an '&' operation on strings. Help
bin()returns a string. Stop using it.