fdhwlib  2.0.25
Adding a new Pbus library

The Pbus library provides a simple interface to the IPE-DAQ electronics.

The interface to the hardware is defined in the class PbusImp. The class PbusTemplate contains all functions that need to be implemented for a new phisicla access method. You will find comments in all places where the access type specific function need to be placed. Unforunately there is no script that automatically includes the new access library in the fdhwlib build system. This document gives a detailed list of the necessary steps.

Add new Pbus library:

1. Copy pbustemplate.h and pbustemplate.cpp to pbusnew.h and pbusnew.cpp. "new" should be the name for the access method. Available methods are sim, 1394, ip.

2. Add both files to the code repository:

cvs add pbusnew.h pbusnew.cpp
       

3. Change the name "Template" in both files to "New" and "TEMPLATE" to "NEW".

4. Remove this documentation and add a description of the new access method in pbusnew.h.

5. Connect Pbus and the new PbusImp: The implamentation will be impluded using the preprocessor define PBUS_NEW This define wraps around the implementation in pbusnew.h and pbusnew.cpp. Add the following defines in Pbus.h.

#define PBUS_MODE_TEMPLATE 99

#if defined PBUS_MODE  && (PBUS_MODE == PBUS_MODE_TEMPLATE)
#define PBUS_TEMPLATE
#endif

#ifdef PBUS_TEMPLATE
#define PBUS_MODE_TXT     "Template for other Pbus libraries"
#define PBUS_LIB          "Template"
#endif
       

Add the new Pbus implementation in Pbus.cpp:

#ifdef PBUS_TEMPLATE
#include "pbustemplate.h"
#endif

int Pbus::init(const char * inifile, int host) {

#ifdef PBUS_TEMPLATE
    pImp = new PbusTemplate();
    pImpAvailable = true;
#endif

}	   
       

6. Update the build system: In Makefile.am the new library has to be added to lib_LIBRARIES. The following entry defines the sources included in the library.

libPbusTemplate_a_SOURCES = pbustemplate.cpp pbustemplate.h \
                            pbuscontrol.cpp pbuscontrol.h Pbus.cpp PbusError.cpp \
                            PbusError.h Pbus.h pbusimp.cpp pbusimp.h 
       

7. Implement the hardware access. A minimal implementation requires initialization in init, reading and writing in rawRead and rawWrite. In most cases also a block access for reading will be added (readBlock).