anchao opened a new pull request #2574: URL: https://github.com/apache/incubator-nuttx/pull/2574
## Summary libs/libc/dumpbuffer: add support to dump the buffer to file descriptor. libs/libc: add lib_dumpvbuffer support libs/libc/dumpbuffer: remove the unnecessary printable characters traversal libs/libc/dumpbuffer: fix nxstyle warning libs/libc/dumpbuffer: add support to recognizable from wireshark e.g: Encapsulation Type: Bluetooth H4: add packet type dump support From: `lib_dumpvbuffer(NULL, data, len);` ``` [ 2.196000] 0000: 030c00 ... [ 2.514600] 0000: 0e0401030c00 ...... [ 2.514600] 0000: 031000 ... [ 2.517600] 0000: 0e0c01031000ffff8ffedbff5b87 ............[. [ 2.517600] 0000: 011000 ... [ 2.520600] 0000: 0e0c0101100006bb22060a00bb22 ........"...." [ 2.520600] 0000: 021000 ... [ 2.527600] 0000: 0e4401021000ffffff03feffffffffff fffff30fe8fe3ff783ff1c00000061f7 .D.............. ......?.......a. [ 2.527600] 0020: ffff7f00000000000000000000000000 00000000000000000000000000000000 ................ ................ [ 2.527600] 0040: 000000000000 ...... ``` To: ``` struct iovec bufs[2]; bufs[0].iov_base = &type; bufs[0].iov_len = 1; bufs[1].iov_base = data; bufs[1].iov_len = len; lib_dumpvbuffer(NULL, bufs, 2); ``` ``` [ 3.711400] 0000 01 03 0c 00 .... [ 4.035400] 0000 04 0e 04 01 03 0c 00 ....... [ 4.035400] 0000 01 03 10 00 .... [ 4.037400] 0000 04 0e 0c 01 03 10 00 ff ff 8f fe db ff 5b 87 .............[. [ 4.037400] 0000 01 01 10 00 .... [ 4.039400] 0000 04 0e 0c 01 01 10 00 06 bb 22 06 0a 00 bb 22 ........."...." [ 4.039400] 0000 01 02 10 00 .... [ 4.046400] 0000 04 0e 44 01 02 10 00 ff ff ff 03 fe ff ff ff ff ..D............. [ 4.046400] 0010 ff ff ff f3 0f e8 fe 3f f7 83 ff 1c 00 00 00 61 .......?.......a [ 4.046400] 0020 f7 ff ff 7f 00 00 00 00 00 00 00 00 00 00 00 00 ................ [ 4.046400] 0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ [ 4.046400] 0040 00 00 00 00 00 00 00 ....... ``` ## Impact ## Testing ``` struct iovec bufs[2]; bufs[0].iov_base = &type; bufs[0].iov_len = 1; bufs[1].iov_base = data; bufs[1].iov_len = len; int fd; fd = open("/data/hci.dump", O_RDWR| O_CREAT | O_APPEND, 0777); if (fd > 0) { pthread_mutex_lock(&g_mutex); lib_writevbuffer(fd, NULL, bufs, 2); pthread_mutex_unlock(&g_mutex); close(fd); } ``` ``` $ cat hci.dump 0000 01 03 0c 00 .... 0000 04 0e 04 01 03 0c 00 ....... 0000 01 03 10 00 .... 0000 04 0e 0c 01 03 10 00 ff ff 8f fe db ff 5b 87 .............[. 0000 01 01 10 00 .... 0000 04 0e 0c 01 01 10 00 06 bb 22 06 0a 00 bb 22 ........."...." 0000 01 02 10 00 .... 0000 04 0e 44 01 02 10 00 ff ff ff 03 fe ff ff ff ff ..D............. 0010 ff ff ff f3 0f e8 fe 3f f7 83 ff 1c 00 00 00 61 .......?.......a 0020 f7 ff ff 7f 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0040 00 00 00 00 00 00 00 ....... 0000 01 18 20 00 .. . 0000 04 0e 0c 01 18 20 00 28 82 d5 c1 83 a8 20 77 ..... .(..... w 0000 01 18 20 00 .. . 0000 04 0e 0c 01 18 20 00 f5 31 c2 34 59 9a 24 02 ..... ..1.4Y.$. 0000 01 18 20 00 .. . 0000 04 0e 0c 01 18 20 00 16 f2 89 c9 7e a5 2d 98 ..... .....~.-. 0000 01 18 20 00 .. . 0000 04 0e 0c 01 18 20 00 55 e4 ca c0 b9 24 a2 17 ..... .U....$.. 0000 01 18 20 00 .. . 0000 04 0e 0c 01 18 20 00 af 06 97 87 b2 e2 f8 b6 ..... ......... 0000 01 33 0c 07 4a 00 00 06 00 00 00 .3..J...... 0000 04 0e 04 01 33 0c 00 ....3.. 0000 01 31 0c 01 01 .1... ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org