VMX-pi HAL Library (C++, Java, C#, Python)

On the Raspberry Pi, the vmxpi-hal package provides low-level direct access on a Raspberry Pi to all VMX-pi capabilities from C++, Java, C# and Python.

Reference Guide and API Documentation

The VMX-pi HAL Library Reference Guide provides an overview for software developers.

For a detailed documentation of the HAL APIonline help is available.

Enabling Communication Interfaces

The VMX-pi HAL Libraries on the Raspberry Pi communicate with the VMX-pi via an internal SPI bus.  For this communication to work, the SPI interface must be enabled with the Raspberry Pi’s raspi-config tool.  Additionally, the I2C and Serial interfaces must also be enabled in order to communicate via the VMX-pi I2C and Serial ports.

To invoke Raspi-config, select Preferences->Raspberry Pi Configuration from the Raspberry Pi system menu.

Note that the Raspberry Pi Configuration Dialog is different depending upon the version of Raspbian being used.

Raspbian Buster Configuration

Click on the “Interfaces” tab and ensure that:

  • SSH, VNC, SPI, I2C and Serial are enabled
  • Serial Console is disabled

Press OK to save the settings at which point a Raspberry Pi reboot will be required in order for the changes to take effect.

Raspbian Stretch Configuration

Click on the “Interfaces” tab and ensure that SSH, SPI, I2C and Serial are enabled.  Press OK to save the settings at which point a Raspberry Pi reboot will be required in order for the changes to take effect.

Finally, you will need to manually disable the serial console on Raspbian Stretch, as follows:

  1. Stop serial-getty from referencing /dev/ttyS0:

You also need to remove the console from the cmdline.txt. If you edit this with:

you will see something like:

remove the line: console=serial0,115200 and save and reboot for changes to take effect.

I2C Bus Speed

By default, the Raspberry Pi I2C bus speed is 100Khz (“Standard Mode”). To change the bus speed to 400Khz (Fast Mode) follow these I2C bus speed configuration instructions.

Installing VMX-pi HAL on a Raspberry Pi

The VMX-pi HAL is included within the VMX Robotics Toolkit image.  VMX-pi HAL can also be installed from Kauai Labs Trusted APT Repository.

Installed VMX-pi HAL Libraries

As further described in the VMX-pi HAL Reference Guide, the VMX-pi HAL installer places libraries, include files (for C++) and examples onto the Raspberry PI, including:

/usr/local/lib/vmxpi:  VMX-pi HAL C,++, Java, Python and C# Libraries

/usr/local/include/vmxpi:  VMX-pi HAL C++ Header Files

Examples

A number of HAL example programs are installed, and can be found at /usr/local/src/vmxpi in the following sub-directories:

  • hal_cpp_examples
  • hal_java_examples
  • hal_python_examples
  • hal_csharp_examples