JMRI - PacketScript
This page discusses using the JMRI libraries to test decoders for NMRA conformance, using a JMRI application called PacketScript. This capability is being actively developed, and this page will not always be up-to-date.
See also the JMRI technical documentation, as well as the Jython interface page for more information on scripting.
- Introduction
- This is a simple introduction that is still being developed
- Requirements
- You need to have jython installed on your computer, in addition to installing JMRI.
- Installation
- To install jython, download the installer from
http://prdownloads.sourceforge.net/jmri/jython_21.class?download
then go to where the download landed, and do
java jython-21
which should lauch a GUI which will prompt you through the install. If that fails, dojava jython-21 -o Jython-2.1 demo lib source
Check to make sure that the "jython" command works from the command line.On some MacOS systems, you may have to move the installed jython-2.1 directory to /Applications.
- Examples
-
% ./jmrithon -i packetscript/PacketScript.py
available routines:
send([1,2,3])
sendXOR([1,2,3])
sendBaseline( 0, "On", "Forward", "emergencystop" )
>>> send([1,2,3])
>>> s1 = sensors.provideSensor("12")
>>> s1.knownState
1
>>> if (s1.knownState == ACTIVE):
... print "OK"
... else :
... print "Not OK"
...
Not OK
- Limitations
-
Raw-mode" sending
Few command stations can send arbitrary bit-strings on their outputs. The original NMRA program had a sendRaw() capability that requires this, and is not yet implemented here.
Programming packets
Many command stations have separate programming and main outputs. It's not clear how this program should operate with those. Currently, the packets are sent to the main output.