Skip to content

Commit

Permalink
Merge pull request #63 from ottowayi/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ottowayi authored Aug 5, 2020
2 parents 37db92f + dbba106 commit b53d05e
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 70 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The MIT License (MIT)

Copyright (c) 2020 Ian Ottoway
Copyright (c) 2014 Agostino Ruscito
Copyright (c) 2019 Ian Ottoway

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 1 addition & 3 deletions pycomm3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
#
# const.py - A set of structures and constants used to implement the Ethernet/IP protocol
#
# Copyright (c) 2019 Ian Ottoway <[email protected]>
# Copyright (c) 2020 Ian Ottoway <[email protected]>
# Copyright (c) 2014 Agostino Ruscito <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
24 changes: 24 additions & 0 deletions pycomm3/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,26 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2020 Ian Ottoway <[email protected]>
# Copyright (c) 2014 Agostino Ruscito <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#

__version_info__ = (0, 9, 1)
__version__ = '.'.join(f'{x}' for x in __version_info__)
4 changes: 1 addition & 3 deletions pycomm3/bytes_.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
#
# const.py - A set of structures and constants used to implement the Ethernet/IP protocol
#
# Copyright (c) 2019 Ian Ottoway <[email protected]>
# Copyright (c) 2020 Ian Ottoway <[email protected]>
# Copyright (c) 2014 Agostino Ruscito <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
14 changes: 6 additions & 8 deletions pycomm3/cip_base.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
#
# const.py - A set of structures and constants used to implement the Ethernet/IP protocol
#
# Copyright (c) 2019 Ian Ottoway <[email protected]>
# Copyright (c) 2020 Ian Ottoway <[email protected]>
# Copyright (c) 2014 Agostino Ruscito <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -71,7 +69,7 @@ class CIPDriver:
"""
An Ethernet/IP Client library for reading and writing tags in ControlLogix and CompactLogix PLCs.
"""
__log = logging.getLogger(__qualname__)
__log = logging.getLogger(f'{__module__}.{__qualname__}')

def __init__(self, path: str, *args, large_packets: bool = True, **kwargs):
"""
Expand Down Expand Up @@ -310,16 +308,16 @@ def _forward_open(self):
forward_open_msg = [
PRIORITY,
TIMEOUT_TICKS,
b'\x00\x00\x00\x00',
b'\x00\x00\x00\x00', # O->T produced connection ID, not needed for us so leave blank
self._cfg['cid'],
self._cfg['csn'],
self._cfg['vid'],
self._cfg['vsn'],
TIMEOUT_MULTIPLIER,
b'\x00\x00\x00',
b'\x01\x40\x20\x00',
b'\x00\x00\x00', # reserved
b'\x01\x40\x20\x00', # O->T RPI in microseconds, RPIs are not important for us so fixed value is fine
net_params,
b'\x01\x40\x20\x00',
b'\x01\x40\x20\x00', # T->O RPI
net_params,
TRANSPORT_CLASS,
]
Expand Down
6 changes: 2 additions & 4 deletions pycomm3/clx.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
#
# const.py - A set of structures and constants used to implement the Ethernet/IP protocol
#
# Copyright (c) 2019 Ian Ottoway <[email protected]>
# Copyright (c) 2020 Ian Ottoway <[email protected]>
# Copyright (c) 2014 Agostino Ruscito <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -49,7 +47,7 @@ class LogixDriver(CIPDriver):
"""
An Ethernet/IP Client library for reading and writing tags in ControlLogix and CompactLogix PLCs.
"""
__log = logging.getLogger(__qualname__)
__log = logging.getLogger(f'{__module__}.{__qualname__}')

def __init__(self, path: str, *args, large_packets: bool = True, micro800: bool = False,
init_info: bool = True, init_tags: bool = True, init_program_tags: bool = False, **kwargs):
Expand Down
4 changes: 1 addition & 3 deletions pycomm3/const.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
#
# const.py - A set of structures and constants used to implement the Ethernet/IP protocol
#
# Copyright (c) 2019 Ian Ottoway <[email protected]>
# Copyright (c) 2020 Ian Ottoway <[email protected]>
# Copyright (c) 2014 Agostino Ruscito <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
4 changes: 1 addition & 3 deletions pycomm3/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
#
# const.py - A set of structures and constants used to implement the Ethernet/IP protocol
#
# Copyright (c) 2019 Ian Ottoway <[email protected]>
# Copyright (c) 2020 Ian Ottoway <[email protected]>
# Copyright (c) 2014 Agostino Ruscito <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
26 changes: 24 additions & 2 deletions pycomm3/map.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
from types import FunctionType
# -*- coding: utf-8 -*-
#
# Copyright (c) 2020 Ian Ottoway <[email protected]>
# Copyright (c) 2014 Agostino Ruscito <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#

__all__ = ['EnumMap', ]

Expand Down Expand Up @@ -30,7 +52,7 @@ def __new__(cls, name, bases, classdict):
return enumcls

def __getitem__(self, item):
val = self._members_.__getitem__(item.lower() if isinstance(item, str) else item)
val = self._members_.__getitem__(item.lower() if isinstance(item, str) else item)
if self._return_caps_only_ and isinstance(val, str):
val = val.upper()
return val
Expand Down
4 changes: 1 addition & 3 deletions pycomm3/packets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
#
# const.py - A set of structures and constants used to implement the Ethernet/IP protocol
#
# Copyright (c) 2019 Ian Ottoway <[email protected]>
# Copyright (c) 2020 Ian Ottoway <[email protected]>
# Copyright (c) 2014 Agostino Ruscito <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
30 changes: 14 additions & 16 deletions pycomm3/packets/requests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
#
# const.py - A set of structures and constants used to implement the Ethernet/IP protocol
#
# Copyright (c) 2019 Ian Ottoway <[email protected]>
# Copyright (c) 2020 Ian Ottoway <[email protected]>
# Copyright (c) 2014 Agostino Ruscito <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -41,7 +39,7 @@


class RequestPacket(Packet):
__log = logging.getLogger(__qualname__)
__log = logging.getLogger(f'{__module__}.{__qualname__}')
_message_type = None
_address_type = None
_timeout = b'\x0a\x00' # 10
Expand Down Expand Up @@ -150,7 +148,7 @@ def __repr__(self):


class SendUnitDataRequestPacket(RequestPacket):
__log = logging.getLogger(__qualname__)
__log = logging.getLogger(f'{__module__}.{__qualname__}')
_message_type = DataItem.connected
_address_type = AddressItem.connection
_response_class = SendUnitDataResponsePacket
Expand All @@ -162,7 +160,7 @@ def __init__(self, plc):


class ReadTagServiceRequestPacket(SendUnitDataRequestPacket):
__log = logging.getLogger(__qualname__)
__log = logging.getLogger(f'{__module__}.{__qualname__}')
type_ = 'read'
_response_class = ReadTagServiceResponsePacket

Expand Down Expand Up @@ -203,7 +201,7 @@ def __repr__(self):


class ReadTagFragmentedServiceRequestPacket(SendUnitDataRequestPacket):
__log = logging.getLogger(__qualname__)
__log = logging.getLogger(f'{__module__}.{__qualname__}')
type_ = 'read'
_response_class = ReadTagFragmentedServiceResponsePacket

Expand Down Expand Up @@ -259,7 +257,7 @@ def __repr__(self):


class WriteTagServiceRequestPacket(SendUnitDataRequestPacket):
__log = logging.getLogger(__qualname__)
__log = logging.getLogger(f'{__module__}.{__qualname__}')
type_ = 'write'
_response_class = WriteTagServiceResponsePacket

Expand Down Expand Up @@ -297,7 +295,7 @@ def __repr__(self):


class WriteTagFragmentedServiceRequestPacket(SendUnitDataRequestPacket):
__log = logging.getLogger(__qualname__)
__log = logging.getLogger(f'{__module__}.{__qualname__}')
type_ = 'write'
_response_class = WriteTagFragmentedServiceResponsePacket

Expand Down Expand Up @@ -376,7 +374,7 @@ def send(self):


class MultiServiceRequestPacket(SendUnitDataRequestPacket):
__log = logging.getLogger(__qualname__)
__log = logging.getLogger(f'{__module__}.{__qualname__}')
type_ = 'multi'
_response_class = MultiServiceResponsePacket

Expand Down Expand Up @@ -512,7 +510,7 @@ def _make_write_data_bit(tag_info, value, request_path):


class SendRRDataRequestPacket(RequestPacket):
__log = logging.getLogger(__qualname__)
__log = logging.getLogger(f'{__module__}.{__qualname__}')
_message_type = DataItem.unconnected
_address_type = AddressItem.uccm
_encap_command = EncapsulationCommand.send_rr_data
Expand All @@ -523,7 +521,7 @@ def _build_common_packet_format(self, addr_data=None) -> bytes:


class RegisterSessionRequestPacket(RequestPacket):
__log = logging.getLogger(__qualname__)
__log = logging.getLogger(f'{__module__}.{__qualname__}')
_encap_command = EncapsulationCommand.register_session
_response_class = RegisterSessionResponsePacket

Expand All @@ -532,7 +530,7 @@ def _build_common_packet_format(self, addr_data=None) -> bytes:


class UnRegisterSessionRequestPacket(RequestPacket):
__log = logging.getLogger(__qualname__)
__log = logging.getLogger(f'{__module__}.{__qualname__}')
_encap_command = EncapsulationCommand.unregister_session
_response_class = UnRegisterSessionResponsePacket

Expand All @@ -544,7 +542,7 @@ def _receive(self):


class ListIdentityRequestPacket(RequestPacket):
__log = logging.getLogger(__qualname__)
__log = logging.getLogger(f'{__module__}.{__qualname__}')
_encap_command = EncapsulationCommand.list_identity
_response_class = ListIdentityResponsePacket

Expand Down Expand Up @@ -629,7 +627,7 @@ def _encode_tag_index(index):


class GenericConnectedRequestPacket(SendUnitDataRequestPacket):
__log = logging.getLogger(__qualname__)
__log = logging.getLogger(f'{__module__}.{__qualname__}')
_response_class = GenericConnectedResponsePacket

def __init__(self, plc):
Expand Down Expand Up @@ -660,7 +658,7 @@ def build(self,


class GenericUnconnectedRequestPacket(SendRRDataRequestPacket):
__log = logging.getLogger(__qualname__)
__log = logging.getLogger(f'{__module__}.{__qualname__}')
_response_class = GenericUnconnectedResponsePacket

def __init__(self, plc):
Expand Down
Loading

0 comments on commit b53d05e

Please sign in to comment.