User written acquisition software problem
Posted: Tue May 23, 2017 5:44 pm
Hello,
I'm attempting to write a module for our current data acquisition system to use our BioSemi Mk2 system. It's set in mode 4 (282 chan). I'm using Linux. I got the Labview_DLL_Synctest example program to work (after adjusting for 282 chan). My program and Synctest both link with liblabview_dll.so. My program follows Synctest's liblabview_dll call order. One difference is the first call 'OPEN_DRIVER()' is done in my module's ctor. Then READ_MULTIPLE_SWEEPS() and USB_WRITE() are in my module's 'startAD()' function. Here's the code:
SubSysBS::SubSysBS()
{
// init _controlBuffer
for (int i=0; i<64; i++)
_controlBuffer = 0;
_lastSample = 0;
// get USB handle, do config
if ( ( _usbHandle = OPEN_DRIVER()) != NULL)
{
cout << "Device Ready" << endl;
_status = DAS_READY;
getConfig();
}
else
_status = DAS_AD_OPEN_ERR;
}
SubSysBS::startAD( int sg, int cb)
{
char *buf;
bool nStatus;
cout << "startAD status " << hex << _status << endl;
if ( _status & DAS_ERROR)
{
cerr << "startAD: DAS_ERROR" << endl;
return 1;
}
buf = _dataBuf + _circBuf[cb].offset;
nStatus = READ_MULTIPLE_SWEEPS( _usbHandle, buf, _circBufSize);
if ( nStatus == false)
{ // ERROR
_status |= DAS_ERROR;
alert ("READ_MULTIPLE_SWEEPS error: %s\n", strerror(errno));
return 1;
}
// start the flow of samples to the ring buffer
sleep(1); // 1 sec sleep
_controlBuffer[0] = char(-1);
nStatus = USB_WRITE( _usbHandle, &_controlBuffer[0]); // enable usb interface
if ( nStatus == false)
{ // ERROR
_status |= DAS_ERROR;
alert ("USB_WRITE-2 for enable handshake error: %s\n", strerror(errno));
return 1;
}
...
The problem is that 'USB_WRITE' returns an 'invalid argument' error (errno=22).
OPEN_DRIVER() and READ_MULTIPLE_SWEEPS() seem to work fine. I am at a loss to why USB_WRITE doesn't work and would appreciate any hints or suggestions on how to debug this.
Thanks,
Barry
I'm attempting to write a module for our current data acquisition system to use our BioSemi Mk2 system. It's set in mode 4 (282 chan). I'm using Linux. I got the Labview_DLL_Synctest example program to work (after adjusting for 282 chan). My program and Synctest both link with liblabview_dll.so. My program follows Synctest's liblabview_dll call order. One difference is the first call 'OPEN_DRIVER()' is done in my module's ctor. Then READ_MULTIPLE_SWEEPS() and USB_WRITE() are in my module's 'startAD()' function. Here's the code:
SubSysBS::SubSysBS()
{
// init _controlBuffer
for (int i=0; i<64; i++)
_controlBuffer = 0;
_lastSample = 0;
// get USB handle, do config
if ( ( _usbHandle = OPEN_DRIVER()) != NULL)
{
cout << "Device Ready" << endl;
_status = DAS_READY;
getConfig();
}
else
_status = DAS_AD_OPEN_ERR;
}
SubSysBS::startAD( int sg, int cb)
{
char *buf;
bool nStatus;
cout << "startAD status " << hex << _status << endl;
if ( _status & DAS_ERROR)
{
cerr << "startAD: DAS_ERROR" << endl;
return 1;
}
buf = _dataBuf + _circBuf[cb].offset;
nStatus = READ_MULTIPLE_SWEEPS( _usbHandle, buf, _circBufSize);
if ( nStatus == false)
{ // ERROR
_status |= DAS_ERROR;
alert ("READ_MULTIPLE_SWEEPS error: %s\n", strerror(errno));
return 1;
}
// start the flow of samples to the ring buffer
sleep(1); // 1 sec sleep
_controlBuffer[0] = char(-1);
nStatus = USB_WRITE( _usbHandle, &_controlBuffer[0]); // enable usb interface
if ( nStatus == false)
{ // ERROR
_status |= DAS_ERROR;
alert ("USB_WRITE-2 for enable handshake error: %s\n", strerror(errno));
return 1;
}
...
The problem is that 'USB_WRITE' returns an 'invalid argument' error (errno=22).
OPEN_DRIVER() and READ_MULTIPLE_SWEEPS() seem to work fine. I am at a loss to why USB_WRITE doesn't work and would appreciate any hints or suggestions on how to debug this.
Thanks,
Barry