|
背景:贴上部分代码
void* serial_thread() {
int fd = open_dev(SERIALPORT_PATH);
if (fd <=0) {
printf("open '%s' failed %d!\n", SERIALPORT_PATH, fd);
close(fd);
return NULL;
}
printf("open %s seccuss\n", SERIALPORT_PATH);
if (set_speed(fd, SERIALPORT_SPEED) == -1) {
close_dev(fd);
return NULL;
}
printf("set speed %d seccuss\n", SERIALPORT_SPEED);
int write_times = 0;
char write_buf[1024];
while (test_running && write_times++ < test_times) {
if (write_flush) {
tcflush(fd, TCIOFLUSH);
usleep(flush_time * 1000);
}
memset(write_buf, 0, sizeof(write_buf));
sprintf(write_buf, "%s_%d\n", send_data, write_times);
int write_len = write(fd, write_buf, strlen(write_buf));
printf(" write len = %d, str = %s\n", write_len, write_buf);
usleep(sleep_time * 1000);
}
close_dev(fd);
return NULL;
}
客户反馈使用串口向外部设备发送数据,在每次发送数据前如果使用tcflush(fd, TCIOFLUSH)清空缓存,则会导致发送的数据出现错乱,错乱的图片见附件。
解决办法:关闭对应串口dma传输
apuart1: serial@11003000 {
compatible = "mediatek,mt6577-uart";
reg = <0 0x11003000 0 0x1000>;
interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
clocks = <&clk26m>, <&infracfg_ao CLK_IFR_UART1>;
clock-names = "baud", "bus";
- dmas = <&apdma 2
- &apdma 3>;
- dma-names = "tx", "rx";
};
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|