Rot Ctl Example
RotCtl and RotCtlD
This is an end-end-exmple using a Raspberry Pi 3, with Ubuntu controlling a RAK Spid Rotator.
We need to control the rotator, so we start with rotctl.
After some experimentation (and c++) I modified the Spid library to work well with my Spid Rak.
This is the command to "talk" to the rotator.... But firstly understand this
- I am logged into the machine where the USB Controller is plugged in
The command I use is
rotctl -m 902 -r /dev/ttyUSB0 -s 1200 -Z
A few helpers
- -m
- The model number (rotctl -l | grep -i spid
)
- The model number (rotctl -l | grep -i spid
- -r
- The Device to connect to (ls /dev/tty*)
- -s
- The Speed (Yes 1200 baud ... we are only sending a few characters)
- -Z
- Timestamp the output
Moving the Antenna
So after giving the connect rotcl command (shown above), you are hopefully looking at a
Rotator command:
prompt.
The first thing to do is to ask the rotator where is it ?
So just type
p
And I presently see
Azimuth: -40.00 Elevation: 0.00 Rotator command:
This makes sense my rotator is Az only (no El), and I am pointing to 320 degrees expressed as -40 ... (umm I feel another mod coming up).
So to move the Antenna say to +10 degrees
You just type
P 10 0
Note: Capital P and 2 values; Azimuth and Elevation
Wait a few seconds and type p
And it should read
Azimuth: 10.00 Elevation: 0.00 Rotator command:
Sick you head out of the window ... and make sure it is telling the truth.
RotctlD
The D means Daemon, in other words a network controlled process.
We can only attempt this if we have the previous step working 100%; And YOU MUST BE ON THE COMPUTER WHERE THE ROTATOR IS CONNECTED TOO (Yes I am speaking in a raised voice).
we however need 2 extra values...
- Port
- IP Address
Port
We should pick something that is
- Not in Use
- Greater than 1024
- Ports less than 1024, require high privileges.
You may if running a tight firewall also have to add a rule to allow access.
So I will pick port 8900
IP Address
You can only listen on an IP Address that is "owned" by your machine.
So if you do the following command
ip addr | grep inet
I see
inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host inet 192.168.199.6/24 brd 192.168.199.255 scope global dynamic wlx1cbfce3d638d inet6 fe80::1ebf:ceff:fe3d:632d/64 scope link
So I have
- 127.0.0.1
- Loopback - nothing can connect to this
- 1/128
- ip6 Loopback - also not useful
- 192.168.199.6/24 *A Class C(local) ip address, this is useful. But only machines in my LAN can see this
- fe80::1ebf:ceff:fe3d:632d/64
- ip6 local IP address [I think]
So you can specify the port of 192.168.19.6 - but if you are using DHCP, this will change - and you will keep having to change this value. So instead us
0.0.0.0
This is shorthand for "any ip address".
Running rotctld
Armed with the knowledge of Port and IP... we use the original rotctl command and enter
rotctld -t 8900 -T 0.0.0.0 -m 902 -r /dev/ttyUSB0 -s 1200 -Z
What are the new parameters
- -t
- The port number we will listen on, 8900 in this case.
- -T
- The IP Address we will listen on, 0.0.0.0 means - ALL
After we issue the command we should see
NOTHING... it will just sit there waiting for someone to connect.
Connecting to ROTCTLD
My rigctld is running on 192.168.19.6 I will connect from a machine with the ip address of 192.168.199.200.
But 1st (sent from 192.168.199.200 machine)
- Can you ping the target machine
- ping 192.168.199.6
If you can not ping this machine (assuming no firewall blocking it), then you are set to go.
The command is
rotctl -m 2 -r 192.168.199.6:8900
Parameters
- -m
- Model of Rotator - a Network rotator
- -r
- Address of the rotctld
- 192.168.199.6:8900
- ip_address:port
After giving this command you will see a familiar screen
Rotator command:
And so we issue the same command
p
And I see
Rotator command: p Azimuth: 0.00 Elevation: -40.00
And to turn I again issue a P 10 0
When you are finished rotating the antenna - you can quit using q.
Please note this only disconnects the rotcl (on machine 192.168.199.200) and the Daemon is still there - listening for a new command instruction.
Remote access
This is more difficult - as you need to ensure that you can port forward from your IP/ISP connection point into your network.
Look for Port-Forwarding options on the router.
Auto Starting on Ubuntu/Linux
We have everything configured, and now we would like to start this process as soon as the machine/network starts.
sudo bash cd /etc/systemd/system vi 92-rotctld.service
The file looks like this
[Unit] Description=Rotctl Spid Service [Service] ExecStart=/usr/local/bin/spid_remote.sh [Install] WantedBy=multi-user.target
We now need to enable this service
systemctl enable 92-rotctld.service
Now create the start_script /usr/local/bin/spid_remote.sh
The file looks like this
#!/usr/bin/bash export LD_LIBRARY_PATH="/usr/local/lib;$LD_LIBRARY_PATH" logger Starting rotctl for Spid /usr/local/bin/rotctld -t 8900 -T 0.0.0.0 -m 902 -r /dev/ttyUSB0 -s 1200 -Z
Set to Execute
chmod +x /usr/local/bin/spid_remote.sh
Try and start the service
systemctl start 92-rotctl.service
Check by
systemctl status 92-rotctl.service
I see
Loaded: loaded (/etc/systemd/system/92-rotctld.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2021-06-12 01:08:00 UTC; 1min 47s ago Main PID: 2850 (spid_remote.sh) Tasks: 2 (limit: 1815) Memory: 2.6M CGroup: /system.slice/92-rotctld.service ├─2850 /usr/bin/bash /usr/local/bin/spid_remote.sh └─2852 /usr/local/bin/rotctld -t 8900 -T 0.0.0.0 -m 902 -r /dev/ttyUSB0 -s 1200 -Z Jun 12 01:08:00 ubuntu systemd[1]: Started Rotctl Spid Service. Jun 12 01:08:00 ubuntu root[2851]: Starting rotctl for Spid
All is working...