| CAEN FERS Library v1.1.4 SDK for FERS systems

Functions
Data readout
API
Collaboration diagram for Data readout:

## Functions
int | FERS_InitReadout (int handle, int ROmode, int *AllocatedSize)
| Init readout for one board (allocate buffers and initialize variables) More...
int | FERS_CloseReadout (int handle)
| De-init readoout (free buffers) More...
int | FERS_FlushData (int handle)
| Flush the data buffer (Read and discard data until the RX buffer is empty) More...
int | FERS_GetCrcErrorCnt (int cnc_handle, uint32_t *errcnt)
| Get the number of CRC errors detected by the concentrator since the last start of run. More...
int | FERS_StartAcquisition (int *handle, int NumBrd, int StartMode, int RunNum)
| Start data acquisition. Set ReadoutState = RUNNING, wait until all threads are running, then send the run command to the boards, according to the given start mode. More...
int | FERS_StopAcquisition (int *handle, int NumBrd, int StartMode, int RunNum)
| Send the stop command to the boards (according to the same mode used to start them) More...
int | FERS_GetEvent (int *handle, int *bindex, int *DataQualifier, double *tstamp_us, void **Event, int *nb)
| Read and decode one event from the readout buffers. There are two readout modes: sorted or unsorted. If sorting is requested, the readout init function will allocate queues for sorting. More...
int | FERS_GetEventFromBoard (int handle, int *DataQualifier, double *tstamp_us, void **Event, int *nb)
| Read and decode one event from a specific board. More...

## Detailed Description

## Function Documentation

## ◆ FERS_InitReadout()

int FERS_InitReadout | ( | int | handle,
|  | int | ROmode,
|  | int * | AllocatedSize
| ) |  |

Init readout for one board (allocate buffers and initialize variables)

Parameters

  [out] | AllocatedSize | Pointer to the tot. num. of bytes allocated for data buffers and descriptors
  [in] | handle | Board handle
  [in] | ROmode | EventBuilding readout mode

Returns
  0 on success, or a negative error code as defined in FERSLIB_ErrorCodes

## ◆ FERS_CloseReadout()

int FERS_CloseReadout | ( | int | handle | ) |

De-init readoout (free buffers)

Parameters

  [in] | handle | Board handle

Returns
  0 on success, or a negative error code as defined in FERSLIB_ErrorCodes

## ◆ FERS_FlushData()

int FERS_FlushData | ( | int | handle | ) |

Flush the data buffer (Read and discard data until the RX buffer is empty)

Parameters

  [in] | handle | Board handle

Returns
  0 on success, or a negative error code as defined in FERSLIB_ErrorCodes

## ◆ FERS_GetCrcErrorCnt()

int FERS_GetCrcErrorCnt | ( | int | cnc_handle,
|  | uint32_t * | errcnt
| ) |  |

Get the number of CRC errors detected by the concentrator since the last start of run.

Parameters

  [out] | errcnt | Pointer to the CRC error counter
  [in] | cnc_handle | Handle of the concentratore

Returns
  0 on success, or a negative error code as defined in FERSLIB_ErrorCodes

## ◆ FERS_StartAcquisition()

int FERS_StartAcquisition | ( | int * | handle,
|  | int | NumBrd,
|  | int | StartMode,
|  | int | RunNum
| ) |  |

Start data acquisition. Set ReadoutState = RUNNING, wait until all threads are running, then send the run command to the boards, according to the given start mode.

Parameters

  [in] | handle | Array of board handles
  [in] | NumBrd | Number of boards to start
  [in] | StartMode | Acquisition start mode (Async, T0/T1 chain, TDlink)
  [in] | RunNum | Run number

Returns
  0 on success, or a negative error code as defined in FERSLIB_ErrorCodes

## ◆ FERS_StopAcquisition()

int FERS_StopAcquisition | ( | int * | handle,
|  | int | NumBrd,
|  | int | StartMode,
|  | int | RunNum
| ) |  |

Send the stop command to the boards (according to the same mode used to start them)

Note
  This function stops the run in the hardware (thus stopping the data flow) but it doesn't stop the RX threads because they need to empty the buffers and the pipes. The threads will stop automatically when there is no data or when a flush command is sent.

Parameters

  [in] | handle | Array of board handles
  [in] | NumBrd | Number of boards to stop
  [in] | StartMode | Acquisition stop mode
  [in] | RunNum | Run number

Returns
  0 on success, or a negative error code as defined in FERSLIB_ErrorCodes

## ◆ FERS_GetEvent()

int FERS_GetEvent | ( | int * | handle,
|  | int * | bindex,
|  | int * | DataQualifier,
|  | double * | tstamp_us,
|  | void ** | Event,
|  | int * | nb
| ) |  |

Read and decode one event from the readout buffers. There are two readout modes: sorted or unsorted. If sorting is requested, the readout init function will allocate queues for sorting.

Parameters

  [out] | bindex | Pointer to the board index from which the event comes
  [out] | DataQualifier | Pointer to the data qualifier (type of data, used to determine the struct for event data)
  [out] | tstamp_us | Pointer to the event timestamp in microseconds (the information is also reported in the event data struct)
  [out] | Event | Pointer to the read event data structure
  [out] | nb | Pointer to the size of the read event (in bytes)
  [in] | handle | Array of boards handles

Returns
  0 on success, or a negative error code as defined in FERSLIB_ErrorCodes

## ◆ FERS_GetEventFromBoard()

int FERS_GetEventFromBoard | ( | int | handle,
|  | int * | DataQualifier,
|  | double * | tstamp_us,
|  | void ** | Event,
|  | int * | nb
| ) |  |

Read and decode one event from a specific board.

Parameters

  [out] | DataQualifier | Pointer to the data qualifier (type of data, used to determine the struct for event data)
  [out] | tstamp_us | Pointer to the event timestamp in microseconds (the information is also reported in the event data struct)
  [out] | Event | Pointer to the read event data
  [out] | nb | Pointer to the size of the read event (in bytes)
  [in] | handle | Board handle

Returns
  0 on success, or a negative error code as defined in FERSLIB_ErrorCodes