Skip to content

Remote and Local Memory Configuration#96

Draft
Poikilos wants to merge 35 commits into
bobjacobsen:mainfrom
Hierosoft:configuration
Draft

Remote and Local Memory Configuration#96
Poikilos wants to merge 35 commits into
bobjacobsen:mainfrom
Hierosoft:configuration

Conversation

@Poikilos
Copy link
Copy Markdown
Contributor

@Poikilos Poikilos commented May 19, 2026

Supercedes (includes) #95

This PR has two major additions: (1) configuration of remote nodes, and (2) configuration of a local node.

Details on (2)'s progress: Requires handling memory configuration protocol messages on the Python side. As for the example I started, it is not complete. To understand why it is structured the way it is: Other examples are created from the perspective of a configuration tool. However, the new example is meant as a generic guide for implementing a typical node in Python. Therefore, no separate virtual node is created, and the node has its own CDI and memory bytearray (eventually, a handler could be used to set variables in the program in addition to that, using struct.unpack to read back whatever the remote node wrote, though that step wouldn't be necessary if we were not doing emulation and instead were using a chip, in which case the firmware would read the written space directly). The variables selected are port and timeout, just for the purpose of using some kind of concrete things that actually apply to the software and that the far node can edit, so we would be allowing some far node to configure the Configuration Tool itself technically, but that is just for the sake of an example of how someone would implement a configurable node. See "...help" sub-list under Tasks below for progress.

Tasks

(These changes are mostly directly related to enabling either remote or local memory configuration or both)

  • Make CDIVar getSize return 8 for eventid.
  • Add CDIVar setData to set a variable from raw data such as from the network safely (enforces size)
  • Implement replication helper method (calculates space and address for each variable).
  • Add LocalNode subclass of Node to handle its own CDI and set values at its own memory addresses (used in new example_node_memory_implementation.py)
  • Add DataProcessorMemo superclass as a memory configuration response in a case where CDI is not applicable
    • including when CDI/FDI load fails
    • and if the listen loop fails (log a console message if _dataProcessor is not set and DataProcessorMemo is discarded).
  • Move serialization and deserialization to a lower level of abstraction (Convert class in openlcb/convert.py) to make circular imports easier to avoid (and move related tests from test_memoryservice.py to test_convert.py)
  • Allow loading CDI from file or string (for purposes of creating a configurable local node, or for caching).
  • Implement save value (CV) to remote node using examples_gui and ensure address is correct.

I may need a little help:

  • I want to allow remote nodes to configure the LocalNode instance: See examples/example_node_memory_implementation.py. Its handleDatagram method is missing the actual code necessary. I'm not sure if a Datagram handler is the ideal place to parse out memory read requests from a far node or not anyway. Can you advise or help with this?

Poikilos and others added 30 commits March 18, 2026 17:44
…d make them more widely available and testable.
…nt). Add memoryService property so client code can register handlers.
…dd a type hint. Reduce logging (use info level for memory read).
…e. Add fromNumber. Change cache_cdi_path to classmethod. Add fromNumber to MemorySpace enum. Add force_end option in _memoryReadSuccess (reserved for future use).
…edTree, extractCDIVarMemos and related features. Add setData and enforce valid size(s).
…thod: deserializeMC2ndByte. Decode errorCode and collect error string (if present) from Datagram in rejectedReply. Add getBeforeNull for deserializing strings.
… _space value instead of causing unclear downstream error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants