From 02baebe92bdbaa86d07b5cb28ef280d8348fa9b0 Mon Sep 17 00:00:00 2001 From: Agentino007 Date: Fri, 10 Nov 2023 19:52:22 +0300 Subject: [PATCH 1/5] encoder commands added --- step_driver_g071_api/step_driver.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/step_driver_g071_api/step_driver.py b/step_driver_g071_api/step_driver.py index 70e0fff..1073c7b 100644 --- a/step_driver_g071_api/step_driver.py +++ b/step_driver_g071_api/step_driver.py @@ -37,6 +37,7 @@ def __init__(self, max_pos: int = None): self._commands: dict = { 'MOVE': 0x01, + 'UPDATE': 0x02, 'INIT': 0x03, 'STOP': 0x04 } @@ -47,6 +48,7 @@ def __init__(self, self._address = modbus_address self._speed_to_search_home_pos = speed_to_search_home_pos self._max_position = max_pos + self._encoder = 0 def _get_status(self) -> bool: return self._status @@ -122,4 +124,15 @@ def _update_info(self) -> None: self._status = bool(received_data[0]) self._current_pos = unpack(' None: + """Update encoder value""" + with self.device: + received_data = self.device.read_holding_registers(slave=self._address, + count=1, + address=12).registers + self._encoder = unpack(' int: + return self._encoder status = property(fget=_get_status) + encoder = property(fget=_get_encoder) From 569fe19663a34d001f03e1b792aee4f362672e8f Mon Sep 17 00:00:00 2001 From: Agentino007 Date: Fri, 10 Nov 2023 19:55:26 +0300 Subject: [PATCH 2/5] added cmd=2 and then read encoder register --- step_driver_g071_api/step_driver.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/step_driver_g071_api/step_driver.py b/step_driver_g071_api/step_driver.py index 1073c7b..fcb70d0 100644 --- a/step_driver_g071_api/step_driver.py +++ b/step_driver_g071_api/step_driver.py @@ -126,6 +126,10 @@ def _update_info(self) -> None: def _update_encoder(self) -> None: """Update encoder value""" + with self.device: + self.device.write_registers(slave=self._address, + address=0, + values=[self._commands['UPDATE']]) with self.device: received_data = self.device.read_holding_registers(slave=self._address, count=1, From 16227c42e44e07716ef1b04824851ee85281b587 Mon Sep 17 00:00:00 2001 From: gelio5 Date: Sat, 11 Nov 2023 00:05:11 +0300 Subject: [PATCH 3/5] Update pylint.yml --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 372d6a2..8e4d444 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -21,4 +21,4 @@ jobs: pip install pylint - name: Analysing the code with pylint run: | - pylint $(git ls-files '*.py') --logging-format-style=fstr + pylint $(git ls-files '*.py') --disable=logging-fstring-interpolation From 13ef9db57847d2ebad4f83e5405424292a879ac4 Mon Sep 17 00:00:00 2001 From: Agentino007 Date: Mon, 13 Nov 2023 14:49:01 +0300 Subject: [PATCH 4/5] fixed tasks: type hint, _update_encoder() description --- step_driver_g071_api/step_driver.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/step_driver_g071_api/step_driver.py b/step_driver_g071_api/step_driver.py index fcb70d0..5d6aab0 100644 --- a/step_driver_g071_api/step_driver.py +++ b/step_driver_g071_api/step_driver.py @@ -48,7 +48,7 @@ def __init__(self, self._address = modbus_address self._speed_to_search_home_pos = speed_to_search_home_pos self._max_position = max_pos - self._encoder = 0 + self._encoder: int = 0 def _get_status(self) -> bool: return self._status @@ -125,7 +125,7 @@ def _update_info(self) -> None: self._current_pos = unpack(' None: - """Update encoder value""" + """Update encoder value by register 13 READ, expected range [0 ... 4095]""" with self.device: self.device.write_registers(slave=self._address, address=0, From d881b305ecff23c8bab71386b0e0a7719fb40470 Mon Sep 17 00:00:00 2001 From: Vladislav Reznik Date: Tue, 14 Nov 2023 16:45:19 +0300 Subject: [PATCH 5/5] v.0.9 --- setup.py | 2 +- step_driver_g071_api/step_driver.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fe09dd5..f7688ad 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name='step_driver_g071_api', - version='0.8', + version='0.9', packages=['step_driver_g071_api'], url='https://github.com/gelio5/step_driver_G071_API.git', license='MIT', diff --git a/step_driver_g071_api/step_driver.py b/step_driver_g071_api/step_driver.py index 5d6aab0..3f22c29 100644 --- a/step_driver_g071_api/step_driver.py +++ b/step_driver_g071_api/step_driver.py @@ -30,6 +30,8 @@ class StepDriver: For simultaneously objects use moving methods in thread with pause between threads <= 50 ms. """ + # pylint: disable=too-many-instance-attributes + def __init__(self, port: str, modbus_address: int,