User Tools

Site Tools


mbus:canservice-en

CANService

ContentCommand StationsMBUS

  • CANService


Introduction

The CANService is a small application which acts like a bridge between UDP/TCP and CAN.


Protocols and Ports

Märklin CS2 CAN

It provides the same UDP ports as the Märklin CS2/CS3, 15730/15731, and TCP default port 15731 for communicating with a PC.

RCAN

ASCII:
The TCP port 5550 is for use with RCAN. The linefeed option is required.
Binary:
The TCP port 15731 can be used in combination with the binary option.

BiDiB-USB

2.1.656+
The TCP port 15731 can also be for used for BiDiB, if the command line option -usb is set.
The default USB device is /dev/ttyUSB0.
Rocrail must be set to BiDiB type TCP with port 15731. The hostname is the IP or name of the RPi.
An unused Raspberry Pi 1, 2 or 3 can be used as USB-TCP bridge.
Command line options:

  • -usb
  • -usbdev <serial device name>
  • -info
  • -byte


Restrictions

The TCP/IP can only handle one client.
If there is need for multiple connections, this can be extended.


Requirements

pi01can.jpg

  1. Debian based Linux platform like Raspberry Pi + Raspbian.
  2. Hardware CAN interface: Pi01CAN.


Install

The CANService application is installed in the /opt/rocrail directory, and is included in all provided rocrail*.deb packages.


SocketCAN Setup

CAN bit rate

Set the CAN bit rate according to the target CAN:

CAN Bit rate
RCAN 125000
MBUS (CS2, CS3, GleisBox) 250000


CANService Setup/Startup

There are no settings to configure, just run it in user context.
To run it automatically after every boot, it can be setup like the Rocrail Server.

Start script

#/bin/bash
cd /home/pi
/opt/rocrail/canservice.sh <options>

Make the script executable:

chmod +x /home/pi/canservice.sh

Add it to the crontab with the command crontab -e:

@reboot /home/pi/canservice.sh
mbus/canservice-en.txt · Last modified: 2020/07/18 17:07 by rjversluis