I am using serial module to get data from a rs232 device, and the device is could only send its data to serial port ,but could not accept any request. the problem is I don’t know when the data will be send,so I need to listen the serial constantly to avoid lose any data. but unfortunately, there are no any event trigger on serial component in ignition . dose anyone meet the same problem and could give some help? (I’m using ignition 7.7.5)
I put scripts on a timer , but datas always losed,and after some time, there is an error “could not creat any more thread”
This is actually a rather challenging task, requiring a background thread constantly listening to the serial port. You might find inspiration in this example: clientserial.py.
I would consider converting the serial output to TCPIP using a serial to ethernet converter; then you can just use Ignition’s TCP device to connect to the ip:port on the converter to listen for data events.
I have used Lantronix UDS1100 for this purpose before.
I think it is time to get your device online. Get yourself a Lantronix or Digi SP One device and start moving that data over Ethernet. My solution would be to configure a UCON driver in Kepware and create a transaction block representative of the data you are trying to receive. Your device will now become a OPC UA device, reachable from Ignition.
You can also check out the Instrument Interface module from Sepasoft (https://www.sepasoft.com/products/instrument-interface/serial-communications/) it has a component that can handle incoming data and monitoring the report. We used it to capture data from 3 serial devices where the data trigger was independent from Ignition (unsolicited data).
Thanks for everyone. I have resolved the problem in a indirected way. I put the code in a button’s actionPerformed event. the program will call itself again when the invokeLater() completed.
How are you using the Instrument Interface to continuously monitor the Serial Port? I am used to Rockwell Serial port functions where I can “test” the serial port for CR and once found then I can read the serial port. I am trying to do the same thing in Ignition where I test the serial port until CR characters then read the Serial port till the CR character. (see attached screen cap)
I am not sure what unsolicited requests means? I might also just experiment with Polled request at super fast rate?
I’m not using Instrument Interface , I think @pturmel have given a perfact way to continuously monitor the serial port data.
If you would still consider putting those serial devices on the network, grab a Raspberry Pi and run ser2sock (https://github.com/nutechsoftware/ser2sock); then add a new TCP device to Ignition and point it to the port on the Pi where your socket is listening on.
That’s a great idea! And use Java commands to record the data?
Well, you wouldn’t even need to go that complex. The TCP driver would be the perfect fit to turn that stream out of the TCP socket into tags: