Giter VIP home page Giter VIP logo

rocoz21's Introduction

RocoZ21

Python library for interfacing with Roco Z21 DCC Command Station

By Marcel van Oosterwijk

Blog: Marcel's Explorations in Automation www.marcelvanoosterwijk.com

version 1.0, 2019-07-28

Based on "Z21 LAN Protocol Specification" version 1.09 by Roco

Supported functions in this library:

  1. System, status, versions:

2.1 LAN_GET_SERIAL_NUMBER (send and receive)

2.2 LAN_LOGOFF (send)

2.3 LAN_X_GET_VERSION (send and receive)

2.4 LAN_X_GET_STATUS (send)

2.5 LAN_X_SET_TRACK_POWER_OFF (send)

2.6 LAN_X_SET_TRACK_POWER_ON (send)

2.7 LAN_X_BC_TRACK_POWER_OFF (receive)

2.8 LAN_X_BC_TRACK_POWER_ON (receive)

2.9 LAN_X_BC_PROGRAMMING_MODE (receive)

2.10 LAN_X_BC_TRACK_SHORT_CIRCUIT (receive)

2.11 LAN_X_UNKNOWN_COMMAND (receive)

2.12 LAN_X_STATUS_CHANGED (receive)

2.13 LAN_X_SET_STOP (send)

2.14 LAN_X_BC_STOPPED (receive)

2.15 LAN_X_GET_FIRMWARE_VERSION (send and receive)

2.16 LAN_SET_BROADCASTFLAGS

2.17 LAN_GET_BROADCASTFLAGS (send and receive)

2.18 LAN_SYSTEMSTATE_DATACHANGED (receive)

2.19 LAN_SYSTEMSTATE_GETDATA (send)

2.20 LAN_GET_HWINFO (send and receive)

2.21 LAN_GET_CODE (send and receive)

  1. Driving:

4.1 LAN_X_GET_LOCO_INFO (send)

4.2 LAN_X_SET_LOCO_DRIVE (send)

4.3 LAN_X_SET_LOCO_FUNCTION (send)

4.4 LAN_X_LOCO_INFO (receive)

  1. Switching:

5.1 LAN_X_GET_TURNOUT_INFO (send)

5.2 LAN_X_SET_TURNOUT (send)

5.3 LAN_X_TURNOUT_INFO (receive)

  1. Feedback - R-Bus:

7.1 LAN_RMBUS_DATACHANGED (receive)

7.2 LAN_RMBUS_GETDATA (send)

Out of scope are:

  1. Settings

  2. Reading and writing decoder CVs

  3. Railcom

  4. LocoNet

  5. CAN

This library is implemented as a facad for the Z21 Command Station. The design pattern is Singleton, assuming only one command station is to be used. As such the library is a set of individual functions rather than a class.

The programming style is based on functional programming where possible. This means that all functions are pure, i.e. are stateless and contain no side effects. Only the final IO functions are non-pure. All functions that interpret incoming messages have correctness checks. This may be unnecessary, assuming that the Z21 will not send any incorrect messages and no errors are made during the handling of incoming messages in this library. Variables are used to keep the functions readable and match the specifications. They only exist within the context of the functions. No global variables are used. Also, the variables once created, are never mutated.

Comments beyond reference of the functions to the specifications are limited to a minumum.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.