areaDetector  3-5-0
EPICS areaDetector framework
Classes | Macros | Typedefs | Functions
firewireDCAM.cpp File Reference

This is areaDetector plug-in support for firewire cameras that comply with the IIDC DCAM protocol. More...

#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <epicsString.h>
#include <epicsTime.h>
#include <epicsThread.h>
#include <epicsEvent.h>
#include <epicsMutex.h>
#include <epicsEndian.h>
#include <ADDriver.h>
#include <dc1394/dc1394.h>

Classes

class  FirewireDCAM
 Main driver class inherited from areaDetectors ADDriver class. More...
 
struct  camList_t
 
class  BusManager
 A singleton class that keep a list of the (configured) cameras on the bus. More...
 
struct  camNode_t
 
struct  pix_lookup
 

Macros

#define REG_CAMERA_TRIGGER_MODE   0x830U
 
#define ERR(errCode)   if (errCode != 0) fprintf(stderr, "ERROR [%s:%d]: dc1394 code: %d\n", __FILE__, __LINE__, errCode)
 Print an errorcode to stderr. More...
 
#define PERR(pasynUser, errCode)   this->err(pasynUser, errCode, __LINE__)
 Convenience macro to be used inside the firewireDCAM class. More...
 
#define FDC_DC1394_NUM_BUFFERS   15
 Number of image buffers the dc1394 library will use internally. More...
 
#define FIRST_FDC_PARAM   FDC_feat_val
 Feature value (int32 read/write) addr: 0-17. More...
 
#define LAST_FDC_PARAM   FDC_bandwidth
 Read back the current bandwidth (int32, read) More...
 
#define FDC_feat_valString   "FDC_FEAT_VAL"
 Specific asyn commands for this support module. More...
 
#define FDC_feat_val_maxString   "FDC_FEAT_VAL_MAX"
 
#define FDC_feat_val_minString   "FDC_FEAT_VAL_MIN"
 
#define FDC_feat_val_absString   "FDC_FEAT_VAL_ABS"
 
#define FDC_feat_val_abs_maxString   "FDC_FEAT_VAL_ABS_MAX"
 
#define FDC_feat_val_abs_minString   "FDC_FEAT_VAL_ABS_MIN"
 
#define FDC_feat_modeString   "FDC_FEAT_MODE"
 
#define FDC_feat_availableString   "FDC_FEAT_AVAILABLE"
 
#define FDC_feat_absoluteString   "FDC_FEAT_ABSOLUTE"
 
#define FDC_framerateString   "FDC_FRAMERATE"
 
#define FDC_videomodeString   "FDC_VIDEOMODE"
 
#define FDC_bandwidthString   "FDC_BANDWIDTH"
 
#define NUM_FDC_PARAMS   (&LAST_FDC_PARAM - &FIRST_FDC_PARAM + 1)
 Number of asyn parameters (asyn commands) this driver supports. More...
 
#define FDC_DC1394_FEATOFFSET   DC1394_FEATURE_MIN
 Feature mapping from DC1394 library enums to a local driver enum The local driver identifies a feature based on the address of the asyn request. More...
 

Typedefs

typedef struct camList_t camList_t
 
typedef struct camNode_t camNode_t
 

Functions

void reset_bus ()
 
int FDC_InitBus (void)
 Initialise the firewire bus. More...
 
int FDC_Config (const char *portName, const char *camid, int speed, int maxBuffers, size_t maxMemory, int disableScalable)
 Configuration function to configure one camera. More...
 
void FDC_ResetBus ()
 

Detailed Description

This is areaDetector plug-in support for firewire cameras that comply with the IIDC DCAM protocol.

This implements the FirewireDCAM class which inherits from the areaDetector ADDriver class.

The driver uses the Linux libraries dc1394 and raw1394.

Author: Ulrik Kofoed Pedersen Diamond Light Source Ltd, UK. Created: November 2008

Macro Definition Documentation

◆ ERR

#define ERR (   errCode)    if (errCode != 0) fprintf(stderr, "ERROR [%s:%d]: dc1394 code: %d\n", __FILE__, __LINE__, errCode)

Print an errorcode to stderr.

Convenience macro to be used when an asynUser is not yet available.

◆ FDC_bandwidthString

#define FDC_bandwidthString   "FDC_BANDWIDTH"

◆ FDC_DC1394_FEATOFFSET

#define FDC_DC1394_FEATOFFSET   DC1394_FEATURE_MIN

Feature mapping from DC1394 library enums to a local driver enum The local driver identifies a feature based on the address of the asyn request.

The address range is [0..DC1394_FEATURE_NUM-1] and the dc1394 feature enum starts at an offset of DC1394_FEATURE_MIN...

◆ FDC_DC1394_NUM_BUFFERS

#define FDC_DC1394_NUM_BUFFERS   15

Number of image buffers the dc1394 library will use internally.

◆ FDC_feat_absoluteString

#define FDC_feat_absoluteString   "FDC_FEAT_ABSOLUTE"

◆ FDC_feat_availableString

#define FDC_feat_availableString   "FDC_FEAT_AVAILABLE"

◆ FDC_feat_modeString

#define FDC_feat_modeString   "FDC_FEAT_MODE"

◆ FDC_feat_val_abs_maxString

#define FDC_feat_val_abs_maxString   "FDC_FEAT_VAL_ABS_MAX"

◆ FDC_feat_val_abs_minString

#define FDC_feat_val_abs_minString   "FDC_FEAT_VAL_ABS_MIN"

◆ FDC_feat_val_absString

#define FDC_feat_val_absString   "FDC_FEAT_VAL_ABS"

◆ FDC_feat_val_maxString

#define FDC_feat_val_maxString   "FDC_FEAT_VAL_MAX"

◆ FDC_feat_val_minString

#define FDC_feat_val_minString   "FDC_FEAT_VAL_MIN"

◆ FDC_feat_valString

#define FDC_feat_valString   "FDC_FEAT_VAL"

Specific asyn commands for this support module.

These will be used and managed by the parameter library (part of areaDetector).

◆ FDC_framerateString

#define FDC_framerateString   "FDC_FRAMERATE"

◆ FDC_videomodeString

#define FDC_videomodeString   "FDC_VIDEOMODE"

◆ FIRST_FDC_PARAM

#define FIRST_FDC_PARAM   FDC_feat_val

Feature value (int32 read/write) addr: 0-17.

◆ LAST_FDC_PARAM

#define LAST_FDC_PARAM   FDC_bandwidth

Read back the current bandwidth (int32, read)

◆ NUM_FDC_PARAMS

#define NUM_FDC_PARAMS   (&LAST_FDC_PARAM - &FIRST_FDC_PARAM + 1)

Number of asyn parameters (asyn commands) this driver supports.

◆ PERR

#define PERR (   pasynUser,
  errCode 
)    this->err(pasynUser, errCode, __LINE__)

Convenience macro to be used inside the firewireDCAM class.

◆ REG_CAMERA_TRIGGER_MODE

#define REG_CAMERA_TRIGGER_MODE   0x830U

Typedef Documentation

◆ camList_t

typedef struct camList_t camList_t

◆ camNode_t

typedef struct camNode_t camNode_t

Function Documentation

◆ FDC_Config()

int FDC_Config ( const char *  portName,
const char *  camid,
int  speed,
int  maxBuffers,
size_t  maxMemory,
int  disableScalable 
)

Configuration function to configure one camera.

This function need to be called once for each camera to be used by the IOC. A call to this function instanciates one object from the FirewireDCAM class.

Parameters
portNameAsyn port name to assign to the camera.
camidThe camera ID or serial number in a hexadecimal string. Lower case and upper case letters can be used. This is used to identify a specific camera on the bus. For instance: "0x00b09d01007139d0".
speedThe bus speed to be used. This indicates whether to use the bus in 1394A or 1394B mode. Valid values are: 400 or 800. If an invalid value is entered the function will always default to 400 (legacy mode).
maxBuffersMaxiumum number of NDArray objects (image buffers) this driver is allowed to allocate. This driver requires 2 buffers, and each queue element in a plugin can require one buffer which will all need to be added up in this parameter.
maxMemoryMaximum memory (in bytes) that this driver is allowed to allocate. So if max. size = 1024x768 (8bpp) and maxBuffers is, say 14. maxMemory = 1024x768x14 = 11010048 bytes (~11MB)
disableScalableDisable scalable modes if this is 1

◆ FDC_InitBus()

int FDC_InitBus ( void  )

Initialise the firewire bus.

This function need to be called only once to initialise the firewire bus before FDC_Config() can be called. The bus will be first be reset, then scanned for cameras and the number of cameras and their hexadecimal ID will be printed to stdout.

◆ FDC_ResetBus()

void FDC_ResetBus ( )

◆ reset_bus()

void reset_bus ( )