static struct eegdev* open_device(struct grpconf group[3]) { struct eegdev* dev; char devicestr[256] = "biosemi"; if (!(dev = egd_open(devicestr))) return NULL; group[0].nch = egd_get_numch(dev, egd_sensor_type("eeg")); group[1].nch = egd_get_numch(dev, egd_sensor_type("undefined")); group[2].nch = egd_get_numch(dev, egd_sensor_type("trigger")); return dev; }
struct acq* acq_init(const char* devstring, acqcb cb, void* cbdata) { struct acq* acq; int i; if (!(acq = calloc(sizeof(*acq), 1))) return NULL; // Open the connection to the device if (!(acq->dev = egd_open(devstring))) { fprintf(stderr, "Connection error: %s\n",strerror(errno)); goto exit; } // Setup the transfer to the data buffers if (configure_egd_acq(acq) || egd_acq_setup(acq->dev, 3, acq->strides, 3, acq->grp)) { fprintf(stderr, "Acq_setup: %s\n", strerror(errno)); goto exit; } acq->cb = cb; acq->cbdata = cbdata ? cbdata : acq; if (pthread_create(&acq->thid, NULL, acq_loop_fn, acq)) goto exit; return acq; exit: if (acq->dev) egd_close(acq->dev); for (i=0; i<3; i++) free(acq->buff[i]); free(acq); return NULL; }