Go Down

Topic: Enhanced Serial Monitor - ESM4 new error reporting system (Read 11307 times) previous topic - next topic


I have added an example of how to check if a serial port is connected and open with an Arduino. From the example help file...

Echo demonstration

This shows a method by which the Arduino can determine if it is connnected to a serial port.

One technique is to send the Arduino a message from the IDE serial monitor. However, this also requires a person to be "attached" to the IDE to make this work and it is not so easy to ensure when, if at all, the message gets sent.

The approach with ESM4 is to have the Arduino send a message back to back to the ESM which it will then respond by sending a message back to the Arduino. If the message isn't received then it isn't connected.

Download version from the first posting.

Also returned the vSerialRead function to its previous state where it didn't need to process the serial input in two different ways depending on whether you wanted support for a wireless or not wireless connection to ESM4. The parsing of the input string is now moved to _esp.cpp library function.

Cheers Ala.


I've been working on customised visualisers/scripts for a little while for very specific applications (which only pop up if the correct messages are sent to the ESM so don't expect to see any new forms unless you are involved in these projects).

I am now back on the project so if there are features that anyone thinks would be of general interest please let me know and I will add them to my list for consideration.

Also if there is something very specific to your project please also consider getting in touch with me. I may be able to help.



ESM version is now available for download from http://alanboother.co.uk/project-cafe/esm4/_ESM4.0.2.0%7B97F83AC2%7D.zip

The big change in this release is the introduction of "Projects" and a few minor changes and a bug fix or two.

A Project in ESM terms is a regularised way to write sketches, scripts, help files and reset files. The ESM will write a complete running system, including the sketch file which will compile and run without modification. This makes it easy to get started, see how to use the features of the ESM. All these files can all be modified to suit your particular project. You don't have to use the project approach and you can still just open up the ESM and use it as a smart serial monitor. Generated files come from templates which you can also modify to be more suitable to your own style.

The basic generated sketch shows how to communicate from ESM to Arduino and from Arduino to ESM, update DATA on the ESM and use it next time the Arduino sketch starts, switch the serial output on and off, automatically refresh data in the help screen which can also be used to update messages back to the Arduino…

The help files are a really convenient way to add in project support information either for end users or during development.

Each project now has its own independent DATA.

Smaller changes to the XY plot visualiser include support for the drawing commands found in the DRAW visualiser (LINE, PIE, TEXT etc) and a position cursor.

The SWP visualiser now records the data that appears in the view and may be replayed after you have adjusted the y axis scales and offsets. Useful in case you missed something important because you hadn't set the axis to the best values before capturing the data.

The main help file has been rewritten.

The folder structure has been cleaned up and so it is recommended that a clean installation into the Arduino libraries folder is carried out and then any files you may have created copied back into it.

A really convenient tweak in this release is the automatic sending of messages indicating the COM port is opened or is closing. This allows you write your sketch to perform differently whether its connected to serial input/output or not - should that be important to you.



25th June 2018

ESM version now available for download from http://alanboother.co.uk/project-cafe/esm4/_ESM4.0.3.0{E29BA8E2}.zip

THE big improvement this release is error reporting! When the ESM fails to recognise or process a message the error is reported in the main monitor form along with some information as to why it may be wrong. Also used when trying to send messages to the Arduino when the COM port isn't open. The display turns to red text when an error is noticed and a red button shows on the form making it hard to miss. Pressing the button clears the text back to default colour.

Also the directory structure has been simplified so it would be best to install this version afresh and then copy any of your own files back in.

When the ESM starts this is now a project which further simplifies the use of the ESM.

Also a couple of minor bug fixes.

I recommend you unzip the file into your Arduino library folder ersulting in a folder called _ESM4.


Hello Alan,

I have been using ESM v3 successfully for several years and just now decided to try upgrading to v4.0.3.0. I like the enhancements, especially the Project concept and the ability to put setup commands in the reset.txt file.

I wrote a simple sketch to try it out and observed a couple of issues.

-- In the reset.txt file, trying to set the Histogram interval (which I assume is the bin size) to 10, I was not able to get it to accept


or any variation on that, including upper case and other values. It gives me the error

    [EX]Check message parametersIndex was outside the bounds of the array.

-- I see that you now have a mechanism with @PORTopened and @PORTclosing to tell the sketch to stop sending data if the port is closed. I noticed that if I do not use that and just close the port so the sketch is continuing to try to send data, the ESM hangs when I re-open the port. Perhaps a buffer overflows if there is a lot of data waiting when you open the port. I have to kill ESM in the Task Manager and restart it to recover.

I am using a 32u4 based Arduino with its integrated USB controller in case that matters. A simple way to get the sketch to stop sending serial data for these processors is to use the undocumented Serial.dtr(), which returns true if the serial port is open and false otherwise.

Thanks for all your efforts on this.


I've just tried the #hist~int~10 (and other values) setting and not getting this problem. Does this problem happen if you send the message directly from the on-screen message sending entry field?

I will send you a link to the latest .exe in case it was a bug that was fixed but has yet to be released. Please let me know.

The port control messages are no more than ordinary messages to the Arduino and only have the meaning that you can see in the message handler vDoMsg(). I'm not expecting an issue here but, hey ho, stuff happens. I would expect the Arduino to not send data if the port wasn't connected irrespective of whether there is an unconnected ESM somewhere in the mix.

Try renaming these messages in vDoMsg() so they don't get invoked and let me know if it clears the problem. Also how much data is collecting in the port? Have a look at the number on the title bar of the ESM form and see if its getting big (bigger). That might be the issue.

Perhaps a 32u4  needs to be told not to send data..., I don't know, I'm not familiar with it. However I wold have though it would be a problem with the Arduino IDE's own monitor. May be someone knows something about these.



I can enter other messages in the entry line at the top of the ESM form of and hit Send and they perform the expected action. If I enter #hist~int~10 or any other value the message stream looks like this

    [EX]Check message parametersIndex was outside the bounds of the array.

I have not been able to get to work yet because I am not clear on what the directory structure and other files should be.

Go Up