K kkingstoun Member Licensed User Longtime User Jan 10, 2013 #1 Hi, I saved data bits from Bluetooth device to the file puls.bin. I would like to read all of these bits like as protocol: Special I need to read 3 byte - wave pulse. How could I read these from file? Last edited: Jan 10, 2013
Hi, I saved data bits from Bluetooth device to the file puls.bin. I would like to read all of these bits like as protocol: Special I need to read 3 byte - wave pulse. How could I read these from file?
Erel B4X founder Staff member Licensed User Longtime User Jan 11, 2013 #2 You can use RandomAccessFile or ByteConverter libraries. Upvote 0
K kkingstoun Member Licensed User Longtime User Jan 11, 2013 #3 Erel thanks for answer, but it don't help me. In Wiki and forum I have not seen information how to read individual bits. I need to read from byte 3 bit 0-6 (range 0.0 - 7F) and check boolen bit 7 - true or not. It's possible in basic4andoid? byte converter works good but i think i have got problem with sign and unsigned bits, becouse max value what's i get after conversion is 191. Last edited: Jan 11, 2013 Upvote 0
Erel thanks for answer, but it don't help me. In Wiki and forum I have not seen information how to read individual bits. I need to read from byte 3 bit 0-6 (range 0.0 - 7F) and check boolen bit 7 - true or not. It's possible in basic4andoid? byte converter works good but i think i have got problem with sign and unsigned bits, becouse max value what's i get after conversion is 191.
M MLDev Active Member Licensed User Longtime User Jan 11, 2013 #4 You could try this: Code: bits06 = Bit.AND(byte3, 0x7f) Code: Log("Bit 7 is " & getBit(byte3, 7)) ... Sub getBit(fromByte As Int, BitNo As Int) As Boolean Return Bit.ShiftRight(Bit.AND(fromByte, Power(2, BitNo)), BitNo) = 1 End Sub Upvote 0
You could try this: Code: bits06 = Bit.AND(byte3, 0x7f) Code: Log("Bit 7 is " & getBit(byte3, 7)) ... Sub getBit(fromByte As Int, BitNo As Int) As Boolean Return Bit.ShiftRight(Bit.AND(fromByte, Power(2, BitNo)), BitNo) = 1 End Sub
K kkingstoun Member Licensed User Longtime User Jan 11, 2013 #5 thanks, but how to get (separate) byte 3? I'm starting analysing data in: Sub Stream_NewData (Buffer() As Byte) Upvote 0
thanks, but how to get (separate) byte 3? I'm starting analysing data in: Sub Stream_NewData (Buffer() As Byte)
M MLDev Active Member Licensed User Longtime User Jan 11, 2013 #6 byte3 = Buffer(2) gets the third byte in the array. Upvote 0
K kkingstoun Member Licensed User Longtime User Jan 11, 2013 #7 Ok, thanks I write somethink like that, and it works. PHP: Writer.WriteLine(fala) these save me only one last line. PHP: Sub Strumien_NewData (Buffer() As Byte) Dim byte3,bits06 As Int byte3 = Buffer(3) ; It's must be 3... byte3 = Bit.AND(byte3, 0x7f) fala = byte3 Last edited: Jan 12, 2013 Upvote 0
Ok, thanks I write somethink like that, and it works. PHP: Writer.WriteLine(fala) these save me only one last line. PHP: Sub Strumien_NewData (Buffer() As Byte) Dim byte3,bits06 As Int byte3 = Buffer(3) ; It's must be 3... byte3 = Bit.AND(byte3, 0x7f) fala = byte3