In the first example, we saw how to configure the groov I/O device and then read from a memory map address just to see that everything was working correctly.
Read an I/O Value
The Read node is mostly used for reading the current value of an analog or digital channel, either an input or an output.
Using a module of your choosing, configure a Read node to read the current value of a channel.
- Double-click on an existing (or new) groov I/O Read node to open the “Edit groov i/o read node” view.
- For the Device field, confirm that a configured device is selected.
- For the Data Type field, select either Digital Channel or Analog Channel.
- For the Module Index, enter the module location you’d like to use. The indexes are zero-based, so 0 is for the first slot on the chassis.
- For the Channel Index, enter the channel you’d like to use. The indexes are zero-based, so 0 is for the first channel on the module.
- Click Done.
- Click Deploy.
- Make sure the Debug tab is open in the right-hand sidebar.
- Click the Inject node’s button.
In the Debug tab, you should see messages with the channel’s current value.
For example, here’s a flow reading both a digital and analog value, with the values shown in the Debug tab:
Accessing Additional Info in the Response
When reading a channel’s value, the main value is placed in the msg.payload property. Additional information is placed in the msg.body property.
To see the full message: 1. Open the Debug node and change the Output field from msg.payload to complete msg object. 1. Redploy the flow and click the associated Inject node. 1. In the Debug tab, expand the message to see the msg.body property and all the other values.
Continue on to scanning values with the Input node.