1.问题
当uart接受到0x0d即‘\r’时,从驱动读出来却是0x0a
原因:UART配置问题
2.解决方法
参考下列配置方式:
options.c_cflag &= ~PARENB;
options.c_iflag &= ~INPCK;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;
options.c_oflag &= ~(BSDLY|CRDLY|FFDLY|NLDLY|OFDEL|OFILL|OLCUC|ONLRET|ONOCR|OPOST|OCRNL|ONLCR);
options.c_lflag &= ~(FLUSHO|ECHOKE|PENDIN|TOSTOP|XCASE|ECHO|ECHOK|ECHONL|ISIG|IEXTEN|ECHOE);
options.c_lflag |= ICANON;
options.c_iflag &= ~(IXON|IXOFF|IXANY|IGNCR|ICRNL|INLCR|BRKINT|IGNPAR|IMAXBEL|IUCLC|PARMRK|IGNBRK|INPCK|ISTRIP);
options.c_cc[VKILL]= _POSIX_VDISABLE;
options.c_cc[VERASE] = _POSIX_VDISABLE;
options.c_cc[VEOL] = _POSIX_VDISABLE;
options.c_cc[VEOL2] = _POSIX_VDISABLE;
options.c_cc[VEOF] = _POSIX_VDISABLE;
options.c_cc[VWERASE] = _POSIX_VDISABLE;
options.c_cc[VREPRINT] = _POSIX_VDISABLE;
参考: