Skip to content

Commit

Permalink
Merge pull request #13 from ottowayi/develop
Browse files Browse the repository at this point in the history
minor refactoring, documentation updates
  • Loading branch information
ottowayi authored Feb 21, 2020
2 parents e72c8b3 + eee5469 commit cecea99
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 164 deletions.
13 changes: 6 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ The package can be installed from
PIP:
::

pip install git+https://github.com/ottowayi/pycomm3.git

Eventually this library will be published to PyPI when it's ready.
pip install pycomm3


Basic Usage
Expand Down Expand Up @@ -94,7 +92,7 @@ Reading/Writing Tags
--------------------

Reading or writing tags is as simple as calling the ``read`` and ``write`` methods. Both methods accept any number of tags,
and will automatically pack multiple tags into a _Multiple Service Packet Service (0x0A)_ while making sure to stay below the connection size.
and will automatically pack multiple tags into a *Multiple Service Packet Service (0x0A)* while making sure to stay below the connection size.
If there is a tag value that cannot fit within the request/reply packet, it will automatically handle that tag independently
using the *Read Tag Fragmented (0x52)* or *Write Tag Fragmented (0x53)* requests.
Other similar libraries do not do this automatically, this library attempts to be as seamless as possible.
Expand All @@ -114,9 +112,10 @@ indicate either the CIP error or exception that was thrown. ``Tag.__bool__()``
``type`` will indicate the data type of the tag and include ``[<length>]`` if multiple array elements are requested.
``value`` will contain the value of the tag either read or written, structures (read only) will be in the form of a
``{ attribute: value, ... }``. Even though strings are technically structures, both reading and writing support
automatically converting them to/from normal string objects. Any structures that contain a DINT and an array of SINTs
will be treated as a string. Reading of structures as a whole is supported as long as no attributes have External Access
set to None (CIP limitation). Writing structures as a whole is not supported (for the time being) except for string objects.
automatically converting them to/from normal string objects. Any structures that have only the attributes ``LEN`` (DINT)
and ``DATA`` (array of SINT) will automatically be treated as strings. Reading of structures as a whole is supported
as long as no attributes have External Access set to None (CIP limitation). Writing structures as a whole is not
supported (for the time being) except for string objects.


Examples::
Expand Down
2 changes: 1 addition & 1 deletion pycomm3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# SOFTWARE.
#

__version_info__ = (0, 4, 0)
__version_info__ = (0, 4, 1)
__version__ = '.'.join(f'{x}' for x in __version_info__)

from typing import NamedTuple, Any, Union, Optional
Expand Down
13 changes: 6 additions & 7 deletions pycomm3/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ def info(self):
def name(self):
return self._info.get('name')

def _check_reply(self, reply):
raise NotImplementedError("The method has not been implemented")

def new_request(self, command):
""" Creates a new RequestPacket based on the command"""
cls = REQUEST_MAP[command]
Expand Down Expand Up @@ -361,8 +358,8 @@ def _parse_identity_object(reply):
major_fw = int(reply[6])
minor_fw = int(reply[7])
status = f'{unpack_uint(reply[8:10]):0{16}b}'
serial_number = f'{unpack_udint(reply[10:12]):0{8}x}'
product_name_len = int(reply[12])
serial_number = f'{unpack_udint(reply[10:14]):0{8}x}'
product_name_len = int(reply[14])
tmp = 15 + product_name_len
device_type = reply[15:tmp].decode()

Expand Down Expand Up @@ -427,13 +424,11 @@ def open(self):
return False
return True
except Exception as e:
# self.clean_up()
raise CommError(e)

def close(self):
"""
socket close
:return: true if no error otherwise false
"""
errs = []
try:
Expand Down Expand Up @@ -468,6 +463,10 @@ def clean_up(self):
# OLD CODE - to be removed
#
# --------------------------------------------------------------

def _check_reply(self, reply):
raise NotImplementedError("The method has not been implemented")

def nop(self):
""" No replay command
Expand Down
Loading

0 comments on commit cecea99

Please sign in to comment.