OpenLCB
C++ implementation of the OpenLCB model railroad layout control protocol. For Arduino, AVR-8, and ARM Cortex M3
Install / Use
/learn @Railstars/OpenLCBREADME
About
"OpenLCB" is a library for using the OpenLCB protocol on the Arduino platform (and on AVRs more generally). Insofar as it has been tested, it has been made to work on an Arduino Uno with an MCP2515 (using hardware SPI), and on an OpenLCB Dev Board (AT90CAN128). This library was assembled by D.E. Goodman-Wilson from the hard work of the OpenLCB team. see: http://openlcb.sf.net
License
See LICENSE.TXT
Features
- Unlimited (not really) virtual nodes permits a single piece of hardware to service several independent NodeIDs.
- Transparent handling of alias translation.
- Clever class organization ;)
- Distinct layers are handled by distinct classes. The Datagram_Handler class deals with OpenLCB Datagram protocol without having to know about CAN, etc.
Documentation
Forthcoming.
Dependencies
"CAN" Arduino/AVR library (available from OpenLCB download site)
Using
Copy this folder to the "libraries" folder in your Arduino sketchbook.
TODO
This software should be considered a developers' preview, and is nothing like feature complete. Indeed, the following are all missing.
- Need to seperate the VirtualNode abstract base class from the X_Handler classes, which should be structured as mixins. A virtual node will inhert VirtualNode, and whichever Handlers it needs.
- Virtual Nodes are not informed whether they are in the inhibited or permitted state. I've added a mechanism in NodeID to do this: When NodeID is initialized, the owning node may move to the permitted state; when it is not, the owning node must move to the inhibited state. This behavior is not yet fully implemented
- An initialzied (alias allocated) NodeID that has had it's NID changed needs to emit an AMR and then an AMD
- Two identical NodeIDs that allocate at exactly the same time will not catch this condition, and will allocate the same alias. Grr! Not sure how to handle this case, because a node cannot differentiate between a self-generated CID/RID and an identical CID/RID generated by a different node!
- Cached aliases need to time out eventually.
- No Stream support.
- No support for higher-level protocols (Blue/Gold, configuration, etc).
- No built-in support for storing persistant data in EEPROM. (Is this even needed?)
- Memory hoggish. Lots of opportunities to condense memory usage.
- Inconsistent use of * and & paradigms for passing parameters by reference. Really? Who cares?
- Many, many bugs to squash.
Discussion
You can get support for the OpenLCB software at the Railstars Support Forum
Related Skills
node-connect
343.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
92.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.3kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。

