Read Serial Port Continuous, Timer Script and Instrument Interface

This Project file is far from complete. It can be used as a starting point for others. I have some questions below. My goal is to write a Ignition Client so a User can plug their laptop into a Mettler Toledo XS lab scale using an USB to Serial converter. There's a Reset Scale button that sends a "@" to reset the Scale. Also a Weight Button to send a "SIR" to make the scale report its weight continuously.

I did not know how to make Ignition event driven based on new data at Serial Port. With Rockwell PLC instructions I can test the Serial buffer for CR, then Read the entire buffer including the CR. Is there a similar Serial Buffer Test in Ignition or in the Instrument Interface? So I had to use a Timer script, the 1-10ms interval appears to work.The Timer script uses a readUntil('\r',0,100) to read until the CR that the SerialTest (2018-02-09)Timer Script.proj (17.7 KB)

At least this project handles Opening, Closing of Serial Port and a few buttons to handle Resetting Scale or making it Report its weight Continuously.

I need to figure out the console exceptions it throws below based if data is not at Serial port it will throw the following

Caused by: java.lang.Exception: Exception encountered while reading from serial port: Delimiter not matched before timeout/EOS.
_ at com.sepasoft.parse.components.PMISerialController.readUntil(
_ at sun.reflect.GeneratedMethodAccessor126.invoke(Unknown Source)_
_ at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)_
_ at java.lang.reflect.Method.invoke(Unknown Source)_
_ at
... 14 common frames omitted

I could live with the Above Exception on the console. I need to write some other code to check for Serial Port is Open or Closed before I try to write out of that port.

For others finding this topic, see this older thread.

Thanks Turmel. I will have to dig into that code you posted.

I was hoping some one would get back to me on how to configure the Instrument Interface to do this Continuous Serial Port monitoring. I believe its a feature(Accept Unsolicited Request) of Instrument Interface based on what I heard at the 2:00 min mark from this video.

The company I work for has already purchased an Instrument Interface license, I will try to give Sepasoft a call. See if they solved this problem or I have to do the custom code solution.

I got some help from SepaSoft and they pointed me in the direction of using Unsolicited Reads to constantly monitor the serial port. They also recommended to make sure I do not have Polling turned on. I dropped some code into the onReceive() event in the Serial Controller based on SepaSoft recommendation. The event.stringData was what I was missing.SerialTestUnsolicited (2018-02-13).proj (32.1 KB)

rr = event.stringData
print rr

I have attached a Demo project to pull data from a Mettler Toledo XS Balance. This demo project should work with any Mettler Toledo scale that uses the MT-SICS command set. The project uses the @, SIR, UPD commands to Reset, Continuously Output, and Change Update Rate.

I had to turn down the Update Rate on the Scale from 10 Updates a Second to 4.5 Updates a second so that the Instrument Interface could read in each weight string as an individual string and not a long string of multiple weights.