You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test result:
The data was transmitted with a length of 64 bytes 20,000 times, and data loss occurred 5 times, one of which is shown in the attached picture.
loss data as follows:
<009883> 64 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
<009884> 64 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
<009885> 64 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
<009886> 64 lllllllllllllllllllllllllllllllllllllllllllllllllll
zzzzzzzzyyy
<009900> 64 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
<009888> 64 nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
<009889> 64 ooooooooooooooooooooooooooooooooooooooooooooooooooo
<009890> 64 ppppppppppppppppppppppppppppppppppppppppppppppppppp
<009891> 64 qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzzzzzzzzzzzz
<009901> 64 000000000000000000000000000000000000000000000000000
<009902> 64 111111111111111111111111111111111111111111111111111
<009903> 64 222222222222222222222222222222222222222222222222222
<009904> 64 333333333333333333333333333333333333333333333333333
The text was updated successfully, but these errors were encountered:
loverking-007
changed the title
In Linux system, continuous data transmission, it will loss data
CH343:In Linux system, continuous data transmission, it will loss data
Jul 4, 2024
please check your hardware if the uart uses TTL level or other level? the baudrate and data amount is not large for ch343, by the way, you can get serial state to check if the chip occurs hardflow when received large data.
source code:
static int set_uart_baudrate(int fd, int baudrate)
{
struct termios2 tio;
}
int set_uart_attributes(int fd, int baudrate) {
struct termios tty;
}
void test_uart_send_speed(char *pDev,unsigned int baud)
{
int sendCnt = 0;
char Buffer[65] = {0};
char tmpstr[16] = {0};
char c = '0';
int fdser = open(pDev, O_RDWR | O_NOCTTY);
int fdusb = open("/media/sda1/usb2uarttest.log", DBG_FILE_MODE);
system("echo -n "" > /media/sda1/usb2uarttest.log");
if((fdser!=-1)&&(fdusb!=-1))
{
printf("%s,%d:Start Test %s!baud=%d\n", FUNCTION, LINE, pDev,baud);
set_uart_attributes(fdser, baud);
while(sendCnt<20000)
{
sendCnt++;
memset(Buffer, c++, sizeof(Buffer));
if(c > 'z'){
c = '0';
}
Buffer[sizeof(Buffer)-2] = '\n';
Buffer[sizeof(Buffer)-1] = 0;
memset(tmpstr, 0, sizeof(tmpstr));
snprintf(tmpstr,sizeof(tmpstr),"<%06d> %d ",sendCnt,strlen(Buffer));
memcpy(Buffer, tmpstr, strlen(tmpstr));
write(fdser, Buffer, strlen(Buffer));
write(fdusb, Buffer, strlen(Buffer));
}
close(fdser);
close(fdusb);
}
}
char Dev343[] = "/dev/ttyCH343USB0";
char pDevice = Dev343;
int main(int argc, charargv[]) {
test_uart_send_speed(pDevice, 4000000);
}
test result:
The data was transmitted with a length of 64 bytes 20,000 times, and data loss occurred 5 times, one of which is shown in the attached picture.
loss data as follows:
<009883> 64 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
<009884> 64 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
<009885> 64 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
<009886> 64 lllllllllllllllllllllllllllllllllllllllllllllllllll
zzzzzzzzyyy
<009900> 64 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
<009888> 64 nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
<009889> 64 ooooooooooooooooooooooooooooooooooooooooooooooooooo
<009890> 64 ppppppppppppppppppppppppppppppppppppppppppppppppppp
<009891> 64 qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzzzzzzzzzzzz
<009901> 64 000000000000000000000000000000000000000000000000000
<009902> 64 111111111111111111111111111111111111111111111111111
<009903> 64 222222222222222222222222222222222222222222222222222
<009904> 64 333333333333333333333333333333333333333333333333333
The text was updated successfully, but these errors were encountered: