We, the Yoctopuce developers, think that it's by regularly using our own products that we improve their quality. It's also in this way that we discover when there are missing features. And this is how we discovered the other day that there was no way to list all the YoctoHubs present on the local network from the command line.
We have therefore added this feature to our command line API. In this post, we are only going to explain its use. If you are interested in its implementation, you can download the source files from our web site.
By default, that is without adding any specific option, executables on the command line use Yoctopuce modules connected on the USB ports of the machine.
For example, the execution of the following command enables us to discover that there is a module with the TMPSENS1-32130 serial number which is connected to a USB port.
The -r option
You can list the modules which are connected to a YoctoHub or a VirtualHub by using the -r option and by specifying the IP address or the host name of the remote hub.
For example, running the following command enables you to see that there is a module with serial number RELAYHI1-05116 which is connected to the YHUBETH1-4C147 YoctoHub, which uses the 192.168.1.34 IP address.
With the latest version of the command line API (v1.10.45975), you can now use the net keyword with the -r option. This keyword enables you to use all the YoctoHubs which are on the local network.
It's specially useful if you don't remember the IP address of your YoctoHub. You can, for example, use net instead of the IP address and obtain the same result as with the previous command.
When using the net keyword, the hub performs an inventory of the Yoctopuce hubs on the local network during 5 seconds. You can change this delay by adding the number of seconds between parentheses after the net keyword.
For example, to wait only one second, the syntax is the following:
There is another keyword which has a specific behavior: the usb keyword. This keyword indicates that you want to use the modules connected on the USB ports of the machine. In fact, the command line automatically adds the -r usb option if no -r option is specified. Which means that our very first example YModule inventory is equivalent to YModule -r usb inventory
Note that you can use several -r options. For example, the following command detects the Yoctopuce modules connected on one of the USB ports, the modules connected on YoctoHubs which are on the local network, and the modules connected on the machine with the faraway.example.com hostame.
Let's come back to our first issue which made us notice that network detection was lacking. How can we easily find the IP address of the Yoctopuce hub?
The answer is the following:
OK: YHUBETH1-4C147.YHUBETH1-4C147.get_ipAddress = 192.168.1.34.
You need to use the YNetwork tool which enables you to interact with the Network functions of a Yoctopuce module. The -r net option specifies that you want to use the modules present on the local network instead of the modules connected by USB. Finally, the all get_ipAddress displays the IP address of all the modules.