Closed jpagliaccio closed 1 year ago
That seems unusual. Unfortunately I don't have access to an Arduino so am unable to confirm. It's also been a while since I've done serious performance testing. Totally possible something is messed up in the code.
But I'm 90% sure that I've gotten sub 50ms at that baud rate. I want to say around 2-3ms... That would've been using the GPIO UART port on a Raspberry Pi 3b and an Arduino Mega 2560.
What is your set up?
I just noticed this line:
https://github.com/n-wach/camino/blob/main/camino/__init__.py#L94
time.sleep(0.05)
That must be the cause, and I’m not sure why it’s there. Any chance you could try with that line removed?
Thanks. The response was always a consistent 50 ms. Very suspicious. I was grepping 5's this morning and found the same.
Removing line 94 from init.py gives a healthy 4 ms response time. It looks the same (4 ms) for each of the functions (eg: analog_read or pin_mode). I did not find any other delays or sleeps.
So the results now:
at 19,200 baud I get 10 ms per function call
at 115,200 is 4 ms
over 115,200 (eg: 150,000) same 4 ms
over 150,000 returns " nothing sent"
I will test some more today to make sure everything is working.
Thanks again.
Ps: I may try to read more than one pin at a time, like Modbus to see how that behaves.
For multiple reads, this callable is working w/o much of a performance hit
// -----------------------------------------------------------
// Return 6 analog values in a comma separted string
// Py read with atup = arduino.multiAnalog(out=str).split(',')
// -----------------------------------------------------------
void multiAnalog(byte dataLength, byte *dataArray) {
char pubString[256] = "";
a0 = analogRead(A0);
sprintf(pubString, "%d,%d,%d,%d,%d,%d", a0, a0, a0, a0, a0, a0);
returns(pubString);
}
Awesome! I'll push an update.
Thanks for the help, and let me know if you find any other issues
It looks like each communication takes 50 ms. Is that what you see? Any way to speed that up? Here is the Python code. I am on an Arduino MEGA 2560 at 115200 baud with your default ino file and just the baud rate changed.
Thanks for sharing the code and your help.