[Twisted-Python] Twisted Allen-Bradley PLC Protocol

Paul Campbell paul at ref.nmedia.net
Tue Mar 8 20:43:46 EST 2005

I've successfully gotten twisted to talk to Allen Bradley PLC 5's using
Ron Gage's "ABEL" library as a template. Needless to say, the twisted way
is cleaner and easier to maintain (in my opinion at least).

However, there's a slight twist to the code and I'm trying to think if there's
a better way, and the protocol is similar to so many other things (SSL comes
to mind).

To communicate with AB PLC's, first you initiate a TCP/IP connection. This
is text book twisted. Second, you initiate communication using a "link layer"
protocol. Once that is established, THEN communication progresses using yet
another protocol layer ("PCCC" or "DF-1" or "CSP" depending on what document
you are reading).

Right now, I simply wrote my "connectionMade" function set self.attached=0 and
then initiate a "send connect command" function. The "received connection"
function sets self.attached=1. All other commands simply to a
reactor.callLater(1,self.func) and float around in the reactor buffer until
self.attach==1 returns with good news.

It seems to me that what we have here is really a protocol stack, similar in
nature to the "LineReceiver" type protocol or perhaps it should be set up
as an adapter (component architecture). Then in this case, the packet/protocol
gets passed up through the layers and the "link layer" occupies the correct
status of being a lower level layer. Or else to support say serial
communication on an RS-232 or RS-485 network later, it could be done as a
component arrangement.

So, does this make any sense? What is the "design pattern" in this case in

More information about the Twisted-Python mailing list