TCP Listener which Parses XML (in this example, from an OptoEMU Sensor)

Hi OptoFans,

On several occasions, I’ve wanted to have a look at some TCP traffic coming from a device to see what exactly was in the packets. In some cases, besides just listening and receiving data, I’ve needed to record it and even respond like a server might.

Wireshark is a handy tool for sniffing, but a little OptoScript running on a PAC gives me more options for saving/parsing/recording the data coming in.

Most recently, I wanted to capture to packets coming out of one of our nifty OptoEMU sensors. I wrote the attached chart, which I thought might be of use to any of you who might want to do something similar – listen on a TCP port, parse some XML code, etc.

In this example, the XML data I parsed is described in the OptoEMU Sensor Communication Guide (form 1958, search for “XML Data”).

Just import the attached chart into a 9.1 or newer strategy and adjust to your needs.

-OptoMary (4.12 KB)