Debugging IP Communication
Question:
How do I debug IP_CLIENT communications using Netlinx Studio Diagnostics and Notifications?
Answer:
When controlling a device via IP in NetLinx it is difficult to debug the incoming and outgoing strings because Netlinx Studio's Notifications cannot be used to watch incoming and outgoing strings. Also, Control a Device does not work to send strings to IP devices. This means that in order to test an outgoing string it must be put in code, then compiled and loaded to test it. If it is incorrect then the process must be repeated.
Using a virtual device as a translator to the IP device allows you to then use Notifications to watch the virtual device and use Control a Device to send strings to the virtual device.
A virtual device is created in code, and then commands and strings are used to/from that virtual device. Commands are sent to the virtual device to represent outgoing messages to the IP device and strings to the virtual device are sent as return messages from the IP device.
The process is to create a virtual device in the 33000 range. Then a DATA_EVENT is created for that virtual device. Under the Command handler event is a SEND_STRING of DATA.TEXT to the IP device. This will result in any message sent to the virtual device as being automatically sent out the IP device as a String. A DATA_EVENT is created for the IP device. Under its String handler event is a SEND_STRING to the virtual device. This will result in any return messages from the remote device being sent as a string to the virtual device.
To watch incoming messages from the real IP device create a Notification in NetLinx Studio to watch for strings to the virtual device.
To send a test message out to the IP device, use Control a Device in NetLinx Studio to send a command to the virtual device. Make sure to include a CR, or LF if the remote device requires it.
Please look at the attached sample code file to see this demonstrated.