Sunday, July 20, 2014

It's Alive...it's Alive!!

My lounge room now echos to the sounds of my HO scale Burlington Northern EMD SD9. And it also looks funny that whilst this loco is moving in one direction there is an N scale Canadian National EMD SD40-2 passing in the opposite direction.

Yes - it is all alive!


I have finally nutted out, with help of course, how to get the Raspberry Pi to run in Facelesss mode and fire up the latest JMRI software which is version 3.8 and to act as an Access Point. This will now allow us at the club to start planning our implementation on our N scale exhibition layout and also our HO club room layout.


So continuing on from my last post, we start at step 22. This is where we had the JMRI running in normal mode and were able to control locos. But it still required manual intervention to start up the JMRI.



22. Once finished, exit the app on the smartphone / tablet and turnoff the device’s wifi connection if required.

Close down the WiThrottle Server by going to WiThrottle on the menu bar of the WiThrottle window and click on Stop Server.

Close down JMRI by going to File on the menu bar of the DecoderPro window and click Quit.
Exit/Logout the desktop GUI of your Raspberry Pi.
Close down the Pi if required:

sudo shutdown –h now

If you don’t intend to have the R-Pi Access Point permanently connected to the Internet (probably only required temporarily for software updates), disconnect the Ethernet cable from the R-Pi.

Bundle up your R-Pi, USB powered hub, and power sources. Position them as you wish on your layout.

Remember this order of start-up:

Turn on your DCC system/s interfaces/systems first
Turn on powered hub
Turn on computer monitor (if required)
Turn on the R-Pi

23. Now it is time to turn our attention to getting our R-Pi to run in Faceless mode. This way we do not need a keyboard, monitor or mouse to run it as our Access Point and WiThrottle. So in this configuration it will be great for our exhibition layouts.

To begin with you will first need to set WiThrottle to autostart when JMRI starts up. So startup DecoderPro as before.

Now under ‘Edit’ on the menu bar, select ‘Preferences’
Select Start Up
Under the ‘Actions’ tab, click the Add Action button and set Start WiThrottle Server on the drop down list to automatically start at Start up.
Click Save
When asked, restart the application for the changes to take effect.

Once done, close down DecoderPro. So from now on, whenever you start up the DecoderPro, the WiThrottle will also start up.

24. Next we need to make DecoderPro itself start up by itself whenever the R-Pi is turned on. First part is to create a profile for this. So turn your R-Pi on and log into it.

The older versions of JMRI used a slightly different method to setup what is called Faceless mode. Under version 3.8 we get to play with the new “profile” files a tad. Now first up we need to setup a profile for use with our Faceless mode.

Now under Edit on the menu bar, select Preferences, then select Config Files.
Click on New and give your new profile a name. I used MyFacelessMode as my name.
Now the Status of your new profile should show as “Active profile on restart”.
So hit Save and restart the JMRI. It should restart and be sitting at the Connections page of Preferences.
So add the details into this profile, the same as before:

So I selected NCE as the System Manufacturer.
Next I selected NCE USB as the System Connection.
Next select /dev/ttyUSB0 in the Serial port dropdown menu under the Settings section.
My USB version I set to V6.x.x as that is what I have.
My system I selected as PowerCAB.

Also select Start Up, then the ‘Actions’ tab, then click the Add Action button and set Start WiThrottle Server on the drop down list to automatically start at Start up.

Now if you want a fixed port number for you WiThrottle, then in the WiThrottle section look at the Network option. Tick the box and give it a 5 digit number (make it below 65000 or there abouts).

Click Save and restart JMRI when asked to.

At this point you could test a train to make sure you have it right or just trust you are following the instructions correctly.

25. Now shutdown the JMRI for the next step where we make the configuration file for the autostart. At a command prompt on you R-Pi, make a new file:

sudo cp /home/pi/.jmri/DecoderProConfig2.properties /home/pi/.jmri/JmriFacelessConfig3.properties

Now let’s edit this new file and make it autostart:

sudo nano /home/pi/.jmri/JmriFacelessConfig3.properties

Now change the line:

<entry key="autoStart">false</entry>

To now be:

<entry key="autoStart">true</entry>

Now save and exit the file.

26. Finally we will edit the R-Pi’s start up file to start JMRI at boot time. So at the command prompt we will edit the startup file:

sudo nano /etc/rc.local

Add the following line so it is the second last line. Copy it exactly, as if you haven’t already guessed, Linux, of which Raspbian is a version, is case sensitive when you type. So a capital letter is different in a command than a lower case letter and so on. And the ampersand at the end of the line means something too.

sudo –u pi /home/pi/JMRI/JmriFaceless &

The last line of course will therefore be “exit 0”.
Now save and exit the file.

You can now reboot your R-Pi and JMRI should now start up as will the WiThrottle. I’ll now be able to connect this one to the club exhibition layout so we can use our tablets and phones to drive our trains at our next show.

27. If at any time you wish to cancel the JMRI Faceless mode then:

Power off the R-Pi (pull out the power lead)
Connect up the computer screen and keyboard
Reconnect the power
Login to the R-Pi and at the command prompt type:

killall java

You can then comment out the execution of JmriFaceless from the startup script if you are intending to work on JMRI, etc. So at the prompt:

                sudo nano /etc/rc.local

Now just put a hash in front the second last line. It should then look like:

sudo -u pi /home/pi/JMRI/JmriFaceless &


Save the file and exit.

So you are now up and running with a Raspberry Pi for remote controlling of you locos. For shutting down I plan on just pulling the power plug. It can't damage the components at all, but in the long term it might corrupt the SD card. So you can always make a backup copy onto another SD card and carry a spare. You can reburn the failed one when you get near your desktop computer. Of course you need to take a copy first - that you do with something like the "Win32DiskImager" which is free on the internet.


No comments:

Post a Comment