SerialSoftware available() question

Hi,

I’m working on modification of the James’es library (http://forum.arduino.cc/index.php?topic=118988.0)
to make it compatible with another radio.

The main concern for me is the part of library and would like to know how does it really work:

while (rigCat.available() < 5 && elapsed < 2000) {
elapsed = millis() – timeout;
;}

This part of code is putted before the serialSoftware.read() command takes place.

My issue is that if I change these two values (5 and 2000) sometimes expected incoming bytes are fine but not completely, sometimes incoming bytes are bad, but the lenght is ok and so.
When this part is remove, the data won’t come at all.

I would like to know how does it really work and what it is responsible for.

I will be appraciate for any hints.

Regards,
Jakub/SP5TOF

That while spins for 2 seconds, unless 5 bytes of data arrive before 2 seconds is up.

I can not imagine why a different radio would require changes to that part of the code.

Hi PaulS,

thank you for explanation. Now it's a liitle bit more clear for me.

If I get the positive results, I'll share it here.

Regards,
Jakub/SP5TOF

Software serial seems to yield widely varying results.

It's rather flaky, as software serial always seems to be (I've read hardware documentation for modules mentioning an option to put a delay after every byte so software serial implementations don't have trouble with the output...). Is the software serial the thing that's communicating with the radio?

If not, I'm not sure why it wouldn't work.

DrAzzy:
Software serial seems to yield widely varying results.
It's rather flaky, as software serial always seems to be (I've read hardware documentation for modules mentioning an option to put a delay after every byte so software serial implementations don't have trouble with the output...). Is the software serial the thing that's communicating with the radio?

If not, I'm not sure why it wouldn't work.

You have put it very nicely.

And since I am not interested in another firestorm telling me that I have no clue what I am talking about I'll just second your opinion - SoftwareSerial.available() is flaky.

DR OM do not use SoftwareSerial.available() in this fashion 73

.