Direwolf/Xastir Auto Start Conundrum

499 views
Skip to first unread message

Budd Churchward

unread,
Oct 28, 2016, 4:12:17 PM10/28/16
to Northwest Washington Digital Amateur Radio
I just can’t let go of this. I am determined to make it work, so I spent a few more hours on it last night and have finally reached a conundrum. Now I’m at the point where it doesn’t make sense.
 
Using the auto start script that Robert shared with us, I did get cron to start checking for Direwolf and launching it if it wasn’t running. It checks every minute, but waits 30 seconds before it tries to launch anything so that the Rpi has a chance to boot up all the way. So it can take up to 90 seconds before Direwolf launches.
 
I added another instruction to then launch Xastir. That took a lot of trial and error and a lot of 90 seconds waiting to see if it worked. I got it to the point where it would launch both Direwolf and Xastir, but Xastir could not find Direwolf and it always showed an error. I thought maybe Xastir was launching too soon. Although I launch the two of them all the time from the command window with:
 
direwolf –p & xastir
 
That works fine.
 
The command in the script to launch Direwolf is: DWCMD=”direwolf –a 100”
That starts a logging file of audio samples which it takes every 100 seconds. I changed it to: DWCMD=”direwolf –p” and that runs just fine.
I added: DWCMD=”xastir” after that and Xastir launches, but can’t find the Direwolf TNC.
 
I put a delay in between the two lines to see if that helps: sleep(20) which is supposed to put a pause between the two commands. It doesn’t. They still launch right away. Yet there is a command earlier in the script: sleep(30) that does seem to work.
 
So here is the conundrum. If I simply execute the script from the command window:
./dw-start.sh
 
It works! Even the delay works (and it isn’t needed). I am up and running. All systems go!
 
But when cron launches the script (same script file) it doesn’t work. Audio device not found. Except maybe 1 out of 8 tries, it does work ???
 

Keith Williamson

unread,
Oct 28, 2016, 4:26:06 PM10/28/16
to nww...@googlegroups.com
Hi Budd,

Beware of using relative paths in cron scripts. When you run a script from the command line, it inherits environment variables such as PATH. This is not the case for scripts executed via cron. Typically, we use fully qualified paths to commands within cron scripts. 

Without having a copy of the script, it's hard for me to say for sure what the issue is but I'm guessing when direwolf starts out of the cron script, it spends more time looking for its various support directories. 

Can you share your "dw-start" script?

-Keith
KF7DRV

--
You received this message because you are subscribed to the Google Groups "Northwest Washington Digital Amateur Radio" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nwwdigi+unsubscribe@googlegroups.com.
To post to this group, send email to nww...@googlegroups.com.
Visit this group at https://groups.google.com/group/nwwdigi.
For more options, visit https://groups.google.com/d/optout.

Budd Churchward

unread,
Oct 28, 2016, 4:46:05 PM10/28/16
to Northwest Washington Digital Amateur Radio
Thanks again, Kieth, for your comment.
I double checked and I am using full path in the cron command to launch the script. I figured that one out. It has to be there. And the script is launching Xastir. It comes up just fine. Unfortunately, Xastir can not find Direwolf. And Direwolf says there is an: "ENOEN ERROR" Interface Error! Error opening interface 1 Hard Fail

I just tried it again, and it comes right up if I call the script from the command window.

I will figure out how to attach the file so you can see it.

Budd
dw-start.sh

Keith Williamson

unread,
Oct 28, 2016, 5:09:45 PM10/28/16
to nww...@googlegroups.com
Hi Budd,

The problem is that after you assign "direwolf -p" to local variable DWCMD, you are assigning "xastir" to DWCMD which replaces "direwolf -p". 

I don't have a way presently to test the attached script but try it out. I simply added a second local variable XSCMD which I set to "xastir". Then below that in the "cascading if" that is checking for what version of the x terminal is installed, I added lines to do a sleep followed by a line to run the XSCMD in the background. 

Cheers,

Keith


--
dw-start.sh

Keith Williamson

unread,
Oct 29, 2016, 12:48:07 AM10/29/16
to nww...@googlegroups.com
Hi Budd,

I installed Xastir on my RPi running direwolf so I could test what I sent you. It doesn't work properly. I'm debugging it and will get back to you with an updated script when I get it working.

Cheers,

Keith
KF7DRV

Keith Williamson

unread,
Oct 29, 2016, 6:05:29 PM10/29/16
to nww...@googlegroups.com
Hi Budd (and all),

I figured out that the auto start of direwolf and xastir needed to be done with separate cron scripts. The reason is that direwolf is meant to run in the "foreground" and xastir is meant to run in the "background". By background, I don't mean from a display point of view but by a shell point of view. Because of this difference, the two scripts are invoked by cron differently. Consequently, they can't be combined.

Attached is an updated dw-start.sh script and a new xs-start.sh script. As before, you can tweak the DWCMD variable to start direwolf with whatever options you like. In the xs-start.sh script, you can tweak the XSCMD variable to start xastir with whatever options you like. The dw-start.sh script just has a 5 second sleep at the top to ensure that the Compass desktop is ready. The xs-start.sh script has a 25 second sleep at the top to ensure that direwolf is far enough along in its initialization to be listening for client connections on port 8000.

To install, just put these two scripts in /home/pi and ensure that they are executable. If not, just do "chmod 755 *-start.sh". Then you need to run "crontab -e" and put the following two lines at the bottom:

@reboot /home/pi/dw-start.sh > /dev/null 2>&1
@reboot /home/pi/xs-start.sh

Note that the dw-start.sh script needs to be run with stdout and stderr redirected to /dev/null (the bit bucket). The "> /dev/null" redirects stdout to /dev/null and the "2>&1" says redirect stderr (2) to the same place as stdout (1)...which is /dev/null. Note also that xs-start.sh does not have stdout and stderr redirected to /dev/null. This is the difference in invocation that forced me to split the startups into separate scripts.

I've tested this repeated on my RPi and it works well for me. Direwolf starts up first in an lxterminal and then xastir starts up and (in my case) fills the screen with the current view. To view the direwolf session, just click on the direwolf tab at the top of the screen.

Cheers,

Keith
KF7DRV

xs-start.sh
dw-start.sh

Robert Sears

unread,
Oct 29, 2016, 6:15:53 PM10/29/16
to nww...@googlegroups.com
That's awesome!

Thanks Keith

Robert/KF7VOP
To unsubscribe from this group and stop receiving emails from it, send an email to nwwdigi+u...@googlegroups.com.

Budd Churchward

unread,
Oct 29, 2016, 6:18:54 PM10/29/16
to Northwest Washington Digital Amateur Radio
Thanks for all of this, Keith. I am looking forward to reading your scripts.

I don't understand why you thought the first version didn't work. I have it running nicely here. Just as an exercise to see if I could teach myself how to do it, I added code to your script that will kill Xastir if it is running when Direwolf goes down. Then both of them launch beautifully and work just fine.

I moved my SD card over to my little 'Appliance' with the touch screen and battery pack. It will soon be a complete portable packet station. I simply flipped the switch and it started itself right up. It is running on the air right now as I type this. It will be interesting to see the changes that you made.

I have added sound effects so I can tell when a message comes in. Send a message to: WB7FHC-3 and say hello.

Budd


On Saturday, October 29, 2016 at 3:05:29 PM UTC-7, Keith Williamson wrote:
Hi Budd (and all),

I figured out that the auto start of direwolf and xastir needed to be done with separate cron scripts. The reason is that direwolf is meant to run in the "foreground" and xastir is meant to run in the "background". By background, I don't mean from a display point of view but by a shell point of view. Because of this difference, the two scripts are invoked by cron differently. Consequently, they can't be combined.

Attached is an updated dw-start.sh script and a new xs-start.sh script. As before, you can tweak the DWCMD variable to start direwolf with whatever options you like. In the xs-start.sh script, you can tweak the XSCMD variable to start xastir with whatever options you like. The dw-start.sh script just has a 5 second sleep at the top to ensure that the Compass desktop is ready. The xs-start.sh script has a 25 second sleep at the top to ensure that direwolf is far enough along in its initialization to be listening for client connections on port 8000.

To install, just put these two scripts in /home/pi and ensure that they are executable. If not, just do "chmod 755 *-start.sh". Then you need to run "crontab -e" and put the following two lines at the bottom:

@reboot /home/pi/dw-start.sh > /dev/null 2>&1
@reboot /home/pi/xs-start.sh

Note that the dw-start.sh script needs to be run with stdout and stderr redirected to /dev/null (the bit bucket). The "> /dev/null" redirects stdout to /dev/null and the "2>&1" says redirect stderr (2) to the same place as stdout (1)...which is /dev/null. Note also that xs-start.sh does not have stdout and stderr redirected to /dev/null. This is the difference in invocation that forced me to split the startups into separate scripts.

I've tested this repeated on my RPi and it works well for me. Direwolf starts up first in an lxterminal and then xastir starts up and (in my case) fills the screen with the current view. To view the direwolf session, just click on the direwolf tab at the top of the screen.

Cheers,

Keith
KF7DRV

Keith Williamson

unread,
Oct 29, 2016, 6:36:41 PM10/29/16
to nww...@googlegroups.com
Interesting that it worked for you as originally modified!

I don't think you need to kill Xastir when direwolf goes down if you have the Xastir option set to reconnect the network interface to the TNC on a failure. It should pick right up when direwolf restarts. In fact, with that option set, the sleep delay on the automatic xastir start is probably unnecessary.

I'll shoot you a message when I get my RPi/UDRC moved back out to the shack. I had it in my office here where I could hook it up to an HDMI monitor to do the script testing.

Cheers,

Keith
Reply all
Reply to author
Forward
0 new messages