Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

egd_acq_setup(3) [debian man page]

EGD_ACQ_SETUP(3)					       EEGDEV library manual						  EGD_ACQ_SETUP(3)

NAME
egd_acq_setup - specify which and how channel data should be obtained SYNOPSIS
#include <eegdev.h> int egd_acq_setup(struct eegdev* dev, unsigned int narr, const size_t *strides, unsigned int ngrp, const struct grpconf *grp); DESCRIPTION
egd_acq_setup() configures the way data is provided by the device referenced by dev for the next calls to egd_get_data(3). The narr argument specifies the number of buffers that will be supplied in the argument list of egd_get_data(3). strides should points to an array of narr values specifying respectively for each buffers its stride, i.e. the size in bytes between the data of two successive sam- ples in this buffer. The channels data that must be returns in those buffers are defined by ngrp groups of consecutive channels. The groups definition are passed by grp which points to an array of ngrp structures, defined as follows: struct grpconf { unsigned int sensortype; /* type of channel */ unsigned int index; /* index of the first channel */ unsigned int nch; /* number of channels */ unsigned int iarray; /* index of the array */ unsigned int arr_offset; /* offset in the array */ unsigned int datatype; /* type in the array */ }; The different fields in the structure defines the properties of the group: * sensortype specifies the type of channel. it must one of the following values returned by egd_sensor_type(3). * index indicates the index of the first channel in the group. Note that channel index i refers the i-th channel of the type specified previously, i.e. the channel index i refers to two differents channels if sensortype differs. * nch specifies the number of consecutive channels that should be in the group. * iarray indicates which buffer the data of the channel group must be written to. * arr_offset defines the offset of the memory location of the data in the buffers relatively to the beginning of each sample. * datatype specifies the type of data that must be written to the buffer. It must be one of the following value: EGD_INT32, EGD_FLOAT or EGD_DOUBLE RETURN VALUE
The function returns 0 in case of succes. Otherwise, -1 is returned and errno is set accordingly. ERRORS
egd_acq_setup() will fail if: EINVAL dev is NULL. EPERM The acquisition is running THREAD SAFETY
egd_acq_setup() is thread-safe. EXAMPLE
See egd_get_data(3) for a example SEE ALSO
egd_get_data(3), egd_start(3), egd_sensor_type(3) EPFL
2010 EGD_ACQ_SETUP(3)

Check Out this Related Man Page

EGD_GET_DATA(3) 					       EEGDEV library manual						   EGD_GET_DATA(3)

NAME
egd_get_data - peek buffered data SYNOPSIS
#include <eegdev.h> ssize_t egd_get_available(struct eegdev* dev); ssize_t egd_get_data(struct eegdev* dev, size_t ns, ...); DESCRIPTION
egd_get_available() returns the number of samples that have been buffered by the device referenced by dev and that have not been read yet. egd_get_data() peeks the ns next samples from the buffered data acquired by the device referenced by dev and fills the arrays provided in the variable list of arguments with the obtained data. If all requested samples have been already acquired, the function returns immedi- ately. Otherwise, the call blocks until the requested data is available, the acquisition stops or a problem occurs. In the last two cases, the data read may be less than requested. The arrays provided in the variable list of argument are filled following the formats specified by previous call to egd_acq_setup(3). In particular, the number of arrays supplied in the variable list of argument and their size should be consistent with the number of arrays and strides specified by the call to egd_acq_setup(3). RETURN VALUE
egd_get_available() returns the number of unread samples in case of succes. Otherwise, -1 is returned and errno is set accordingly. In case of success, egd_get_data() returns the number of read samples (which can be less than the requested number). Otherwise, -1 is returned and errno is set accordingly. ERRORS
egd_get_available() and egd_get_data() will fail if: EINVAL dev is NULL. ENOMEM The internal ringbuffer of the device referenced by dev is full. EAGAIN The underlying hardware referenced by dev has encountered a loss of connection, maybe due some cable disconnected or a power switch set to off. EIO The underlying hardware referenced by dev has encountered a loss of synchronization for an unknown reason. NOTES
Please be aware that the user has no obligation to make all the calls to egd_get_data() and egd_get_available() during the acquisition. He can also peform some of them after the acquisition which will correspond to get the remaining buffered data. For example, it might happened that a user want to wait for an certain external event to occur before stopping the acquisition. In this situation, the usual workflow would be to start the acquisition, get regurlarly some data while scanning the event to occur. When this hap- pens, the acquisition is immediately stopped. However at the moment of stopping the acquisition, there might still be some buffered data which could be important. Calling egd_get_available() after egd_stop(3) would then return the size of the remaining data that could be obtained with egd_get_data(). EXAMPLE
#define NEEG 8 #define NTRI 1 #define NS 4 int ns_tot; ssize_t ns_read; float eegarr[NEEG*NS]; int32_t triarr[NTRI*NS]; struct grpconf grp[2]; unsigned int strides[2]; /* Assume that a device has been successfully opened, i.e. there is a valid 'dev' variable of type struct eegdev* */ strides[0] = NEEG*sizeof(float); strides[1] = NTRI*sizeof(int32_t); grp[0].sensortype = egd_sensor_type("eeg"); grp[0].index = 0; grp[0].iarray = 0; grp[0].arr_offset = 0; grp[0].nch = NEEG; grp[0].datatype = EGD_FLOAT; grp[1].sensortype = egd_sensor_type("trigger"); grp[1].index = 0; grp[1].iarray = 1; grp[1].arr_offset = 0; grp[1].nch = NTRI; grp[1].datatype = EGD_INT32; /* Setup how to get the data */ egd_acq_setup(dev, 2, strides, 2, grp); /* Start the acquisition. From now, all incoming samples will be buffered */ egd_start(dev); ns_tot = 0; while (ns_tot < 1000) { /* Get the data */ ns_read = egd_get_data(dev, NS, eegarr, triarr); if (ns_read < 0) { /* Handle failure */ } ns_tot += ns_read; /* do something with the new data */ } /* Stop the acquisition, i.e. no new data is buffered */ egd_stop(dev); SEE ALSO
egd_acq_setup(3), egd_start(3), egd_stop(3) EPFL
2010 EGD_GET_DATA(3)
Man Page