NEP CLI
An npm package and command line tool for NEP+
Installation
After installing node.js > 18.0, you can install NEP CLI using the following command in Windows:
npm install -g nep-cli
In Linux and macOS you may need to use sudo
sudo npm install -g nep-cli
Verify that NEP CLI is installed correctly using the following command:
nep help
If using Intune (Windows)
To verify, navigate to Control Panel -> System and Security -> Windows Defender Firewall -> Allow an app or feature through Windows Defender Firewall. Ensure that Node.js JavaScript Runtime is listed as an allowed app or feature. If it is not listed, click on the "Allow another app" button and add Node.js (C:\Program Files\nodejs\nodejs.exe).
Manage connection between nodes:
nep master
Start master for managing NEP+ topics
nep ip
Display current Wi-Fi and Ethernet IP addresses of the computer
Connection of NEP+ nodes
Use the following command to connect NEP nodes within a local network. This is applicable when the nodes are on the same computer or connected via Wi-Fi or Ethernet.
nep master
This command will display the next output:
Starting NEP master in terminal
New Master in: tcp://0.0.0.0:50000
Master info in: tcp://0.0.0.0:500001
This command initiates a NEP master node on your local network. NEP nodes within your network can connect to this master node to communicate with each other.
See the Wi-Fi and Ethernet IP address of your PC
This command displays the current Wi-Fi and Ethernet IP addresses of the computer where this command is run. It identifies the operating system and accordingly fetches the network interfaces.
nep ip
For each identified Wi-Fi interface, it fetches and prints the IP address. It also fetches and prints the IP address of the Ethernet interface. An example is show bellow:
Wi-Fi (Wi-Fi) IP Address: 192.168.1.3
No Ethernet IPv4 address found.
Topics registered
nep topics
Displays the list of NEP+ topics
nep topics
This command displays the list of NEP+ topics. It connects to the NEP master node at the local IP address (127.0.0.1) and sends a request for the list of topics. The command waits for a response from the master node or a timeout, whichever comes first.
Publish a JSON message:
nep publish <topic> <message>
Publish a message to a NEP+ topic (only JSON messages are supported)
Let's imagine that the topic test/json
is already registered in NEP+ master, and it is required to send the message {'msg':'hello'}
to a node subscribed to this topic using the command line interface.
This is possible with the command nep publish <topic> <message>
as follow:
nep publish test/json "{'msg':'hello'}"
If the message to send:{'msg':'hello'}
is written as: {"msg":"hello"}
it will produce an error. Therefore, use ' '
and not " "
In these examples, change test/json
by the topic you would like to publish a message. To see the list of registered topics, use the nep topics
command .
Display messages:
nep show [topic] [index]
Displays messages published to a specified NEP+ topic in the default browser. The [index] parameter specifies the index of the message to display and must be a number between 0 and 49.
nep echo [topic]
Subscribe to a NEP+ topic and display raw string messages
show
This command is used to display messages send in a specific topic in the default browser . The topic and index are optional parameters.
If no parameters are provided, the user will be prompted to select one of the available topics.
The index is used to identify a specific server instance when multiple servers are running. It helps in routing the messages correctly to the intended server for display in the web browser.
It's important to assign a unique index value for each topic. Duplicate index values can lead to confusion and incorrect routing of messages.
Example:
nep show test/json 0
echo
This command subscribes to a NEP+ topic and displays raw string messages. The topic is an optional parameter. If no topic is provided, the user will be prompted to select one of the available topics.
Example:
nep echo test/json
Comunication monitoring:
hz [topic]
Monitor the publishing rate of a NEP+ topic
delay [topic]
Monitor the delay between messages of a NEP+ topic
bw [topic]
Monitor the bandwidth used by a NEP+ topic
These commands are used to monitor various aspects of a NEP+ topic. The topic is an optional parameter. If no topic is provided, the user will be prompted to select one of the available topics.
hz
This command is used to monitor the publishing rate of a NEP+ topic. It displays the rate at which messages are being published to the specified topic.
Example:
nep hz test/json
delay
This command is used to monitor the delay in message delivery for a NEP+ topic. It displays the time taken for messages to be delivered from the publisher to the subscriber for the specified topic.
Example:
nep delay test/json
bw
This command is used to monitor the bandwidth usage of a NEP+ topic. It displays the amount of data being transmitted over the network for the specified topic.
Example:
nep bw test/json
Bag (record and play messages)
record [topic]
Record messages from a NEP+ topic to a JSON bag file
nep play <bagfile> <topic>
Play messages from a bag file to a NEP+ topic
These commands are used to record and playback messages from a NEP+ topic.
record
This command is used to record messages from a specified NEP+ topic. If no topic is not provided, the user will be prompted to select one of the available topics. User can prompt a timeout (in miliseconds)
Example:
nep record
play
This command is used to playback messages from a recorded file. The bagfile must be a JSON file created by nep record command.
nep play
Last updated