linux-automation / lxa-iobus

Linux Automation IOBus server
https://lxa-iobus.readthedocs.io/en/latest/
Apache License 2.0
3 stars 4 forks source link

Use predictable device names in REST URLs #5

Closed hnez closed 3 years ago

hnez commented 3 years ago

IOBus devices sold by the Linux Automation GmbH are delivered with a serial number printed on them that looks something like this: 00005.00026. These are two blocks of zero-padded decimal numbers (product class.serial number).

CANOpen addresses are formatted as hexadecimal numbers and contain the serial number as last component. The device above has the address: 00001287.00000002.00000003.0000001a. The iobus-server abbreviates this to IOMux-0000001a and uses it in the REST URLs. Due to the serial number being expressed as hexadecimal these URLs do however look nothing like the serial number printed on the device.

This commit tries to fix that by allowing both the 00005.00026 format, as well as the IOMux-0000001a format in URLs and prefering the former when listing nodes.

This change affects the following projects. An [x] indicates that the documentation was updated accordingly:

jluebbe commented 3 years ago

I see some potential issues with this:

SmithChart commented 3 years ago

I see some potential issues with this:

* the hex-encoding is confusing compared to the decimal label

This is true. We could change to decimal representation in list and URLs.

* the product ID is not really relevant to the user, especially in config files

I would say that the product-ID is a relevant as the IOMux-prefix in the example above. Even worse IOMux is neither part of the product label nor is it printed on the PCB.

* zero padding requires deciding on a fixed length now without much benefit

I can agree on that.

* there would be multiple URLs per node (or there would need to be an API to "resolve" user-level names to node URLs, requiring more coordination between labgrid and the iobus server)

I guess this discussion boils down to the question how we want to represent our nodes in the UI. We currently plan to have the following label on PCBs and housings: fileqWNRzp

I think we should try to make it as intuitive as possible to map this label to the node in the UI and to the URL. I see the following ways to archive this:

What do you think?

hnez commented 3 years ago

A consensus was found on how the device names should be formatted and i will start implementing it and update this PR accordingly.

hnez commented 3 years ago

I've updated the PR with an implementation that results in URLs formatted as shown above. Feel free to review the changes.

hnez commented 3 years ago

Hi Florian,

I've changed Pin.writeso that it returns RuntimeErrorinstead of ValueError. I've also rebased this branch on top of master to resolve a merge conflict in lxa_iobus/lpc11xxcanisp/firmware/versions.py.