
Originally Posted by
nagabathula
Hello thank you for replying,
i am actually pushingback that data from the sqlite db where i have saved all the data after aligning and bitshifting.. Now i need to remove the frame id in order to save only the channel data. the frame id is 6 bytes in size 03b702200001 after which 20 bytes is data after which is 6 bytes of frame id again
No it isn't if your example data is anything to go by. Expressed as a hexadecimal string with bytes numbered:
// 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3
// 0 1 2 3 4 5 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
-- 03b702200001 00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de
-- 03b702200002 00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de
// 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3
// 0 1 2 3 4 5 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
-- 03b702200001 00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de
-- 03b702200002 00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de
To copy to clipboard, switch view to plain text mode
There are 40 bytes after the 6-byte header.
i have to remove those 6 bytes and save the next 20 bytes this cycle goes on, i could't use QStringPattern to remove the frameID cause the frame id increments after every 20 bytes so the string patter would change.
Nobody suggested you use "QStringPattern", primarily because it does not exist in Qt.
i need to think about a logic to remove 6 bytes and save 20 bytes remove the next 6 and save 20 bytes again and so on.. Which i am not able to figure out i tried looking for a similar example but din find.
You certainly do need to think about the logic. You don't need to remove anything in order to access a subsection from the middle.
I actually though evey thing wud be in Bytes in QByteArray but its taking for example
"1d" as 2 chars i think then a single byte. thats why i got a lil confused with it,.
Everything in a QByteArray is a byte. The string "1d" is two characters, and in a QByteArray each ASCII character is represented by a byte. You are going to really struggle with this low-level byte manipulation until you grasp the difference between the value in a byte (a binary number) and the representation of that value in human-readable form (whether hexadecimal, octal, decimal, or base64). This is not the place to learn that.
Answer these questions for yourself:
What are you working on: an array of the actual bytes, or a hexadecimal string representing the bytes?
What are you trying to obtain: an array of the actual desired bytes or a hexadecimal string representing the bytes?
How many bytes, or hexadecimal characters if using a string, are there?
How can the functions already pointed out in this thread access parts of the byte array (or string)?
Bookmarks