How to Develop a Rulbus Device Driver
[Developer Manual]

How to Develop a Rulbus Device Driver

A driver for a Rulbus device consists of the following parts:

The C-language API is the DLL's interface to the actual Rulbus Device objects in the DLL.

The C-language API for a Rulbus module consists of three types of functions:

The protypes for the programming interface functions of all Rulbus modules are located in file rulbus.h, whereas the implementation of these functions are placed in a separate file for each Rulbus module, named rbyydd_name.cpp, like rb8510_dac12.cpp.

The following sections show several API-functions for the 12-bit DAC module, RB8510.

open

extern "C" EXPORT int32 RDL_API rb8510_dac12_open( int32 *pHandle, CCstr name )
{
   return RulbusDevice_open( pHandle, name );
}

use - obtain a value

extern "C" EXPORT int32 RDL_API rb8510_dac12_getVoltage( int32 handle, float32* pVoltage )
{
   try         { *pVoltage = to_rb8510( TheRulbusDeviceList::instance().get( handle ) ).voltage(); }
   catch (...) { return 1; }

   return 0;
}

use - set a value

extern "C" EXPORT int32 RDL_API rb8510_dac12_setVoltage( int32 handle, float32 voltage )
{
   try         { to_rb8510( TheRulbusDeviceList::instance().get( handle ) ).setVoltage( voltage ); }
   catch (...) { return 1; }

   return 0;
}

close

extern "C" EXPORT int32 RDL_API rb8510_dac12_close( int32 handle )
{
   return RulbusDevice_close( handle );
}

There are several things worth to mention here.

A Rulbus device is accessed via a handle, a number. This handle is obtained by the call to open and it is the link to the actual Rulbus device object. The handle--device object relation is maintained by TheRulbusDeviceList, of which there is and can be only one in the DLL (hence the The).

Further, the C++ style error handling through exceptions of the Rulbus Device Class Library is tranformed here to an error return value. This is the usual mechanism to report errors in for example LabVIEW. More information on an error can be obtained with rdl_getLastError().

It is also interesting to note the dual purpose of to_rb8510():


Generated on Wed Apr 6 08:59:22 2005 for Rulbus Device Library for Microsoft Windows by doxygen 1.4.0