alericardi / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

serial.find stops serial.read() to work #1044

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Using serial.read() to store different inputs in a unsigned char array as 
soon as serial.available()>0 leads to misreads (elements in the array bigger 
than [0]  still filled with 0). As I found out it takes some time until all 
elements of the input are available (serial.available() returns 1 at the 
beginning, some Milliseconds later 3 ...). Therefore I would like to use 
serial.find to assure that all the elements of the input are stored in the 
buffer.

2.Define a while loop or if clause with serial.find(a char determing the end of 
the serial input) to avoid the misreads by waiting until all elements are in 
the buffer

3. In the while loop: unsigned char array array[8]=serial.read();

What is the expected output? What do you see instead?
Expected: array filled with the values send via HTerm
Instead:First element in the unsigned array is =255, every other is still 0

What version of the Arduino software are you using? On what operating
system?  Which Arduino board are you using?

Using 1.01 on Windows 7 (32bit) and Arduino Uno

Please provide any additional information below.

Thank you in advance for your feedback!

Original issue reported on code.google.com by x1angw...@gmail.com on 17 Sep 2012 at 9:27

GoogleCodeExporter commented 9 years ago
This sounds like it might be a bug in your code rather than in Serial.find(). 
Can you post your whole sketch? I'd also suggest posting it in the Arduino 
forum as you might get more help there.

Original comment by dmel...@gmail.com on 17 Sep 2012 at 11:43