When using Robustel's EG series gateways (like the EG5120 or EG3110) running RobustOS Pro, you often need to interact with the physical world through Digital Inputs (DI) and Digital Outputs (DO). For instance, you might need to read the state of a connected switch (DI) or turn on an alarm light (DO). This guide provides the specific command-line instructions to read DI states and control DO states from the device's terminal. These commands are useful for scripting and remote diagnostics, and can be easily executed from within custom applications written in various programming languages.
Hardware list:
Software/Firmware:
Prerequisites:
sudo user account through the RobustOS Pro web interface. The entire process is performed through the gateway's command-line interface (CLI).
First, you need to establish an SSH connection to your gateway to access its terminal.
192.168.0.1). sudo user credentials.ssh your_sudo_user@192.168.0.1For applications requiring real-time, event-driven DI status updates, it is recommended to monitor the device file (e.g., /dev/DI1) for EV_KEY events using standard Linux input event handling methods. The following steps, however, configure the port for use with the usi command, which is suitable for periodic polling of the DI state.
You can read the status of any DI port using the built-in usi command.
High or Low.sudo usi get dido.di[1].levelgrep to convert it. This command will output 0 if the state is "Low" and 1 if the state is "High".sudo usi get dido.di[1].level | grep -qx "Low" && echo 0 || echo 1Note: To check a different DI port, simply change the number inside the brackets, e.g., dido.di[2] for DI2.
The status of DO ports is managed through the standard Linux /sys filesystem.
brightness file for the corresponding DO. 1 indicates the DO is set to High (On), and 0 indicates Low (Off).cat /sys/class/leds/do1/brightnessNote: To check a different DO port, change do1 to do2, etc.
You can change the state of a DO port by writing to the same brightness file. This requires superuser privileges, so sudo tee is used.
echo 1 | sudo tee /sys/class/leds/do1/brightnessecho 0 | sudo tee /sys/class/leds/do1/brightnessAfter running the commands, you should verify that they work as expected.
sudo usi get dido.di[x].level command and observe the output change between "Low" and "High" as you toggle the input.echo 1 | sudo tee ... command. Observe the corresponding DO status on the gateway; it should turn on. Running echo 0 | sudo tee ... should turn it off. You can also connect a multimeter to the DO terminals to verify the voltage change./sys/class/leds/ requires root permissions. Make sure your command includes sudo tee. Simply using sudo echo 1 > ... will not work due to how shell redirection handles permissions.usi is not found.usi utility is a key part of RobustOS Pro. If this command is missing, you may be on a different firmware or operating system. Please ensure your device is running a compatible version of RobustOS Pro./sys/class/leds/do1/brightness does not exist.ls /sys/class/leds/ to list all available LED controls on your specific gateway model and find the correct identifier for your DO ports (e.g., it might be user:do1 or similar).Revision | Date | Author | Notes |
1.0 | 2025-10-11 | Jens Zhou | Initial Release |