Step6. Set GPIO6, GPIO8, GPIO10 and GPIO12 output Level to 1 (Logical high):
After GPIO6, GPIO8, GPIO10 and GPIO12 are config to output pins, than you can set their Level to true/false by "adv_susicontrol_set" command.
This case is a demonstration to instruct MIO-5375 GPIO configuration and usage.
NOTE: All GPIO direction are configable.
- Hardware Config:
In this demonstraction, we would like to do a loopback test from DO to DI, before start below steps, we need to wire-connect from DO to DI for each:
DO1 (GPIO00) --- DI1 (GPIO04)
DO2 (GPIO01) --- DI2 (GPIO05)
DO3 (GPIO02) --- DI3 (GPIO06)
DO4 (GPIO03) --- DI4 (GPIO07)
- Steps:
Step1. Setup ROS2 foxy environmant variables:
$ source /opt/ros/foxy/setup.bash
Step2. Setup Advantech ROS Message:
$ source /usr/local/Advantech/ros/foxy/include/edge-converter-ros2/adv_msgs/install/local_setup.bash
Step3. Go to node.js SUSIControl node sample client path:
$ cd /usr/local/Advantech/ros/foxy/sample_code/edge-data-client/rclnodejs_edge_data_client/
Step4. Config GPIO00, GPIO01, GPIO02 and GPIO03 as output pins:
$ node example_SetSensor.js "rclnodejs_SUSIControl_setter" "adv_susicontrol_set" "SUSIControl/GPIO/GPIO00/Dir" "bv" false<br/> $ node example_SetSensor.js "rclnodejs_SUSIControl_setter" "adv_susicontrol_set" "SUSIControl/GPIO/GPIO01/Dir" "bv" false<br/> $ node example_SetSensor.js "rclnodejs_SUSIControl_setter" "adv_susicontrol_set" "SUSIControl/GPIO/GPIO02/Dir" "bv" false<br/> $ node example_SetSensor.js "rclnodejs_SUSIControl_setter" "adv_susicontrol_set" "SUSIControl/GPIO/GPIO03/Dir" "bv" false<br/>
Step5. Config GPIO04, GPIO05, GPIO06 and GPIO07 as input pins:
$ node example_SetSensor.js "rclnodejs_SUSIControl_setter" "adv_susicontrol_set" "SUSIControl/GPIO/GPIO04/Dir" "bv" true<br/> $ node example_SetSensor.js "rclnodejs_SUSIControl_setter" "adv_susicontrol_set" "SUSIControl/GPIO/GPIO05/Dir" "bv" true<br/> $ node example_SetSensor.js "rclnodejs_SUSIControl_setter" "adv_susicontrol_set" "SUSIControl/GPIO/GPIO06/Dir" "bv" true<br/> $ node example_SetSensor.js "rclnodejs_SUSIControl_setter" "adv_susicontrol_set" "SUSIControl/GPIO/GPIO07/Dir" "bv" true<br/>
Step6. Set GPIO00, GPIO01, GPIO02 and GPIO03 output Level to 1 (Logical high):
After GPIO00, GPIO01, GPIO02 and GPIO03 are config to output pins, than you can set their Level to true (logical high) by "adv_susicontrol_set" command.
Note: Please do not set value to the pins GPIO04, GPIO05, GPIO06 and GPIO07 because these pins are configured as input pins, set value action is not allow.
$ node example_SetSensor.js "rclnodejs_SUSIControl_setter" "adv_susicontrol_set" "SUSIControl/GPIO/GPIO00/Level" "bv" true<br/> $ node example_SetSensor.js "rclnodejs_SUSIControl_setter" "adv_susicontrol_set" "SUSIControl/GPIO/GPIO01/Level" "bv" true<br/> $ node example_SetSensor.js "rclnodejs_SUSIControl_setter" "adv_susicontrol_set" "SUSIControl/GPIO/GPIO02/Level" "bv" true<br/> $ node example_SetSensor.js "rclnodejs_SUSIControl_setter" "adv_susicontrol_set" "SUSIControl/GPIO/GPIO03/Level" "bv" true<br/>
Step7. Run node.js SUSIControl client:
$ node example_SubscribeSensor.js "rclnodejs_SUSIControl_subscriber" "/adv/susicontrol"
Step8. Verify received data:
You have entered arguments:<br/> node name: rclnodejs_SUSIControl_subscriber<br/> message topic: /adv/susicontrol<br/> ----------------------------------------------<br/> Data: sensor = "SUSIControl/GPIO/GPIO00/Dir", v = 0.00<br/> Data: sensor = "SUSIControl/GPIO/GPIO00/Level", v = 1.00<br/> Data: sensor = "SUSIControl/GPIO/GPIO01/Dir", v = 0.00<br/> Data: sensor = "SUSIControl/GPIO/GPIO01/Level", v = 1.00<br/> Data: sensor = "SUSIControl/GPIO/GPIO02/Dir", v = 0.00<br/> Data: sensor = "SUSIControl/GPIO/GPIO02/Level", v = 1.00<br/> Data: sensor = "SUSIControl/GPIO/GPIO03/Dir", v = 0.00<br/> Data: sensor = "SUSIControl/GPIO/GPIO03/Level", v = 1.00<br/> Data: sensor = "SUSIControl/GPIO/GPIO04/Dir", v = 1.00<br/> Data: sensor = "SUSIControl/GPIO/GPIO04/Level", v = 1.00<br/> Data: sensor = "SUSIControl/GPIO/GPIO05/Dir", v = 1.00<br/> Data: sensor = "SUSIControl/GPIO/GPIO05/Level", v = 1.00<br/> Data: sensor = "SUSIControl/GPIO/GPIO06/Dir", v = 1.00<br/> Data: sensor = "SUSIControl/GPIO/GPIO06/Level", v = 1.00<br/> Data: sensor = "SUSIControl/GPIO/GPIO07/Dir", v = 1.00<br/> Data: sensor = "SUSIControl/GPIO/GPIO07/Level", v = 1.00<br/>
Python
The program rclpy_edge_data_client is a Python client example for user to understand how to use rclpy to subscribe SUSIControl node's data. Please follow below steps to run the program, when the program launched, it will subscribe OPCUAClient node's sensor and print the data in the console screen.
Steps - Subscribe Sensor
Step1. Setup ROS2 foxy environmant variables:
$ source /opt/ros/foxy/setup.bash
Step2. Setup Advantech ROS Message:
$ source /usr/local/Advantech/ros/foxy/include/edge-converter-ros2/adv_msgs/install/local_setup.bash
Step3. Setup SUSIControl variables:
$ source /usr/local/Advantech/ros/foxy/sample_code/edge-data-client/install/local_setup.bash
Step4. Run Python SUSIControl sample client:
$ ros2 run rclpy_edge_data_client listener "rclcpp_SUSIControl_subscriber" "/adv/susicontrol"
Step5. Verify received data:
[INFO] [1668419166.970557368] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/Hardware Monitor/Voltage/Vcore", v = 1.13<br/> [INFO] [1668419166.971275797] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/Hardware Monitor/Voltage/3.3V", v = 3.36<br/> [INFO] [1668419166.971889153] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/Hardware Monitor/Voltage/5V", v = 5.22<br/> [INFO] [1668419166.972484995] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/Hardware Monitor/Voltage/12V", v = 12.13<br/> [INFO] [1668419166.973073717] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/Hardware Monitor/Voltage/5V Standby", v = 5.22<br/> [INFO] [1668419166.973724029] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/Hardware Monitor/Voltage/CMOS Battery", v = 3.15<br/> [INFO] [1668419166.974310688] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/Hardware Monitor/Voltage/VCC3", v = 3.34<br/> [INFO] [1668419166.974895174] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/Hardware Monitor/Temperature/CPU", v = 43.20<br/> [INFO] [1668419166.975476661] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/Hardware Monitor/Temperature/System", v = 36.50<br/> [INFO] [1668419166.976056322] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/Hardware Monitor/Fan Speed/CPU", v = 0.00<br/> [INFO] [1668419166.976637793] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/Hardware Monitor/Fan Speed/System", v = 2513.00<br/> [INFO] [1668419166.977217676] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/Hardware Monitor/Fan Speed/System 2", v = 2410.00<br/> [INFO] [1668419166.977840176] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/DiskInfo/Disk C Total Disk Space", v = 60039.00<br/> [INFO] [1668419166.978420960] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/DiskInfo/Disk C Free Disk Space", v = 1482.00<br/> [INFO] [1668419166.979005895] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/Platform Information/Board manufacturer", sv = "Advantech"<br/> [INFO] [1668419166.979585125] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/Platform Information/Board name", sv = "AIMB-285"<br/> [INFO] [1668419166.980164289] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/Platform Information/BIOS revision", sv = "V1.13"<br/> [INFO] [1668419166.980741273] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/Platform Information/Driver version", sv = "4.0.14326"<br/> [INFO] [1668419166.981320076] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/Platform Information/Library version", sv = "4.0.14326"<br/> [INFO] [1668419166.981936635] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/GPIO/GPIO00/Dir", bv = False<br/> [INFO] [1668419166.982513742] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/GPIO/GPIO00/Level", bv = False<br/> [INFO] [1668419166.983092131] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/GPIO/GPIO04/Dir", bv = True<br/> [INFO] [1668419166.983668132] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/GPIO/GPIO04/Level", bv = True<br/> [INFO] [1668419166.984246338] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/GPIO/GPIO02/Dir", bv = True<br/> [INFO] [1668419166.984820603] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/GPIO/GPIO02/Level", bv = True<br/> [INFO] [1668419166.985397629] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/GPIO/GPIO01/Dir", bv = True<br/> [INFO] [1668419166.986005697] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/GPIO/GPIO01/Level", bv = True<br/> [INFO] [1668419166.986585734] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/GPIO/GPIO03/Dir", bv = True<br/> [INFO] [1668419166.987160259] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/GPIO/GPIO03/Level", bv = True<br/> [INFO] [1668419166.987738015] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/GPIO/GPIO05/Dir", bv = True<br/> [INFO] [1668419166.988313746] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/GPIO/GPIO05/Level", bv = True<br/> [INFO] [1668419166.988890908] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/GPIO/GPIO06/Dir", bv = True<br/> [INFO] [1668419166.989482096] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/GPIO/GPIO06/Level", bv = True<br/> [INFO] [1668419166.990074224] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/GPIO/GPIO07/Dir", bv = True<br/> [INFO] [1668419166.990648950] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/GPIO/GPIO07/Level", bv = True<br/> [INFO] [1668419166.991224271] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/Backlight/Backlight 1/Brightness", v = 255.00<br/> [INFO] [1668419166.991803378] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/Backlight/Backlight 1/Frequency", v = 18780.00<br/> [INFO] [1668419166.992393882] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/Backlight/Backlight 1/Polarity", bv = False<br/> [INFO] [1668419166.992984235] [rclpy_SUSIControl_subscriber]: Data: sensor = "SUSIControl/SUSIIoT Information/version", sv = "1.0.14327"<br/>
C++
The program rclcpp_edge_data_client is a C++ example for user to understand how to use rclcpp to subscribe SUSI node's data. Please follow below steps to run the program, when the program launched, it will subscribe SUSI node's sensor and print the data in the console screen.
Steps - Subscribe Sensor
Step1. Setup ROS2 foxy environmant variables:
$ source /opt/ros/foxy/setup.bash
Step2. Setup Advantech ROS Message:
$ source /usr/local/Advantech/ros/foxy/include/edge-converter-ros2/adv_msgs/install/local_setup.bash
Step3. Setup SUSIControl node variables:
$ source /usr/local/Advantech/ros/foxy/sample_code/edge-data-client/install/local_setup.bash
Step4. Run Python SUSIControl sample client:
$ ros2 run rclcpp_edge_data_client listener "rclcpp_SUSIControl_subscriber" "/adv/susicontrol"
Step5. Verify received data:
[INFO] [1665992194.487803681] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/SUSIIoT Information/version', sv = '1.0.14327'<br/> [INFO] [1665992194.488662535] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/DiskInfo/Disk C Total Disk Space', v = 60039.00<br/> [INFO] [1665992194.489943911] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/DiskInfo/Disk C Free Disk Space', v = 2282.00<br/> [INFO] [1665992194.490802091] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/Platform Information/Board manufacturer', sv = 'Advantech'<br/> [INFO] [1665992194.490963569] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/Platform Information/Board name', sv = 'AIMB-285'<br/> [INFO] [1665992194.491036637] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/Platform Information/BIOS revision', sv = 'V1.13'<br/> [INFO] [1665992194.491086609] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/Platform Information/Driver version', sv = '4.0.14326'<br/> [INFO] [1665992194.491176944] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/Platform Information/Library version', sv = '4.0.14326'<br/> [INFO] [1665992194.491815332] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/Hardware Monitor/Voltage/Vcore', v = 0.29<br/> [INFO] [1665992194.492036608] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/Hardware Monitor/Voltage/3.3V', v = 3.36<br/> [INFO] [1665992194.492213936] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/Hardware Monitor/Voltage/5V', v = 5.22<br/> [INFO] [1665992194.492377116] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/Hardware Monitor/Voltage/12V', v = 12.18<br/> [INFO] [1665992194.492529694] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/Hardware Monitor/Voltage/5V Standby', v = 5.22<br/> [INFO] [1665992194.492846390] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/Hardware Monitor/Voltage/CMOS Battery', v = 3.15<br/> [INFO] [1665992194.492928825] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/Hardware Monitor/Voltage/VCC3', v = 3.34<br/> [INFO] [1665992194.493060224] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/Hardware Monitor/Fan Speed/CPU', v = 0.00<br/> [INFO] [1665992194.493217407] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/Hardware Monitor/Fan Speed/System', v = 2556.00<br/> [INFO] [1665992194.493377706] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/Hardware Monitor/Fan Speed/System 2', v = 2419.00<br/> [INFO] [1665992194.493532012] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/Hardware Monitor/Temperature/CPU', v = 35.00<br/> [INFO] [1665992194.493736784] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/Hardware Monitor/Temperature/System', v = 32.50<br/> [INFO] [1665992194.493923784] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/GPIO/GPIO05/Dir', bv = true<br/> [INFO] [1665992194.494074865] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/GPIO/GPIO05/Level', bv = true<br/> [INFO] [1665992194.494192822] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/GPIO/GPIO00/Dir', bv = true<br/> [INFO] [1665992194.494377938] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/GPIO/GPIO00/Level', bv = true<br/> [INFO] [1665992194.494536223] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/GPIO/GPIO02/Dir', bv = true<br/> [INFO] [1665992194.494715595] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/GPIO/GPIO02/Level', bv = true<br/> [INFO] [1665992194.494872167] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/GPIO/GPIO01/Dir', bv = true<br/> [INFO] [1665992194.495035704] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/GPIO/GPIO01/Level', bv = true<br/> [INFO] [1665992194.495239010] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/GPIO/GPIO03/Dir', bv = true<br/> [INFO] [1665992194.495405399] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/GPIO/GPIO03/Level', bv = true<br/> [INFO] [1665992194.495561419] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/GPIO/GPIO04/Dir', bv = true<br/> [INFO] [1665992194.495740410] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/GPIO/GPIO04/Level', bv = true<br/> [INFO] [1665992194.495901148] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/GPIO/GPIO06/Dir', bv = true<br/> [INFO] [1665992194.496102220] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/GPIO/GPIO06/Level', bv = true<br/> [INFO] [1665992194.496270253] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/GPIO/GPIO07/Dir', bv = true<br/> [INFO] [1665992194.496458663] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/GPIO/GPIO07/Level', bv = true<br/> [INFO] [1665992194.496639251] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/Backlight/Backlight 1/Brightness', v = 255.00<br/> [INFO] [1665992194.496767970] [rclcpp_SUSIControl_subscriber]: Data: sensor = 'SUSIControl/Backlight/Backlight 1/Frequency', v = 18780.00<br/> [INFO] [1665992194.496951618] [rclcpp_SUSIontrol_subscriber]: Data: sensor = 'SUSIControl/Backlight/Backlight 1/Polarity', bv = false<br/>
|