From e559510a9acd0491e2ecb17efb8deef32c197346 Mon Sep 17 00:00:00 2001 From: wangWking <842749351@qq.com> Date: Thu, 27 Nov 2025 14:40:38 +0800 Subject: [PATCH 1/4] fix(280-api):Fixed an issue where the get_servo_data(4, 85) interface could not read servo parameters on 280 PI and JN version machines. --- pymycobot/common.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pymycobot/common.py b/pymycobot/common.py index 28a2cb2..09573ea 100644 --- a/pymycobot/common.py +++ b/pymycobot/common.py @@ -1198,7 +1198,17 @@ def read(self, genre, method=None, command=None, _class=None, timeout=None, real continue break elif len(datas) == 2: + if data == b'\xfe': + datas += data + data_len = -1 + else: + data_len = struct.unpack("b", data)[0] + datas += data + elif len(datas) == 3 and datas[:3] == b'\xfe\xfe\xfe' and data_len == -1: + # This resolves an issue where the `get_servo_data(4, 85)` interface + # on 280 PI and JN version machines cannot read parameters at address 85 of servo motor 4. data_len = struct.unpack("b", data)[0] + datas = datas[1:] datas += data elif len(datas) > 2 and data_len > 0: datas += data From 54f871f8db6bfcec89f2f01d6aa7afc6b2305661 Mon Sep 17 00:00:00 2001 From: wangWking <842749351@qq.com> Date: Thu, 27 Nov 2025 14:42:17 +0800 Subject: [PATCH 2/4] fix(280-api):When fixing packet loss issues, the read command was garbled. --- pymycobot/mycobot280.py | 12 +++++++++--- pymycobot/mycobot280socket.py | 11 ++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/pymycobot/mycobot280.py b/pymycobot/mycobot280.py index fcc2482..40573e0 100644 --- a/pymycobot/mycobot280.py +++ b/pymycobot/mycobot280.py @@ -150,12 +150,18 @@ def _res(self, real_command, has_reply, genre): data = self._read(genre) else: try_count = 0 + expected_genre = genre while try_count < 3: + self._serial_port.reset_input_buffer() self._write(self._flatten(real_command)) data = self._read(genre) - if data is not None and data != b'': - break - try_count += 1 + if not data or len(data) < 4: + try_count += 1 + continue + if data[3] != expected_genre: + try_count += 1 + continue + break else: return -1 if genre == ProtocolCode.SET_SSID_PWD: diff --git a/pymycobot/mycobot280socket.py b/pymycobot/mycobot280socket.py index 40f7d45..21f0132 100644 --- a/pymycobot/mycobot280socket.py +++ b/pymycobot/mycobot280socket.py @@ -140,12 +140,17 @@ def _res(self, real_command, has_reply, genre): data = self._read(genre, method='socket') else: try_count = 0 + expected_genre = genre while try_count < 3: self._write(self._flatten(real_command), "socket") data = self._read(genre, method='socket') - if data is not None and data != b'': - break - try_count += 1 + if not data or len(data) < 4: + try_count += 1 + continue + if data[3] != expected_genre: + try_count += 1 + continue + break else: return -1 if genre == ProtocolCode.SET_SSID_PWD: From 25c4cb8c9e4643e88ff1d3979cc3729c1d22c192 Mon Sep 17 00:00:00 2001 From: wangWking <842749351@qq.com> Date: Thu, 4 Dec 2025 18:02:47 +0800 Subject: [PATCH 3/4] perf(280-api): opt get_servo_data() api read data --- pymycobot/common.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/pymycobot/common.py b/pymycobot/common.py index 09573ea..dc2e506 100644 --- a/pymycobot/common.py +++ b/pymycobot/common.py @@ -1198,17 +1198,10 @@ def read(self, genre, method=None, command=None, _class=None, timeout=None, real continue break elif len(datas) == 2: - if data == b'\xfe': - datas += data - data_len = -1 - else: - data_len = struct.unpack("b", data)[0] - datas += data - elif len(datas) == 3 and datas[:3] == b'\xfe\xfe\xfe' and data_len == -1: - # This resolves an issue where the `get_servo_data(4, 85)` interface - # on 280 PI and JN version machines cannot read parameters at address 85 of servo motor 4. data_len = struct.unpack("b", data)[0] - datas = datas[1:] + if data_len < 0 or data_len > 30: + data_len = -1 + continue datas += data elif len(datas) > 2 and data_len > 0: datas += data From c25aff1bfabf11edffaae2d4377f2adf82d2fb9c Mon Sep 17 00:00:00 2001 From: wangWking <842749351@qq.com> Date: Wed, 10 Dec 2025 11:25:37 +0800 Subject: [PATCH 4/4] feat(280-api):Add support for pin 39 to the terminal I/O pin. --- pymycobot/error.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymycobot/error.py b/pymycobot/error.py index dd8ea94..782f9df 100644 --- a/pymycobot/error.py +++ b/pymycobot/error.py @@ -418,7 +418,7 @@ def public_check( check_0_or_1( parameter, value, - [19, 22, 23, 33], + [19, 22, 23, 33, 39], value_type, exception_class, int,