串口收到的信息
c[2J[10r[11;1H7[10r[1;1H[2KBLE Central87[10r[2;1H[2K0xB0912269F97B87[10r[3;1H[2KInitialized87[10r[6;1H[2KDiscover ->87[10r[3;1H[2K87[10r[4;1H[2K87[10r[6;1H[2KDiscover ->8
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
串口收到的信息
c[2J[10r[11;1H7[10r[1;1H[2KBLE Central87[10r[2;1H[2K0xB0912269F97B87[10r[3;1H[2KInitialized87[10r[6;1H[2KDiscover ->87[10r[3;1H[2K87[10r[4;1H[2K87[10r[6;1H[2KDiscover ->8
昨天我浏览SDK代码时发现以下代码:
/* -----------------------------------------------------------------------------
* Constants and macros
* -----------------------------------------------------------------------------
*/
#ifndef MIN
# define MIN(n, m) (((n) > (m)) ? (m) : (n))
#endif
#define DISPLAY_UART_ESC_INITIAL "\x1b\x63" /* Reset terminal */ \
"\x1b[2J" /* Clear screen */ \
"\x1b[10r" /* Scrolling region from line 10 */ \
"\x1b[11;1H" /* Set initial cursor to line 11 */
#define DISPLAY_UART_ESC_MOVEPOS_FMT "\x1b\x37" /* Save cursor position */ \
"\x1b[10r" /* Retransmit scroll */ \
"\x1b[%d;%dH" /* Move cursor fmt str */
#define DISPLAY_UART_ESC_RESTOREPOS "\x1b\x38" /* Restore saved cursor pos */
#define DISPLAY_UART_ESC_CLEAR_SCREEN "\x1b[2J" /* Clear screen */
#define DISPLAY_UART_ESC_CLEAR_CUR_LEFT "\x1b[1K" /* Clear cursor left */
#define DISPLAY_UART_ESC_CLEAR_CUR_RIGHT "\x1b[0K" /* Clear cursor right */
#define DISPLAY_UART_ESC_CLEAR_BOTH "\x1b[2K" /* Clear line */
#define DISPLAY_UART_ESC_CLEARSEQ_LEN 4
原来这些字符串不是乱码而是VT100终端控制码,因为我使用的终端不支持控制码所以导致出现乱码,后来改用screen命令就不会有乱码了。
所以和波特率没有关系,换一个支持终端控制码的终端就可以解决这个问题。