laptophead
Well-known member
Using Teensy 3.5 Serial1. Are all the Serial ports buffered? Is there an advantage in using 1,2.3 or another?
I am talking to motor with a built in encoder. I am sending commands and the motor controller replies in transmissions varying from 5 to 18 hexadecimal numbers, each made of 2 digits.
I found this method to work well:
It is populating my array accurately.
The problem is that I get a 18 bytes, or 12 bytes or 10 bytes transmission and that is not working since I am aways waiting for 7 bytes.
If I always wait for 18 bytes, the shorter transmission don't get logged....
So ideally I would:
- Count the bytes
- execute the function to populate my array.
- clean the buffer for the next show.
I am not that sharp at this, please help.
(please note, each byte comes in a new line)
Thanks
Mitch
I am talking to motor with a built in encoder. I am sending commands and the motor controller replies in transmissions varying from 5 to 18 hexadecimal numbers, each made of 2 digits.
I found this method to work well:
HTML:
while (Serial1.available() >=7 ) // serial will wait for "Bytes_In_A" before
{
for (int n = 0; n < 8; n++)
{ in_bytes[n] = Serial1.read();
} // end of for loop
It is populating my array accurately.
The problem is that I get a 18 bytes, or 12 bytes or 10 bytes transmission and that is not working since I am aways waiting for 7 bytes.
If I always wait for 18 bytes, the shorter transmission don't get logged....
So ideally I would:
- Count the bytes
- execute the function to populate my array.
- clean the buffer for the next show.
I am not that sharp at this, please help.
(please note, each byte comes in a new line)
Thanks
Mitch