-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from ottowayi/develop
Develop
- Loading branch information
Showing
15 changed files
with
94 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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): | ||
""" | ||
|
@@ -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, | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', ] | ||
|
||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
||
|
@@ -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 | ||
|
||
|
@@ -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 | ||
|
||
|
@@ -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 | ||
|
||
|
@@ -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 | ||
|
||
|
@@ -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 | ||
|
@@ -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 | ||
|
||
|
@@ -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 | ||
|
||
|
@@ -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 | ||
|
||
|
@@ -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): | ||
|
@@ -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): | ||
|
Oops, something went wrong.