Я не могу получить все байты, которые я посылаю. (Raspberry Pi 3B + / Raspbian)
Я попытался отправить 4000 байтов и получить только 960 байтов на скорости 9600 бит / с. Когда я увеличил скорость, увеличил полученные байты. Я пытаюсь установить значения VTIME и VMIN в массиве c_cc, но не изменить все.
Как я могу получить все байты?
transmitter:
char write_buffer[4000]; /* Buffer containing characters to write into port */
for(uint32_t i=0;i<4000;i++)
{
write_buffer[i] = i;
}
int bytes_written = 0; /* Value for storing the number of bytes written to the port */
bytes_written = write(fd,write_buffer,sizeof(write_buffer));/* use write() to send data to port */
/* "fd" - file descriptor pointing to the opened serial port */
/* "write_buffer" - address of the buffer containing data */
/* "sizeof(write_buffer)" - No of bytes to write */
printf("\n %s written to ttyUSB0",write_buffer);
printf("\n %d Bytes written to ttyUSB0", bytes_written);
printf("\n +----------------------------------+\n\n");
receiver:
/*------------------------------- Read data from serial port -----------------------------*/
char read_buffer[4000]; /* Buffer to store the data received */
uint32_t bytes_read = 0; /* Number of bytes read by the read() system call */
int i = 0;
bytes_read = read(fd,&read_buffer,4000); /* Read the data */
printf("\n\n Bytes Rxed: %d", bytes_read); /* Print the number of bytes read */
printf("\n\n ");
for(i=0;i<bytes_read;i++) /*printing only the received characters*/
printf("%c",read_buffer[i]);
printf("\n +----------------------------------+\n\n\n");
выход:
+----------------------------------+
| Serial Port Write |
+----------------------------------+
ttyUSB0 Opened Successfully
BaudRate = 9600
StopBits = 1
Parity = none
written to ttyUSB0
4000 Bytes written to ttyUSB0
+----------------------------------+
Bytes Rxed: 960
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~������������������������������������������������������������������������������������������������������������������������������
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~������������������������������������������������������������������������������������������������������������������������������
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~������������������������������������������������������������������������������������������������������������������������������
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~��������������������������������������������������������������
+----------------------------------+