I uploaded the code from IDE, then run the following command on host to save the serial port /dev/ttyACM0 stream binary data into file ImuData.txt:
(stty raw; cat > ImuData.txt) < /dev/ttyACM0
The ImuData.txt is dumped below. The serial port stream has 32 records with 14 byte/record. The data in ImuData.txt starting from address 0x700D (ba 02 ...) is from the last run of Arduino code, all of the data before address 0x700D is leftover from previous run of the same Arduino code.
How can I avoid the leftover from previous run of the same Arduino code? I have used Serial.print() for text data and get the same problem.
Thanks, Wei
00000000: ba02 fcff f2ff feff b4f2 bae5 bdf3 021c ................
00000010: 003e fff4 ff4e f9b8 f2c5 f9de 02e8 fffc .>...N..........
00000020: feec ff46 f9b4 f2f1 f9df 0207 0026 ff03 ...F.........&..
00000030: 0042 f9b4 f2d0 f9e1 0225 004a ff03 005d .B.......%.J...]
00000040: f9a5 f2d6 f9e2 020b 0053 fff4 ff79 f9aa .........S...y..
00000050: f2c4 f9e3 02f6 ff27 ffdf ff5e f9ba f2cf .......'...^....
00000060: f9e4 02d7 ff53 ff03 004d f9af f2d0 f9e5 .....S...M......
00000070: 02ff ff2f ffef ff56 f9b5 f2c8 f9ba 0201 .../...V........
00000080: 00f5 fffb ffae f284 e58f f3c0 02f2 ff9b ................
00000090: ffd3 ff68 f9ae f2d0 f9c1 02e1 ffb0 ff85 ...h............
000000a0: ff5b f9b4 f2dd f9c3 02dd ffa8 ffba ff50 .[.............P
000000b0: f9b7 f2c4 f9c4 02f7 ff7d ffb8 ff52 f99c .........}...R..
000000c0: f2e9 f9c5 02e7 ff48 ffb5 ff51 f9c0 f2c6 .......H...Q....
000000d0: f9c6 0201 00aa ffa8 ff5a f9a6 f2e0 f9c7 .........Z......
000000e0: 021c 0083 ffee ff5f f99e f2c2 f9c9 0212 ...............
000000f0: 0064 ffe4 ff67 f9b2 f2ef f9ca 02f3 ff55 .d...g.........U
00000100: ffc0 ff53 f9b0 f2d8 f9cb 02f4 ff86 ffda ...S............
00000110: ff58 f9b7 f2d4 f9cc 0222 00bc ffe8 ff4f .X.......".....O
00000120: f9ae f2e0 f9cd 020e 00ac ffb6 ff55 f9b0 .............U..
00000130: f2d7 f9cf 020e 0051 ffe0 ff6c f9ab f2bb .......Q...l....
00000140: f9d0 0218 0034 ff02 005a f9a8 f2c9 f9d1 .....4...Z......
00000150: 02ff ff5f ffc0 ff4e f9a7 f2da f9d2 02e5 ......N........
00000160: ff95 ffb9 ff58 f9b3 f2c8 f9d4 02cf ff7c .....X.........|
00000170: ffc7 ff6c f9b1 f2a0 f9d6 02c8 ff49 ffb7 ...l.........I..
00000180: ff5e f9b1 f2cf f9d7 02cd ff3d ff91 ff4c .^.........=...L
00000190: f9b8 f2dd f9d8 02ef ff57 ffba ff65 f9b4 .........W...e..
000001a0: f2bf f9d9 0214 00a2 ffa7 ff4a f9ad f2e7 ...........J....
000001b0: f9db 0205 007e ffd0 ff62 f9b0 f2cd f9dc .....~...b......
000001c0: 02d5 ff52 ffa8 ff3b f9af f2de f9dd 0201 ...R...;........
000001d0: 003e ffba ff43 f9be f2d3 f9de 0209 005e .>...C.........^
000001e0: ffb2 ff50 f9a8 f2ce f9df 02ba ff61 ffaf ...P.........a..
000001f0: ff60 f99e f2ba f9e1 02e7 ff59 ffcd ff72 .`.........Y...r
00000200: f9b3 f2c3 f9e2 02eb ff47 ffbc ff52 f9a2 .........G...R..
00000210: f2bd f9e3 02f4 ff62 ffd2 ff58 f9ae f2da .......b...X....
00000220: f9e4 02eb ffa7 ffc7 ff4b f9b0 f2d7 f9e5 .........K......
00000230: 02fb ff6b ffc8 ff4b f9a5 f2d1 f9 ...k...K.....