-
Notifications
You must be signed in to change notification settings - Fork 207
Description
It is possible to create a custom SDO reader when using LocalNode
. If this function returns anything else than None
this value will be used as a response to the remote client.
Lines 79 to 83 in 09f6e9e
# Try callback | |
for callback in self._read_callbacks: | |
result = callback(index=index, subindex=subindex, od=obj) | |
if result is not None: | |
return obj.encode_raw(result) |
However, this is not the case on SDO write. There is callbacks that can be used to deliver the value to a custom system. There is, however, no ability to prevent it from storing the data in its data store.
Lines 118 to 124 in 09f6e9e
# Try callbacks | |
for callback in self._write_callbacks: | |
callback(index=index, subindex=subindex, od=obj, data=data) | |
# Store data | |
self.data_store.setdefault(index, {}) | |
self.data_store[index][subindex] = bytes(data) |
I believe a similar solution should be used here. If the write callbacks return anything else than None
then the data should not be stored in the data store.
The use-case for this is when implementing a simulator of our hardware devices using LocalNode
. We have some special SDOs that require some special responses. The callbacks for both reads and writes provides everything that's needed for that, except the data store is filling up with data that should not be present in the store.