I write programs for a pair of the Raspberry Pi Pico W boards, and one side recive the data(Texts) from the serial port, then encrypted it and send to another board with socket. Another side recive it and decrypt it.
The encrypt process will take about 350ms each 85 bytes, the transfer side's program of read serial data like this
// Recive serial port's data and encrypt it
if (Serial.available() > 0)
{
// Check pending size in the serial buffer
int r_bytes = Serial.available();
#ifdef DEBUG
Serial.printf("Need transfer %d bytes.\n", r_bytes);
#endif
#ifdef SHOWBUF
Serial.printf("\n===%d===", r_bytes);
#endif
// Create buffer
uint8_t rbuffer[85] = {0};
// Empty buffer
std::fill_n(rbuffer, sizeof(rbuffer), 0);
if (r_bytes >= 85)
r_bytes = 85;
Serial.readBytes(rbuffer, r_bytes);
unsigned char enc_buf[128] = {0};
// Empty buffer
std::fill_n(enc_buf, sizeof(enc_buf), 0);
ret = mbedtls_rsa_pkcs1_encrypt(
mbedtls_pk_rsa(depk),
mbedtls_ctr_drbg_random,
&drbg,
MBEDTLS_RSA_PUBLIC,
r_bytes,
rbuffer,
enc_buf
);
// ...(Sign and transfer process)
I originally use Tera Term to monitor and feed data, but seems like the Tera Term will repeat duplicate data at the transfer side(but when the data small enough it will not occur), and the reciver side also recives the duplicate data repeatly.
But the PuTTY and the Arduino IDE can handle the data very well.
The Serial Setting of Tera Term and PuTTY are the same, the development environment I use VSCode and the platform IO IDE, maybe some setting of Tera Term I missed and cause this problem?