Differential corrections
From CajunBot Wiki
The following document describes how to send differential corrections over the Internet using the base station.
Contents |
[edit] How is it set up
If the diagram is not clear:
- There is a base station antenna that is mounted on the roof of Abdalla hall.
- The C-NAV is connected to the antenna by a long cable (the C-NAV rests in CBLab)
- A computer in the lab (currently cb1), is connected via serial to the C-NAV.
- A server program runs on cb1, listening to a port that is forwarded from the lab router (currently 8800).
- On the CajunBot DataLogger machine, a client program is running, which is directly connected to a cell modem.
- The client program connects to cbserver.cacs.louisiana.edu at port 8800, which is forwarded to cb1, and the server accepts the connection and starts sending the binary correction data from the C-NAV to the client.
- The client program receives the binary correction data and writes it to a serial port which is connected to the RT3K, which then uses the data as differential corrections.
[edit] Connections in the lab
The antenna is mounted on top of the roof and has a long cable that is connected to the C-Nav that is located inside the lab next to the server. The C-Nav is connected via serial cable to Cb1 (computer that is closest to the server). This computer sends the corrections over the Internet using the port 8800.
[edit] Connections in CajunBot
The Cradle Point router located in the bot has a 3g wireless card that enables it to connect to the internet. The logging computer is directly connected to it.
[edit] Setting up the server side
It is assumed you will be root and the programs after they are compiled will be in the root home directory "/root". Pay particular attention to the init scripts below for clarity
In order to get the correct data from the C-NAV, the serial device needs to be set up properly. The way we found out which options needed to be set was using minicom (see the section below). We noticed that with minicom we would receive data, but not when we tried just to cat the device. Using minicom, we determined the correct settings to give to the stty command.
Before trying to use the serial device, you need to set it up correctly using the stty command:
stty -parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts ignbrk -brkint -ignpar -parmrk -inpck \ -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8 -opost -olcuc -ocrnl -onlcr \ -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 -isig -icanon -iexten -echo -echoe -echok -echonl \ -noflsh -xcase -tostop -echoprt -echoctl -echoke 9600 -F /dev/ttyS0
Then the program rt_corrections_server in the CVS module rt_corrections can be run to write the data over the Internet when the client connects. The usage for the program is below:
Usage: rt_corrections_server <options> [-b #] Buffer transfer size [4096]. [-p #] Port to use [8800]. [-q #] Queue size [2]. [-s dev] Serial device to read from (must have proper permissions) [/dev/ttyS0]. [-v] Turn on verbosity.
A more desirable thing would to have this program run "automatically" at boot time. A simple init script can be created to run the program as a daemon. In the CVS module rt_corrections, the daemonize program has been included, which will daemonize a program for running as a system process.
In the folder /etc/init.d, create the script start_sending_rt_corrections (also in CVS):
#!/bin/bash arg=$1 if [ ! -n "$arg" -o "$arg" == "start" ] ; then echo "Setting serial device up" stty -parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts ignbrk \ -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon \ -ixoff -iuclc -ixany -imaxbel -iutf8 -opost -olcuc -ocrnl -onlcr \ -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 -isig -icanon \ -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt \ -echoctl -echoke 9600 -F /dev/ttyS0 echo "Starting /root/rt_corrections_server" /root/daemonize /root/rt_corrections_server fi if [ "$arg" == "stop" ] ; then echo "Stopping /root/rt_corrections_server" pid=`pgrep rt_corrections` kill -9 $pid fi if [ "$arg" == "restart" ] ; then echo "Stopping /root/rt_corrections_server" pid=`pgrep rt_corrections` if [ -n "$pid" ] ; then kill -9 $pid fi echo "Starting /root/rt_corrections_server" /root/daemonize /root/rt_corrections_server fi
This is a simple script which can be used to start (setup), stop, and restart the server program.
Also, in the default runlevel for the computer (for example, the GUI environment is usually runlevel 5, the text-only environment is usually runlevel 3), add a startup script so that at boot time, the computer will start the process.
For cb1, the default runlevel is 5. Create a symbolic link to the init script:
# cd /etc/rc5.d # ln -s ../init.d/start_sending_rt_corrections S99start_sending_rt_corrections
This will run the process near the end of the boot process.
Lastly, don't forget to have the proper port (currently 8800) forwarded in the lab's router.
[edit] Setting up the client side
It is assumed you will be root and the programs after they are compiled will be in the root home directory "/root". Pay particular attention to the init scripts below for clarity
The process is similar for the client side as it is for the server side, but with a few differences. First, recall that the bot machines currently have read-only flash memory, so as root you'll need to remount the filesystem as read-write so that your changes are permanent. Don't forget to remount back as read-only at the end.
Also, the machine running the client program needs to have access to the Internet connection, so verify you can connect to cbserver.cacs.louisiana.edu.
In order to get the correct data from the server program, the serial device needs to be set up properly. The way we found out which options needed to be set was using minicom (see the section below). We noticed that with minicom we would receive data, but not when we tried just to cat the device. Using minicom, we determined the correct settings to give to the stty command.
Before trying to use the serial device, you need to set it up correctly using the stty command:
stty -parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts ignbrk -brkint -ignpar -parmrk -inpck \ -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -opost -olcuc -ocrnl -onlcr -onocr \ -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 -isig -icanon -iexten -echo -echoe -echok -echonl -noflsh \ -xcase -tostop -echoprt -echoctl -echoke 9600 -F /dev/ttyS0
Then the program rt_corrections_client in the CVS module rt_corrections can be run to write the data over the Internet when the client connects. The usage for the program is below:
Usage: rt_corrections_client <options> [-b #] Buffer transfer size [4096]. [-h str] Hostname of server [localhost]. [-p #] Port to use [8800]. [-s #] Sleep before reconnect attempt [1000]. [-v] Turn on verbosity.
A more desirable thing would to have this program run "automatically" at boot time. A simple init script can be created to run the program as a daemon. In the CVS module rt_corrections, the daemonize program has been included, which will daemonize a program for running as a system process.
In the folder /etc/init.d, create the script start_getting_rt_corrections (also in CVS):
#!/bin/bash arg=$1 if [ ! -n "$arg" -o "$arg" == "start" ] ; then echo "Setting serial device up" stty -parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts ignbrk \ -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon \ -ixoff -iuclc -ixany -imaxbel -opost -olcuc -ocrnl -onlcr -onocr \ -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 -isig -icanon -iexten \ -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl \ -echoke 9600 -F /dev/ttyS0 echo "Starting /root/rt_corrections_client" /root/daemonize /root/rt_corrections_client_startup.sh cbserver.cacs.louisiana.edu /dev/ttyS0 fi if [ "$arg" == "stop" ] ; then echo "Stopping /root/rt_corrections_client" pid=`pgrep rt_corrections` kill -9 $pid fi if [ "$arg" == "restart" ] ; then echo "Stopping /root/rt_corrections_client" pid=`pgrep rt_corrections` if [ -n "$pid" ] ; then kill -9 $pid fi echo "Starting /root/rt_corrections_client" /root/daemonize /root/rt_corrections_client_startup.sh cbserver.cacs.louisiana.edu /dev/ttyS0 fi
This is a simple script which can be used to start (setup), stop, and restart the client program.
You may have noticed there is an important difference in this init script from the server one created. An intermediate script called rt_corrections_client_startup.sh is used because we wish to write the data received from the Internet side to the serial device which is connected to the RT3K. In order to use the standard redirection operator >, we need an intermediate script. The script rt_corrections_client_startup.sh is quite simple:
#!/bin/bash host=$1 device=$2 /root/rt_corrections_client -h $host > $device
Also, in the default runlevel for the computer (for example, the GUI environment is usually runlevel 5, the text-only environment is usually runlevel 3), add a startup script so that at boot time, the computer will start the process.
For the bot machines, the default runlevel is 3. Create a symbolic link to the init script:
# cd /etc/rc3.d # ln -s ../init.d/start_sending_rt_corrections S99start_sending_rt_corrections
This will run the process near the end of the boot process.
[edit] Minicom (troubleshooting)
This section is mainly for troubleshooting. You can verify that there is data coming into the serial connection with minicom. As root:
# minicom
Press ctrl+a then o to load up configuration:
Use the arrow keys to choose serial port setup:
Verify that the above options apply. Specifically pay attention to E, F, and G.
- E should be set to 9600 baud, odd parity, 1 stop bit.
- No hardware flow control
- No software flow control
When done, press enter. Then at the configuration menu, choose "Save setup as dfl". Then exit.
You should see the data from the main screen. If not, try exiting minicom with ctrl+a then x, and rerunning it again.




