User Tools

Site Tools


rocnet:rocnetnode-build-en

RocNetNode Build from source

Build

Read first: RasPi Dev
:!: Do not install libi2c-dev; It will break the build process and the needed C-Headers and libraries are already available in the RaspBian image.
The Rocrail Server build also includes the RocNetNode:

make server
sudo make install

The binary is written in Rocrail/unxbin.
The rocnetnode.ini can be copied from Rocrail/rocnetnode/package/rocnetnode.ini.

Install

cd rocnetnode
sudo make install

This will copy following files to /opt/rocnet:

  • rocnetnode
  • rocnetnode.ini
  • rocnetnode.sh


Startup

  1. The rocnetnode.ini and dcc232 library must reside in the working directory.
  2. To be able to access the /dev/mem and /dev/i2c-x the program must be started with sudo:
20130825.214751.623 r9999I main     raspi    0068 setup RasPi I/O 0x00000001
20130825.214751.624 r9999E main     raspi    0072 can't open /dev/mem

Sudo startup in the unxbin directory:

sudo ./rocnetnode


rocnetnode.ini

See: Port mapping

<rnnode>
  <rocnet id="4711" addr="224.0.0.1" port="4321">
    <rocnetnodeoptions iotype="0" sack="true"/>
    <portsetup port="1" type="1" delay="200"/>
    <portsetup port="2" type="1" delay="200"/>
    <portsetup port="3" type="1" delay="200"/>
    <portsetup port="4" type="1" delay="200"/>
    <portsetup port="5" type="1" delay="200"/>
    <portsetup port="6" type="1" delay="200"/>
    <portsetup port="7" type="1" delay="200"/>
    <portsetup port="8" type="1" delay="200"/>
    <portsetup port="9" type="0" delay="0"/>
    <portsetup port="10" type="0" delay="0"/>
    <portsetup port="11" type="0" delay="0"/>
    <portsetup port="12" type="0" delay="0"/>
    <portsetup port="13" type="1"/>
    <portsetup port="14" type="1"/>
    <portsetup port="15" type="1"/>
    <portsetup port="16" type="1"/>
  </rocnet>
  <trace rfile="rocnetnode" protpath="" debug="false" info="false" calc="true" byte="false"/>  
  <digint lib="dcc232" iid="dcc-1" device="/dev/ttyUSB0"/>
</rnnode>

rocnet

Attribute Description Range Default
id RocNet ID 0-65535 0
addr Multicast address * 224.0.0.1
port Multicast port 0-65535 4321


rocnetnodeoptions

Attribute Description Range Default
iotype I/O type 0=i2c-1, 1=i2c-0 0
sack Sensor acknowledge true/false false
rfid Activate ID-12 reading true/false false

For Raspberry Pi Rev. 1 use I2C-0 as device.

portsetup

Attribute Description Range Default Remark
port logical port number to be used for Rocrail addressing 1-128 1
type I/O type 0=output, 1=input 0
delay Input delayed off for occupancy1), or output pulse time. 0-255 0 10ms units, 0=not used
state saved output state 0=off, 1=on 0 Saved at a Power Off command.


DCC232 Device

To be able to generate a usable DCC signal the internal RS232 cannot be used.
The best way is to attach a FDTI USB-RS232 converter to the USB connector.

Bus 001 Device 004: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC 
crw-rw---T 1 root dialout 188, 0 Jan  1  1970 /dev/ttyUSB0


Shutdown

Terminal

If the program is running in a console it can be stopped with CTRL+C.
In all other cases kill must be used.


I2C Preparations

Enable

This can only be enabled with the sudo command.

Remove the modules from the /etc/modprobe.d/raspi-blacklist.conf by commenting them out (insert # at the beginning of the following lines):

# blacklist spi and i2c by default (many users don't need them)

#blacklist spi-bcm2708
#blacklist i2c-bcm2708

Add them in /etc/modules:

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.
snd-bcm2835
i2c-bcm2708
i2c-dev


Raspberry Pi and the Serial Port

By default the Raspberry Pi’s serial port is configured to be used for console input/output. Whilst this is useful if you want to login using the serial port, it means you can't use the Serial Port in your programs. To be able to use the serial port to connect and talk to other devices (e.g. Arduino), the serial port console login needs to be disabled.

Needless to say you will need some other way to login to the Raspberry Pi, and we suggest doing this over the network using an SSH connection.

Disable Serial Port Login

To enable the serial port for your own use you need to disable login on the port. There are two files that need to be edited

The first and main one is /etc/inittab

This file has the command to enable the login prompt and this needs to be disabled. Edit the file and move to the end of the file. You will see a line similar to

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

Disable it by adding a # character to the beginning. Save the file.

#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

Disable Bootup Info

When the Raspberry Pi boots up, all the bootup information is sent to the serial port. Disabling this bootup information is optional and you may want to leave this enabled as it is sometimes useful to see what is happening at bootup. If you have a device connected (i.e. Arduino) at bootup, it will receive this information over the serial port, so it is up to you to decide whether this is a problem or not.

You can disable it by editing the file /boot/cmdline.txt

The contents of the file look like this

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

Remove all references to ttyAMA0 (which is the name of the serial port). The file will now look like this

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

Reboot

In order you enable the changes you have made, you will need to reboot the Raspberry Pi

sudo shutdown -r now

1)
Minimal pulse length 100ms.
rocnet/rocnetnode-build-en.txt · Last modified: 2021/12/11 09:57 by phil45