We have data streaming to the serial monitor every 200ms to an Uno (and later to a Mega), and occasionally need to pause it, and restart it periodically, as the need arises.
...Ideally, it's wanted for the restart-action to just continue to add data to the existing data already-collected in the serial monitor window (rather than clearing or resetting or removing the data already-collected). (Interim data stoppage/loss during-the-pause is okay.)
...We'd like to send a string-keyword or character or number (etc) from the serial monitor window via the Send-button to initiate these separate pause and resume actions.
-Q1-: Does Anyone have any thoughts on how to do this? We've been searching around yet haven't found an answer yet... we suspect we'd need to somehow 'read' the serial monitor and evaluate the result and then take action on that, yet we've yet to figure out the basic read commands for the serial monitor etc. needed.
Any help provided is much appreciated...!
PS -Q2-: We'd also like to periodically send a string of text information from the serial monitor window and have it placed back into the data stream, as a way of 'marking events' related to the data.
(...We expect that a similar send-window 'read' and take-action process would-apply, though the 'read' would need to be of multiple characters at-once (to create the brief 'note' to insert regarding the data) than just a single character as may be used with the above first-question). It seems likely, such answer to Q1 may reveal enough to accomplish this Q2 also (except reading a string is needed/highly-desired.)...
Any insights here would be helpful as well (and much-appreciated)!!!
Well, here’s a hint to an-answer, and why rapid-responses aren’t arriving too quickly…
Looking at sheepdogguides’s sketch-functions and explanations, rather than reading things into the Arduino piecemeal as the send-button pushes the info out into the (PC's?) serial-buffer (after a Send-button mouse-click), we might try to modify sheepdogguides’s sketches so that the Arduino will watch for the serial buffer to (first) change state (using ‘available’), and then, have the Arduino monitor for some reasonable period of time to have elapsed (maybe 1 second) so to allow the serial buffer to fill-completely from the send-button-click operation, and then, have the Arduino read the filled-buffer in one move.
Then, we’ll compare the read input to a known-response being looked-for, and then when true, send it off to a function to do the pause, resume, or re-print into the serial buffer as a note, etc…
If anyone sees / knows if there’s a problem with this approach, please let me know..!
PS...“Sheepdogguides" seems to do a good job explaining why this is a bit more difficult than it might first appear, and seems worth a read… Especially a worthwhile read for those who may one day want to read and take action on info sent from the serial monitor (to the PC's{?} serial-buffer) using the Send-button…
...The key here seems to be realizing that the "Send" button just sends info to the (-PC's-..?) serial buffer, where the buffered-info waits (indefinitely) for something to act on it (or make use of it, etc); the Arduino needs to (MUST) poll (meaning "read") that buffer to see what's in it in order to make use of it -such is NOT automatically pushed thru to the Arduino-itsef (as one might be led to expect from the word "Send"); all seemingly as it is explained by sheepdogguides, and as we're currently interpreting it...
We’re closing in on it…! Will endeavor to post further info once complete…!
PS: It seems that multi-character messages sent from the buffer do need to be read in piecemeal, yet it appears there may be some elegant ways to do that..., and to handle response-actions once, read-in.