Package: metlinkpid
Themetlinkpidmodule provides a class to operate Metlink LED passenger information displays:>>> from metlinkpid import PID
>>> with PID.for_device('/dev/ttyUSB0') as pid:
...     pid.send('12:34 FUNKYTOWN~5_Limited Express|_Stops all stations except East Richard')It also provides a function to inspect raw display data,
both with and without checksumming & packet-framing:>>> from metlinkpid import inspect
>>> inspect(b'\x10\x02\x01\x44\x00\x1D\x00\x00\x00\x4F\x50\x45\x4E\x0A\x46\x4F\x52\x20\x42\x55\x53\x49\x4E\x45\x53\x53\x0D\x8F\xDF\x10\x03')
DisplayMessage.from_str('V0^OPEN_FOR BUSINESS')
>>> inspect(b'\x01\x44\x00\x1D\x00\x00\x00\x53\x54\x49\x4C\x4C\x20\x4F\x50\x45\x4E\x0A\x46\x4F\x52\x20\x42\x55\x53\x49\x4E\x45\x53\x53\x0D')
DisplayMessage.from_str('V0^STILL OPEN_FOR BUSINESS')
>>> inspect(b'\x01\x50\x6F')
PingMessage(unspecified_byte=111)InstallationInstall fromPyPIusingpip:pip install -U metlinkpidBasic usageFind the deviceDetermine the device to which the display is connected.
On Linux, this can be achieved by disconnecting the display from the computer & reconnecting,
then inspecting the contents ofdmesgoutput for USB attachment messages:[    3.010816] usb 1-1.4: FTDI USB Serial Device converter now attached to ttyUSB0The above output indicates that the display is reachable through/dev/ttyUSB0.Display a messageNext, write & run a Python script
that connects to that device location
and callsPID.send():from metlinkpid import PID
with PID.for_device('/dev/ttyUSB0') as pid:
    pid.send('12:34 FUNKYTOWN~5_Limited Express|_Stops all stations except East Richard')The PID should display the specified message instantly,
but after approximately one minute the display will self-clear.Keep the message upTo prevent the message from clearing,
the display can bepingedat a regular interval:from time import sleep

from metlinkpid import PID
with PID.for_device('/dev/ttyUSB0') as pid:
    pid.send('12:34 FUNKYTOWN~5_Limited Express|_Stops all stations except East Richard')

    while True:
        sleep(10)
        pid.ping()Message formatUse the|character to separatepagesof a message:pid.send('V10^FIRST_PAGE|V10^SECOND_PAGE|V10^THIRD_PAGE')The message in the abovesend()call has three pages:V10^FIRST_PAGE,V10^SECOND_PAGE, andV10^THIRD_PAGE.Page formatEverything in a page up to and including the^affects the display of the page,
and is not included in the output.
The letter specifies theanimationand can beVfor a vertical upwards scroll,Hfor a horizontal scroll,
orNfor no animation.
The number specifies thedelay(in roughly quarter-seconds)
after the animation finishes and before the next page (or first page again) is shown.Text after~will be right-aligned on the current line,
and text after_will appear on the next line.
Each page in the above example therefore spans two lines.Some ASCII charactersare notavailable for display,
and some “extended” Unicode charactersareavailable.
Full details are in thedocumentationfor thePageclass.Known issuesAnimation typesNot all known page animation types are implemented yet.PIDclass unit testingUnit tests have not yet been written for thePIDclass.
A suitable serial port mocking interface is yet to be found.SupportThemetlinkpidmodule is fully documented.
All further usage & development details can be found in the documentation.
Bug reports, feature requests, and questions are welcome via the issue tracker.Documentation:https://python-metlinkpid.readthedocs.ioIssue tracker:https://github.com/Lx/python-metlinkpid/issuesChanges1.0.2Add optionalignore_responseparameter
to allow PID response errors to be ignored.1.0.1Add support for Python 3.6.1.0.0Initial release.ContributePull requests for both code and documentation improvements
are gratefully received and considered.GitHub repository:https://github.com/Lx/python-metlinkpidLicenseThis project is licensed under theMIT License.