Thanks for the reply Paul.
Apologies for the poor coding - I'm not a trained programmer. I'm a newbie to Arduino programming and to this forum, and I'm hoping for some constructive expert guidance in what is proving to be a difficult problem for me to implement on an Arduino.
Not a single recognized coding style accepts ANYTHING on the line after the {
I'm not impressed with your attempt to invent a new one."
Not intentional - wish I had the skill to invent a new coding style
Probably because I've come from a background in Python rather than C, I'm aware my formatting leaves a lot to be desired.
As I'm sure you know, Python formatting is based around indents rather than curly brackets, so I'm still getting to grips with the new conventions associated with programming the Arduino.
Here's a clue:
Code:
Serial.begin(9600,SERIAL_8N1); //
Serial1.begin(19200,SERIAL_8E1);
Sending data out slower than you read it in isn't a good idea.
Apologies - I should have clarified: All the data is being read in from an external device via a RS232-TTL converter attached to the Serial1 Rx pin of the Mega. Once I can read & parse the data properly from Serial1, I plan to send it out to another device via Serial2.
I'm just using using Serial as a temporary measure to communicate details of variables and program flow via the USB cable back to a laptop running the Arduino Serial Monitor, so I can debug my code. It's not intended to be part of the final implementation.
I thought that Serial, Serial1, Serial2 and Serial3 were completely independent, and therefore could run at different speeds without causing conflict, so left Serial at the slower default settings. If I understand you correctly though, you're saying that by not setting both serial ports to the same speed, I may be causing problems.
Thanks for this suggestion. Will try increasing Serial to 19200 baud and see if this helps.
Using do/while in place of a normal while loop is rarely a good idea.
I haven't used "Do-while" loops much previously: they are not available in Python; but I thought it was the appropriate construct in the places that I've used it here - i.e. where a block of code had to be run through at least once before checking the condition. However if it is likely to cause problems (?particularly if there are nested do-while loops), I'm happy to try and re-write this using "while" instead.
Thanks again for your advice Paul.
I'd be very grateful for any further helpful suggestions & guidance from the forum.
BW
Dave