Provide an escape to access the Rulbus for non-supported operations or modules.
Sometimes you may want to use an operation on a Rulbus module that is not provided by the modules' interface in this library. Or you may want to use a Rulbus module that is not supported by this library at all.
In these cases the required operations may be constructed with the functions for the Generic Rulbus Device to open a device, read and write a byte and close a device (see Rulbus DLL Interface).
Not much is known of operations or modules that are not supported by this library.
rb_generic "mydevice"
{
address = 0 # must be zero
}
When the Rulbus configuration file is read, the device is unaffected.
For a generic Rulbus device you can use the functions as described in Rulbus DLL Interface
Here is a small snippet of code that shows how to access the Rulbus with the generic Rulbus interface functions.
int32 handle; int mybase = 0x12; // mydevice Rulbus base address int myreg0 = 0; // e.g. register offset for LSB int myreg1 = 1; // e.g. register offset for MSB int myvalue = 0x1234; // value to write to mydevice RulbusDevice_open ( &handle, "mydevice" ); RulbusDevice_putByte( handle, mybase + myreg0, myvalue % 256 ); // LSB RulbusDevice_putByte( handle, mybase + myreg1, myvalue / 256 ); // MSB RulbusDevice_close ( handle );
Here is a small program to demonstrate how the generic Rulbus interface functions may be used to continuously write a test pattern to a Rulbus address.
/* * pattern - write a data pattern to the Rulbus. */ #include "rulbus.h" // header #include <stdio.h> // for fprintf() #include <stdlib.h> // for EXIT_SUCCESS #include <conio.h> // for kbhit() int error() { return EXIT_FAILURE; } int main() { int32 pattern = 0x5E; // test pattern int32 rack = 0; // rulbus rack number int32 addr = 0; // rulbus base address int32 offset = 0x12; // rulbus address offset int32 handle = 0; // handle to generic rulbus device // open the generic rulbus device if ( RulbusDevice_open( &handle, "Rulbus-test-device" ) ) return error(); RulbusDevice_getRack ( handle, &rack ); RulbusDevice_getAddress( handle, &addr ); fprintf( stdout, "Writing [%d:0x%02X] <- 0x%02X\n", rack, addr + offset, pattern ); fprintf( stderr, "\nPress a key to stop..." ); while( !kbhit() ) // write pattern until a key is pressed if ( 0 > RulbusDevice_putByte( handle, offset, pattern ) ); return error(); (void) getch(); // eat character if ( RulbusDevice_close( handle ) ) return error(); // close the generic rulbus device return EXIT_SUCCESS; }