samm_flynn
Active member
I’m using a Teensy 4.1 and need to transfer large amounts of data in a duplex manner. I have a few questions:
Is it normal for send_now() to be slower speed when writing full 512-byte chunks, or is there something wrong with my code?
My best observed speeds:
PC -> Teensy: 7.38 MB/s (using PySerial)
Teensy -> PC: 20.97 MB/s (without send_now())
I’m running this on a high-performance gaming laptop with two separate processes (not threads) for communication.
Could Windows overhead be the bottleneck here?
(I'm not necessarily looking for higher speeds—just curious why it’s capped so much lower than the theoretical max. I am using
BAUD_RATE = 4608000 in python.)
3. Structured Data Over Serial
I need to send and receive C-style structs over serial between PC and Teensy.
Are there any existing frameworks or libraries that handle this nicely?
I’m currently implementing my own data layer, but it’s time-consuming. Ideally, I’d like a library that:
-Fragments & reassembles large data packets (e.g., SQN numbers, CRC, etc. all the data layer black magic.)
-Handles error detection.
Does anything like this exist for Teensy/Arduino?
4.I need to send and recieve Structs over Serial from PC to teensy . Is there already any framework that does this nicely.
- Is this fantastic library by @Frank B hardware accelerated? I want to use it for CRC32 calculation.
Apologies in advance if there is any mistake in my calculations. Not very good at maths.
Thanks in Advance.
1. Performance of Serial.send_now()
I noticed that using Serial.send_now() reduces my data transfer speed. Specifically:- Without send_now(): 20.97 MB/s
- With send_now(): 10.26 MB/s
- Chunk size = 512 bytes, payload size = 293,472 bytes
C++:
void sendBinaryPayload(uint8_t *payload, size_t payloadSize, size_t chunkSize) {
size_t bytesSent = 0;
while (bytesSent < payloadSize) {
size_t currentChunkSize = min(chunkSize, payloadSize - bytesSent);
Serial.write(&payload[bytesSent], currentChunkSize);
// without send_now ->Data Transfer Speed: 20.97 MB/s.Payload Size : 293472 bytes | Time taken 0.0133486s. totalBytesRead=293472
// Serial.send_now();
// Data Transfer Speed: 10.26 MB/s. Payload Size : 293472 bytes | Time taken 0.0272901s. totalBytesRead=293472
bytesSent += currentChunkSize;
}
}
2. USB Speed Limitations
The Teensy 4.1 supports USB 2.0 High-Speed (480 Mbps = 60 MB/s), but I never reach anywhere close to that.My best observed speeds:
PC -> Teensy: 7.38 MB/s (using PySerial)
Teensy -> PC: 20.97 MB/s (without send_now())
I’m running this on a high-performance gaming laptop with two separate processes (not threads) for communication.
Could Windows overhead be the bottleneck here?
(I'm not necessarily looking for higher speeds—just curious why it’s capped so much lower than the theoretical max. I am using
BAUD_RATE = 4608000 in python.)
3. Structured Data Over Serial
I need to send and receive C-style structs over serial between PC and Teensy.
Are there any existing frameworks or libraries that handle this nicely?
I’m currently implementing my own data layer, but it’s time-consuming. Ideally, I’d like a library that:
-Fragments & reassembles large data packets (e.g., SQN numbers, CRC, etc. all the data layer black magic.)
-Handles error detection.
Does anything like this exist for Teensy/Arduino?
4.I need to send and recieve Structs over Serial from PC to teensy . Is there already any framework that does this nicely.
- Is this fantastic library by @Frank B hardware accelerated? I want to use it for CRC32 calculation.
Apologies in advance if there is any mistake in my calculations. Not very good at maths.
Thanks in Advance.