bobjacobsen / python-openlcb

MIT License
2 stars 1 forks source link

example_node_implementation has a hard-coded localNodeID #28

Closed Poikilos closed 4 months ago

Poikilos commented 4 months ago

Should the node ID be determined by the network somehow in a real situation? If possible please update example or explain. I will read the LCC Standard again but have trouble connecting it to practicals.

bobjacobsen commented 4 months ago

Each node has to have a unique node ID assigned when it is constructed.

For example, a hardware node will have its unique node ID programmed into it as part of assembling the node. The ID is usually written on the board somewhere so it can be found for configuration after installing it on the layout.

For these examples, that's called localNodeID. I gave it a value from the range that's assigned to me (see http://registry.openlcb.org/uniqueidranges). If a real node was made from these examples, other unique value(s) should be assigned.

Some of these examples reach out and touch another node, e.g. to send it a datagram. A node ID is also needed for that (though see some of the tests in OlcbChecker for an example of "find a node, any node"), so I entered a value as farNodeID. The value I gave it was the CS-105 that I have on my desk. Your value for that would vary.

When creating a node like a RR-Cirkits node board, you don't really have to worry about the far node. The only time such a board needs to specifically address another node is when that other node has issued a request to it. I.e. You'll get the node ID from the other node dynamically as it requests you to talk to it, and you can just reply using that info.

Node like JMRI or a firmware downloader are query the network to find all the node ID that are out there, then e.g. ask the user to select one.

Poikilos commented 4 months ago

Right, I recall that devices must generally be serialized (with an LCC ID in the range a given organization or individual has been using/assigned). However, generally only one copy of the software would run on an LCC network, therefore a unique LCC ID could be tied to a product ID (as opposed to an even more unique serial like hardware does).

Some of these examples reach out and touch another node, e.g. to send it a datagram. A node ID is also needed for that (though see some of the tests in OlcbChecker for an example of "find a node, any node"), so I entered a value as farNodeID. The value I gave it was the CS-105 that I have on my desk. Your value for that would vary.

When creating a node like a RR-Cirkits node board, you don't really have to worry about the far node. The only time such a board needs to specifically address another node is when that other node has issued a request to it. I.e. You'll get the node ID from the other node dynamically as it requests you to talk to it, and you can just reply using that info.

Node like JMRI or a firmware downloader are query the network to find all the node ID that are out there, then e.g. ask the user to select one.

Ok thanks, that also helps. I'll suggest some code comments and will also start on my LCC tutorials idea (A document with headings in a practical order like "Choose an ID", "List Nodes" etc).