ngc 1.5.0
 
Loading...
Searching...
No Matches
ngcppDataRecv.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/shm.h>
#include <sys/socket.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <netinet/in.h>
#include <ngc/core/ngcbSocket.h>
#include <ngc/core/ngcppInt.h>

Classes

struct  _link_config_t
 

Macros

#define _GNU_SOURCE
 
#define NGC_LINUX
 
#define _XOPEN_SOURCE
 
#define NGCPP_RCV_MAX_FD   FD_SETSIZE
 

Functions

void ngcppScale (ngcpp_frame_t *frame)
 
void ngcppScaleBuf (void *dest, ngcpp_frame_t *frame)
 
void ngcppScale2Real (ngcpp_frame_t *frame)
 
void ngcppScaleBuf2Real (void *dest, ngcpp_frame_t *frame)
 
void ngcppDataInit (void)
 
void ngcppHdrInit (ngcpp_hdr_t *hdr)
 
int ngcppDataConnect (const char *srvName, int *socket, int transferMode, int processId, char *erms)
 
int ngcppDataDisconnect (int socket)
 
int ngcppPingDataSrv (const char *srvName, char *procName, char *erms)
 
int ngcppKillDataClient (const char *srvName, int id, char *erms)
 
int ngcppDataProtocol (const char *srvName, int *version, char *erms)
 
int ngcppGetFrameTypeByName (int *type, const char *name, char *erms)
 
int ngcppGetFrameNameByType (int type, char *name, char *erms)
 
int ngcppGetTypeDef (const char *srvName, int *nTypes, ngcpp_ftype *frameType, char *erms)
 
int ngcppGetFrameTypes (const char *srvName, int *types, char *erms)
 
int ngcppAbortReq (const char *srvName, int processId, char *erms)
 
int ngcppCancelReq (int socket, int processId, char *erms)
 
int ngcppSendDataRequest (int socket, ngcpp_req_t request, char *erms)
 
int ngcppWaitDataReply (int socket, ngcpp_hdr_t *header, char *erms)
 
int ngcppWaitNextFrame (int socket, ngcpp_req_t request, ngcpp_hdr_t *header, char *erms)
 
int ngcppPollNextFrame (int socket, ngcpp_req_t request, ngcpp_hdr_t *header, char *erms)
 
int ngcppSkipFrame (int socket, char *erms)
 
int ngcppAcceptFrame (int socket, ngcpp_req_t request, ngcpp_frame_t *frame, char *erms)
 
int ngcppAcceptFrameN (int socket, ngcpp_req_t request, ngcpp_frame_t *frame, int partNo, int numDiv, char *erms)
 
int ngcppAckFrame (int socket, ngcpp_req_t request, ngcpp_hdr_t *header, char *erms)
 
int ngcppGetFrameBuf (int socket, ngcpp_frame_t *frame, size_t offset, size_t size, char *erms)
 
int ngcppAttachData (char *srvName, size_t bufferSize, char *erms)
 
int ngcppDetachData (char *erms)
 
ngcpp_hdr_simplengcppImportData (void **buffer, char *erms)
 
int ngcppReturnData (char *erms)
 

Variables

ngcb_sig_t ngcppSigMask = sigprocmask
 

Detailed Description

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

◆ _XOPEN_SOURCE

#define _XOPEN_SOURCE

◆ NGC_LINUX

#define NGC_LINUX

◆ NGCPP_RCV_MAX_FD

#define NGCPP_RCV_MAX_FD   FD_SETSIZE

Maximum numbers of file descriptors to be handled here

Function Documentation

◆ ngcppAbortReq()

int ngcppAbortReq ( const char * srvName,
int processId,
char * erms )

Abort the current frame request.modehronously. The process waiting for the data reply receives immediately a reply. If there was no valid frame when the other side received the abort request, the frame type is set to ngcppFRAME_NO_FRAME and one must neither skip nor accept the frame. If the frame was ready when the other side received the abort command, the valid frame header is sent and the receiving process has to either skip or accept the frame.

◆ ngcppAcceptFrame()

int ngcppAcceptFrame ( int socket,
ngcpp_req_t request,
ngcpp_frame_t * frame,
char * erms )

Accept the frame returned by ngcppWaitNextFrame(). The frame is transferred and read into a buffer. The frame header might be different from the the one received with ngcppWaitDataReply() or ngcppWait/PollNextFrame() (because of windowing or if an error occured in the meantime).

◆ ngcppAcceptFrameN()

int ngcppAcceptFrameN ( int socket,
ngcpp_req_t request,
ngcpp_frame_t * frame,
int partNo,
int numDiv,
char * erms )

Accept the frame returned by ngcppWaitNextFrame(). The frame partition (partNo) out of numDiv partiions is transferred and read into a buffer supplied by the frame structure. The frame header might be different from the the one received with ngcppWaitDataReply() or ngcppWait/PollNextFrame() (because of windowing or if an error occured in the meantime).

◆ ngcppAckFrame()

int ngcppAckFrame ( int socket,
ngcpp_req_t request,
ngcpp_hdr_t * header,
char * erms )

Acknowledge the frame for later transfer.

◆ ngcppAttachData()

int ngcppAttachData ( char * srvName,
size_t bufferSize,
char * erms )

Attach the calling process to acquisition process internal buffers for processing support.

◆ ngcppCancelReq()

int ngcppCancelReq ( int socket,
int processId,
char * erms )

Aborts the current frame request, wait for the data reply and skip an eventually incoming frame. This can only be called from within the same process that has sent the request before.

◆ ngcppDataConnect()

int ngcppDataConnect ( const char * srvName,
int * socket,
int transferMode,
int processId,
char * erms )

Opens a connection to the ngcpp data server. The transferMode can be one of:

ngcppTMODE_SCIENCE - science transfer (for storage)
ngcppTMODE_VIDEO   - video transfer (not queued)

The server name must be given as string: "host:port"

◆ ngcppDataDisconnect()

int ngcppDataDisconnect ( int socket)

Diconnects from the ngcpp data server

◆ ngcppDataInit()

void ngcppDataInit ( void )

Initialize the data interface

◆ ngcppDataProtocol()

int ngcppDataProtocol ( const char * srvName,
int * version,
char * erms )

Return the actual data-protocol version used by the acquisition process.

◆ ngcppDetachData()

int ngcppDetachData ( char * srvName)

Detach the calling process from the acquisition process internal buffers.

◆ ngcppGetFrameBuf()

int ngcppGetFrameBuf ( int socket,
ngcpp_frame_t * frame,
size_t offset,
size_t size,
char * erms )

Store data (size bytes) in the frame buffer at the given offset.

◆ ngcppGetFrameNameByType()

int ngcppGetFrameNameByType ( int type,
char * name,
char * erms )

Set the frame name to the name associated with the type. If the type cannot be resolved ngcppFAILURE is returned.

◆ ngcppGetFrameTypeByName()

int ngcppGetFrameTypeByName ( int * type,
const char * name,
char * erms )

Set the frame type to the type associated with the given name. If the name cannot be resolved ngcppFAILURE is returned.

◆ ngcppGetFrameTypes()

int ngcppGetFrameTypes ( const char * srvName,
int * types,
char * erms )

Return the currently available frames. A frame-type is available, if types & frame-type != 0.

◆ ngcppGetTypeDef()

int ngcppGetTypeDef ( const char * srvName,
int * nTypes,
ngcpp_ftype * frameType,
char * erms )

Receive the frame-type definitions from the data-server. The maximum number of defined frametypes is ngcppMAX_FRAME_TYPES. The function returns an array of frame-type structures. The sturcture array has to be allocated by the calling function. One has to distinguish between defined frametypes and available frametypes, which are a subset of the defined frametypes (the defined frametypes might be enabled/disabled via commands).

◆ ngcppHdrInit()

void ngcppHdrInit ( ngcpp_hdr_t * hdr)

Initialize frame header structure

◆ ngcppImportData()

ngcpp_hdr_simple * ngcppImportData ( void ** buffer,
char * erms )

Import a buffer. The buffer must have been allocated by the caller. The address is stored for the later ngcppReturnData call. The function returns a pointer to the header of a buffer to be processed.

◆ ngcppKillDataClient()

int ngcppKillDataClient ( const char * srvName,
int id,
char * erms )

Terminate data client

◆ ngcppPingDataSrv()

int ngcppPingDataSrv ( const char * srvName,
char * procName,
char * erms )

Checks if the data server is alive. The actual acquisition process name is returned in procName.

◆ ngcppPollNextFrame()

int ngcppPollNextFrame ( int socket,
ngcpp_req_t request,
ngcpp_hdr_t * header,
char * erms )

Checks if a frame matching the request is available. If a frame is available it returns the frame header, and the output on the other end will block until the frame is either skipped or accepted. If no frame is available the frame type in the header is set to ngcppFRAME_NO_FRAME. request.blocking should be set to zero when using this function.

◆ ngcppReturnData()

int ngcppReturnData ( char * erms)

Return the processed buffer to the acquisition process.

◆ ngcppScale()

void ngcppScale ( ngcpp_frame_t * frame)

Scale the frame if frame->h.scal != 1.

◆ ngcppScale2Real()

void ngcppScale2Real ( ngcpp_frame_t * frame)

Scale the frame and convert to 32-bit floating point.

◆ ngcppScaleBuf()

void ngcppScaleBuf ( void * dest,
ngcpp_frame_t * frame )

Scale frame if frame->h.scal != 1 and store the result in a separate destination buffer.

◆ ngcppScaleBuf2Real()

void ngcppScaleBuf2Real ( void * dest,
ngcpp_frame_t * frame )

Scale frame, convert to 32-bit floating point and store the result in a separate destination buffer.

◆ ngcppSendDataRequest()

int ngcppSendDataRequest ( int socket,
ngcpp_req_t request,
char * erms )

Send a request to the data output server.

◆ ngcppSkipFrame()

int ngcppSkipFrame ( int socket,
char * erms )

Skip the frame returned by ngcppWaitNextFrame().

◆ ngcppWaitDataReply()

int ngcppWaitDataReply ( int socket,
ngcpp_hdr_t * header,
char * erms )

Wait for a reply from the data output server.

◆ ngcppWaitNextFrame()

int ngcppWaitNextFrame ( int socket,
ngcpp_req_t request,
ngcpp_hdr_t * header,
char * erms )

Wait for the next (valid) frame matching the request. The frame header is filled with the frame meta data. The output on the other end will block until the frame is either skipped or accepted. If the frametype is ngcppFRAME_NO_FRAME skip/accept must not be done.

Variable Documentation

◆ ngcppSigMask

ngcb_sig_t ngcppSigMask = sigprocmask

Signal mask function