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 API, online 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:
- Stop serial-getty from referencing /dev/ttyS0:
$ sudo systemctl stop serial–getty@ttyS0.service
$ sudo systemctl disable serial–getty@ttyS0.service
You also need to remove the console from the cmdline.txt. If you edit this with:
$ sudo nano /boot/cmdline.txt
you will see something like:
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes root wait
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
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
A number of HAL example programs are installed, and can be found at /usr/local/src/vmxpi in the following sub-directories: