Skip to content

Commit

Permalink
Merge pull request #5 from m4tthew-d/m4tthew-d-patch-5
Browse files Browse the repository at this point in the history
Update plc.py
  • Loading branch information
m4tthew-d authored Aug 1, 2016
2 parents 4e98f74 + 0c8783d commit d9378a7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions plc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
from cip import CIP, CIP_Path, CIP_ReqConnectionManager, \
CIP_MultipleServicePacket, CIP_ReqForwardOpen, CIP_RespForwardOpen, \
CIP_ReqForwardClose, CIP_ReqGetAttributeList, CIP_ReqReadOtherTag
from enip_tcp import ENIP_TCP, ENIP_SendUnitData, ENIP_SendUnitData_Item, \
ENIP_ConnectionAddress, ENIP_ConnectionPacket, ENIP_RegisterSession, ENIP_SendRRData
from enip import ENIP_PACKET, ENIP_SendUnitData, ENIP_ConnectionAddress, \
ENIP_ConnectionPacket, ENIP_RegisterSession, ENIP_SendRRData

# Global switch to make it easy to test without sending anything
NO_NETWORK = False
Expand All @@ -56,7 +56,7 @@ def __init__(self, plc_addr, plc_port=44818):
self.sequence = 1

# Open an Ethernet/IP session
sessionpkt = ENIP_TCP() / ENIP_RegisterSession()
sessionpkt = ENIP_PACKET() / ENIP_RegisterSession()
if self.sock is not None:
self.sock.send(str(sessionpkt))
reply_pkt = self.recv_enippkt()
Expand All @@ -68,7 +68,7 @@ def connected(self):

def send_rr_cip(self, cippkt):
"""Send a CIP packet over the TCP connection as an ENIP Req/Rep Data"""
enippkt = ENIP_TCP(session=self.session_id)
enippkt = ENIP_PACKET(session=self.session_id)
enippkt /= ENIP_SendRRData(items=[
ENIP_SendUnitData_Item(type_id=0),
ENIP_SendUnitData_Item() / cippkt
Expand All @@ -92,7 +92,7 @@ def send_rr_mr_cip(self, cippkt):

def send_unit_cip(self, cippkt):
"""Send a CIP packet over the TCP connection as an ENIP Unit Data"""
enippkt = ENIP_TCP(session=self.session_id)
enippkt = ENIP_PACKET(session=self.session_id)
enippkt /= ENIP_SendUnitData(items=[
ENIP_SendUnitData_Item() / ENIP_ConnectionAddress(connection_id=self.enip_connid),
ENIP_SendUnitData_Item() / ENIP_ConnectionPacket(sequence=self.sequence) / cippkt
Expand All @@ -106,7 +106,7 @@ def recv_enippkt(self):
if self.sock is None:
return
pktbytes = self.sock.recv(2000)
pkt = ENIP_TCP(pktbytes)
pkt = ENIP_PACKET(pktbytes)
return pkt

def forward_open(self):
Expand Down

0 comments on commit d9378a7

Please sign in to comment.