Skip to content

Prevent storing of SDO write data in local store when using callbacks in LocalNode #598

@sveinse

Description

@sveinse

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.

# 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.

# 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions