-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug fixes, send/receive debug logs and Unsigned 24 support #267
base: master
Are you sure you want to change the base?
Changes from all commits
5141b19
3ce8ab4
bc06df4
3fb146e
659899d
9b9efb7
a8fcd87
d0d9bba
b14f43e
56b206a
a108eee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
.idea/ | ||
|
||
# C extensions | ||
*.so | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -219,6 +219,17 @@ def add_member(self, variable): | |
self.subindices[variable.subindex] = variable | ||
self.names[variable.name] = variable | ||
|
||
class Unsigned24(struct.Struct): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__("<I", *args, **kwargs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As previously noted, use |
||
|
||
def unpack(self, data, *args, **kwargs): | ||
if isinstance(data, bytearray): | ||
while len(data) < 4: | ||
data += b'\x00' | ||
else: | ||
logger.error(f"Unsigned24.unpack received wrong type - {type(data)}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use |
||
return super(Unsigned24, self).unpack(data, *args, **kwargs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another |
||
|
||
class Variable(object): | ||
"""Simple variable.""" | ||
|
@@ -231,6 +242,7 @@ class Variable(object): | |
INTEGER64: struct.Struct("<q"), | ||
UNSIGNED8: struct.Struct("B"), | ||
UNSIGNED16: struct.Struct("<H"), | ||
UNSIGNED24: Unsigned24(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be ordered by size? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
UNSIGNED32: struct.Struct("<L"), | ||
UNSIGNED64: struct.Struct("<Q"), | ||
REAL32: struct.Struct("<f"), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -562,7 +562,7 @@ def get_data(self): | |
data = data | (~((1 << self.length) - 1)) | ||
data = od_struct.pack(data) | ||
else: | ||
data = self.pdo_parent.data[byte_offset:byte_offset + len(self.od) // 8] | ||
data = self.pdo_parent.data[byte_offset:byte_offset + self.length // 8] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the cached value here seems like a good idea, but it does change the semantics. That should at least be explained in the commit message. Why not apply the same treatment in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't think of any reason len (self. OD) is used here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, I agree there are some corner cases in the code that don't deal well with mapping only some bits of an object. But to fix that properly, each use within By the way, my (hacky) solution so far was to adjust the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @acolomb This one |
||
|
||
return data | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -29,6 +29,9 @@ class SdoClient(SdoBase): | |||||||
#: Seconds to wait before sending a request, for rate limiting | ||||||||
PAUSE_BEFORE_SEND = 0.0 | ||||||||
|
||||||||
# Seconds to wait before next read attempt for response in queue. For delayed responses. | ||||||||
RETRY_DELAY = 0.0 | ||||||||
|
||||||||
def __init__(self, rx_cobid, tx_cobid, od): | ||||||||
""" | ||||||||
:param int rx_cobid: | ||||||||
|
@@ -89,6 +92,7 @@ def request_response(self, sdo_request): | |||||||
self.abort(0x5040000) | ||||||||
raise | ||||||||
logger.warning(str(e)) | ||||||||
time.sleep(self.RETRY_DELAY) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
def abort(self, abort_code=0x08000000): | ||||||||
"""Abort current transfer.""" | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,6 +172,7 @@ def segmented_download(self, command, request): | |
self.send_response(response) | ||
|
||
def send_response(self, response): | ||
logger.debug(f"Sending to {self.tx_cobid} data {response}.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another overly verbose log message. |
||
self.network.send_message(self.tx_cobid, response) | ||
|
||
def abort(self, abort_code=0x08000000): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a separate section for IDE stuff down below, if such things must be collected here.
This change seems unrelated though, so let's keep it in a separate commit / PR.