Skip to content

ports: Layout and content of the information shown by repr(object). #11055

@robert-hh

Description

@robert-hh

At the moment, the result of repr(object) when object is one created by the machine classes (and others) like a Pin object or UART object is somewhat inconsistent between the ports. And I contributed my share to the chaos. This inconsistency make it difficult to retrieve information if needed. So I suggest to harmonize that, knowing that such a change is both breaking and quite a bit of work. Not complicated, but a lot.
First thing would be to agree on the format. my suggestion would be the style and content used to instantiate the object in that port, with a minimum set of common information, and optional port specific information. So for a pin the result would e.g. be: pin-spec, mode=Pin.mode, pull=Pin.mode like 2, mode=Pin.OUT, pull=Pin.OFF. The pin-spec would have the form and content such that is can be used again to designate a pin, with a preference for a single integer. UART e.g. would be:
id, baudrate, tx=Pin(pin-spec), rx=Pin(pin-spec), bits=n, parity=UART.mode, stop=n, txbuf=n, rxbuf=n, ....,
PWM could be Pin(pin-spec), freq=nnn, duty_u16=nnn, invert=0|1, ..... No additional brackets of specifiers for a device type.
Using that, it is easier to parse such an information string and extract the required information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature requests, new feature implementations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions