Routing and pylogix



I'm finally adding the ability to route packets to pylogix.  I've been asked about it a few times, a pull request was even submitted at one point.  The main reason I haven't added this feature is because I didn't have the hardware to be able to test it, so I didn't want to add features which I could not support myself.

I have a L30ER at home that I do all of my testing on. I was able to scrounge up and borrow a CLX rack with a few ENBT modules, a DNB module as well as a DeviceNET Point I/O adapter.  This gives me enough hardware to do some of the basic testing that needs to be done, testing routing over Ethernet as well as DeviceNET.  ControlNET works the same as DeviceNET, so if DNET works, so should CNET.  For the time being, I'll be pushing these changes to the route branch to get feedback.

Added to the PLC class is the parameter .Route.   Since route path parameters are in pairs, you will use a list of tuples to specify the path route.  Ex. comm.Route = [(1, 2), (2, '192.168.1.10')].  If you've ever had to setup a Message route, it's the same idea.  I'll do my best to describe here how to determine a route.

We are going to be routing through the CLX chassis, to the L30ER as well as the ADN Point I/O adapter for my examples.  Here is the makeup of my CLX rack:

[0] = ENBT - 192.168.1.1
[4] = ENBT - 10.10.10.9
[6] = DNB - Node 0













My computer is connected to the ENBT in slot 0.  My L30ER is connected to the ENBT in slot 4, which has the IP address of 10.10.10.9.  Also, connected to the DNB is my DeviceNET Point I/O adapter at node 2.

If you are here because I asked for help testing and you already have pylogix installed, it would be worth setting up a virtual environment.  Here is a post that describes setting it up on Windows.  Virtualenv will let you install specific versions of python and python modules without disturbing your current installs.

Once you set up your virtualenv and activate it, you can install the pylogix routing branch:

pip install git+https://github.com/dmroeder/pylogix.git@routing


Example 1:

In order to read a tag from the L30ER, we need to connect to the ENBT in slot 0, route through the backplane to slot 4, out the Ethernet port to get to the L30ER.  Our route is going to look like this:

[(1, 4), (2, '10.10.10.9')]

  • 1 = Backplane
  • 4 = the slot we need to go out once we hit the backplane
  • 2 = The Ethernet port of the ENBT in slot 4 (this is always 2)
  • 10.10.10.9 = IP address of the L30ER we are after
Here's a code example:



Example 2:

For this example, we'll get our DeviceNET Point I/O adapter's properties.  Similar to the previous example, we'll be routing through the backplane to slot 6 (where the DNB is located) and out to node 2, which is our Point I/O adapter.  Here is the code:

Comments

Popular Posts