OPTO22 SNAP UP1 ADS read network settings using LINUX
Opto22 and its industrial hardware is known for its openness in protocols, documentation and bug reports. The haven't a complete Linux based suite to work with their equipment, however they produced some specific linux apps!.
* Este articulo tambien esta disponible en Español haciendo clic aqui
SNAP UP1 ADS
This device is a combination of a controller (CPU) and I/O. This is not an Opto22's last generation equipment, and is not recommended for new designs, however still in production and supported. Due to its great flexibility to program diverse communication protocols, it's very attractive for developing Internet Of Things (IoT) gateways
The SNAP UP1 ADS have an on-board Ethernet. Its primary use is for general setup, download of control strategies and remote monitoring HMI. When the controller is in an Ethernet network, the manufacturer provides a Windows app named PAC MANAGER (part of a PAC PROJECT free suite), used to detect devices plugged into the network.
The main problem with the application, is that the device must have similar network settings to the computer running the app! (same network segment settings).If not the device isn't detected. If the network parameters of the device are unknown, there are only 2 alternatives:
- Reset device to default settings to set a new known network parameters (erasing control strategy and other configurations)
- Use another application via serial port to get the parameters
The application is OptoFlash-ENET, used to read and modify network parameters, get hardware info and update firmware for compatible devices: SNAP Ethernet brains, SNAP Ultimate and M4SENET-100 card
To communicate the application with the device a serial cable must be built. If there is no available serial port in the computer an USB to RS232 cable could be used, and if no solder is desired a convenient way is to use a DB-9 breakout connector!
OptoFlash-ENET uses an ASCII protocol to establish communications with the hardware. ASCII protocols are easy to analyse and the app provides a debugging window where all the communication frames can be seen. The app does 3 things:
1. 1. Send "Power Up Clear" command
2. Send Hardware info query
3. Send Network Settings info query
Opto22 literature says "power up clear" command clears a flag that is set every time a controller is turned on or rebooted. With this flag the monitoring app knows that something happened. If the acknowledgement of power up isn't sent, the controller refuses to execute any other command, so the application sends power up clear before any other query.
"power up clear" frame:
Last four digits are CRC-16
Network settings query frame
Again last four digits are CRC-16.
COMMUNICATION USING LINUX
In the debugging window of OptoFlash-ENET app is noted that the serial communication parameters are 19200,8,N,1. Pretty common setup in industrial hardware!
Due to the communication frames are ASCII representation of HEX numbers, a serial port terminal program in Linux able to send characters is enough to establish communication.In this case CUTECOM was used
First "power up clear" command must be sent
The device’s answer similar to this:
Next, network settings info query is sent:
The device’s answer similar to this:
The windows app showed the actual network parameters, so there is known strings to search in the received frames, the most obvious is:
Which is the MAC shown in the Windows app
As the frame is the ASCII representation of HEX numbers, IP address and other network parameters must be encoded in that way!.
OptoFlash-ENET ip address displayed as 192.168.2.104 encoded in HEX: C0A80268. Looking for this string in the received frame:
Looking closely the following characters FFFFFF00C0A80201 are HEX representation of 255.255.255.0 and 192.168.2.1 so the blocks that match actual network parameters settings were found!. The remaining characters in the frame probably are another info not shown in OptoFlash-ENET or are placeholders to add more information in the future.
This information is the first step to develop a Linux app that automatizes de process of sending, receiving and frame analysis
More test with different hardware models are required to see if the frame structure and size is the same, or if is different for other type of hardware
(See bottom part - Attached files)
* Complete article in PDF
Video getting communication frames using OptoFlash-ENET and network settings read test in Linux