I have a windows program (my own software) getting a constant stream of data from a Mega via the Serial Port with a simple, "Serial.println(dataStr);" to the PC com port.
The PC program sometimes needs to do stuff, so I'd like the PC to be able to pause the incoming stream for about half a second. I don't mind losing some data stream as it is very repetitive and any gaps would be minor, maybe half a second or so.
How can I get the the Mega to pause sending? Is there a DSR or something that does not trigger a reboot of the Mega?
If I close the incoming Port, then it reboots the Mega when I open it again, which I definitely do not want.
I have a windows program (my own software) getting a constant stream of data from a Mega via the Serial Port with a simple, "Serial.println(dataStr);" to the PC com port.
The PC program sometimes needs to do stuff, so I'd like the PC to be able to pause the incoming stream for about half a second. I don't mind losing some data stream as it is very repetitive and any gaps would be minor, maybe half a second or so.
How can I get the the Mega to pause sending? Is there a DSR or something that does not trigger a reboot of the Mega?
If you are the programmer of the software at both ends of the communication, you could use
In case the PC wants a pause, then PC sends an decimal ASCII-19 byte
And for resume transmission, the PC sends decimal ASCII-17 character
The Arduino program just has to act accordingly to receiving ASCII-19 and ASCII-17.
The USARTs on the Atmega chips do not support hardware handshaking.
The simplest thing (IMHO) is to have the Arduino wait until it receives a request from the PC before sending a message. That could be a simple as having the PC send "" meaning "more". Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.
Thanks to both of you. Good suggestions, I thought there might be a built in Xon/Xoff with the Arduino somewhere.
The data stream coming into the Arduino by an NRF24L arrives randomly and some data the Arduino responds to and sends stuff out on another NRF24L, but all of it goes out the Serial for the PC, so it gets complicated as I never know when "more" is expected.
I will add in an "IamBusy" process in the PC software and just miss any incoming stuff while "busy." Finding the start of the next full string of data will be a little tricky as it can come in fast, strong and long.
I do have several different types of EOL terminators on the data stream from the Arduino, so I can look for one of those. It is all doable, I just thought there might be an easy way already available before spending time and find I have reinvented the wheel.
In my experience the PC is so much faster than an Arduino and has so much memory in which it can buffer incoming data that I have never had a problem with keeping up with my Arduinos. I suspect your PC program needs to be re-considered - but I am not offering to help with that.