Implement FORT SDK as a Service
This appendix explains how to run the FORT SDK as a service on a Linux machine so that IP communication between an NSC Pro and its sender starts automatically after every restart, with separate procedures for an EPC sender and an SRC Pro sender.
Implement FORT SDK as a Service
When you configure an NSC Pro to communicate with its EPC sender via Wi-Fi or Ethernet, the FORT SDK must be running at all times in order to enable IP communications between the sender and the NSC Pro (see Install and Run the FORT SDK). One way to ensure that the FORT SDK is running is to implement it as a service that launches automatically whenever the Linux machine restarts.
This appendix explains how to implement the FORT SDK as a service in a configuration with an EPC sender (next section) and in a configuration with an SRC Pro sender (Implement SDK as a Service for SRC Pro Sender).
Implement SDK as a Service for EPC Sender
For a configuration with an EPC sender and NSC Pro receivers, the FORT SDK must be running at all times to enable Ethernet traffic between the EPC and the NSC Pro. This section shows how to implement the FORT SDK as a service to run on an Ubuntu Linux machine.
To Implement FORT SDK as a Service
-
Create the directory etc/fort-sdk:
>mkdir/etc/fort-sdk/ -
Create an environmental file in the new directory (
/etc/fort-sdk/fort-agent-pro.conf) with the following content:/*--fort-agent-pro.conf--*/ 1FORT_SAFETY_CHARDEV=/dev/serial/by-id/usb-FTDI_Dual_RS232-HS-if01-port0 2FORT_CONFIG_CHARDEV=/dev/serial/by-id/usb-FORT_Robotics__Inc._NSC_Pro_ <SerialNumber>-if00 -
Use
chmodto set the read-write permissions to the /etc/fort-sdk/directory as shown by the followinglscommand:>ls-la/etc/fort-sdk/ total20 drwxr-xr-x2rootroot4096Nov2212:55. drwxr-xr-x151rootroot12288Nov2212:55.. -rw-r--r--1rootroot154Nov2212:55fort-agent-pro.conf -
Define a service configuration file
/etc/systemd/system/fort-agent-pro.service:>sudotouch/etc/systemd/system/fort-agent-pro.service -
In the file, specify the command-line options for launching
fort-agent_proas a service:/*--fort-agent-pro.service--*/ 1[Unit] 2Description=FORTAgentProservice 3After=network.target 4[Service] 5EnvironmentFile=/etc/fort-sdk/fort-agent-pro.conf 6ExecStart=/usr/local/bin/fort-agent-pro--safety"${FORT_SAFETY_CHARDEV}"--config"${FORT_CONFIG_CHARDEV}" 7ExecReload=/usr/local/bin/fort-agent-pro--safety"${FORT_SAFETY_CHARDEV}"--config"${FORT_CONFIG_CHARDEV}" 8Restart=always 9Type=simple 10[Install] 11WantedBy=default.target 12RequiredBy=network.target -
Use
chmodto set the read-write permissions to/etc/systemd/system/fort-agent-pro.serviceas shown by the following ls command:>ls-la/etc/systemd/system/fort-agent-pro.service -rw-r--r--1rootroot427Nov2212:57/etc/systemd/system/fort-agent-pro.service -
Run the following command to start the service:
>sudosystemctlstartfort-agent-pro.service -
To verify that FORT Agent Pro is running, run the following command and you should see similar output:
> sudo systemctl status fort-agent-pro.service ● fort-agent-pro.service - FORT Agent Pro service Loaded: loaded (/etc/systemd/system/fort-agent-pro.service; disabled; vendor preset: enabled) Active: active (running) since Wed 2023-11-22 12:58:52 EST; 5min ago Main PID: 210832 (fort-agent-pro) Tasks: 5 (limit: 35659) Memory: 240.0K CGroup: /system.slice/fort-agent-pro.service └─210832 /usr/local/bin/fort-agent-pro --safety /dev/serial/by-id/usb-FTDI_Dual_RS232-HS-if01-port0 --config /dev/serial/by-id/usb-FORT_Robotics__Inc._NSC_Pro_NOTSET-if00 Nov 22 13:04:18 FORT-PF2PKENV fort-agent-pro[210832]: [1700676258118] [info] config->udp (2 packets, 22 bytes, 0 bytes/sec) Nov 22 13:04:18 FORT-PF2PKENV fort-agent-pro[210832]: [1700676258118] [info] udp->config (2 packets, 60 bytes, 0 bytes/sec) Nov 22 13:04:18 FORT-PF2PKENV fort-agent-pro[210832]: [1700676258118] [info] comms->udp (1 packets, 0 bytes, 0 bytes/sec) Nov 22 13:04:18 FORT-PF2PKENV fort-agent-pro[210832]: [1700676258118] [info] udp->comms (0 packets, 0 bytes, 0 bytes/sec) Nov 22 13:04:18 FORT-PF2PKENV /usr/local/bin/fort-agent-pro[210832]: [fort-agent_show_statistics:275] Uplink Statistics Nov 22 13:04:18 FORT-PF2PKENV /usr/local/bin/fort-agent-pro[210832]: [fort-agent_show_statistics:276] -------------------------------------------------------------------------------- Nov 22 13:04:18 FORT-PF2PKENV /usr/local/bin/fort-agent-pro[210832]: [fort-agent_show_statistics:277] config->udp (2 packets, 22 bytes, 0 bytes/sec) Nov 22 13:04:18 FORT-PF2PKENV /usr/local/bin/fort-agent-pro[210832]: [fort-agent_show_statistics:281] udp->config (2 packets, 60 bytes, 0 bytes/sec) Nov 22 13:04:18 FORT-PF2PKENV /usr/local/bin/fort-agent-pro[210832]: [fort-agent_show_statistics:285] comms->udp (1 packets, 0 bytes, 0 bytes/sec) Nov 22 13:04:18 FORT-PF2PKENV /usr/local/bin/fort-agent-pro[210832]: [fort-agent_show_statistics:289] udp->comms (0 packets, 0 bytes, 0 bytes/sec)
You can run the following command to stop the service:
sudosystemctlstopfort-agent-pro.service
Implement SDK as a Service for SRC Pro Sender
While it is not strictly necessary to install and run the FORT Agent Pro in a configuration with an SRC Pro sender and NSC Pro receivers, installing and enabling FORT Agent Pro allows you to configure an NSC Pro over IP as long as the host Linux device connected to the NSC is TCP/IP network enabled.
The general procedure is the same as that detailed in the previous section: you
create a /etc/fort-sdk/fort-agent-pro.conf file and a
/etc/systemd/system/fort-agent-pro.service file. However,
since the agent is to be run in config-only mode in this use
case, the contents of the files should look like this:
Contents of /etc/fort-sdk/fort-agent-pro.conf:
/*--fort-agent-pro.confsrcproversion--*/
1FORT_CONFIG_CHARDEV=/dev/serial/by-id/usb-FORT_Robotics__Inc._NSC_Pro_<SerialNumber>-if00
Contentsof/etc/systemd/system/fort-agent-pro.service:
/*--fort-agent-pro.servicesrcproversion--*/
1[Unit]
2Description=FORTAgentProservice
3After=network.target
4[Service]
5EnvironmentFile=/etc/fort-sdk/fort-agent-pro.conf
6ExecStart=/usr/local/bin/fort-agent-pro--config"${FORT_CONFIG_CHARDEV}"
7ExecReload=/usr/local/bin/fort-agent-pro--config"${FORT_CONFIG_CHARDEV}"
8Restart=always
9Type=simple
10[Install]
11WantedBy=default.target
12RequiredBy=network.target
To start, stop, and check status of the service, use the following commands:
-
sudosystemctlstartfort-agent-pro.service -
sudosystemctlstatusfort-agent-pro.service -
sudosystemctlstopfort-agent-pro.service