Problems with ModularEEG Data aquisition

Obtaining data from various hardware devices
unidesigner
Posts: 5
Joined: Wed Jul 15, 2009 12:49 pm

Problems with ModularEEG Data aquisition

Post by unidesigner »

Hello,

We've built a ModularEEG and I tried to use it with OpenVibe. But there seems a problem in the Acquisition Server which I couldn't track.
I have a serial-USB converter on board. So, I'm able to connect to the device and it says ready in the Acquisition Server. But after I click start,
it disconnects with the error:
" Something bad happened in the callback loop"
The developer of the driver (Chris) told me that this does not happend with his device and his version of the driver. He told me that it probably has
to do with someting that Yann added for the release?

Thanks for help!
Stephan

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: Problems with ModularEEG Data aquisition

Post by yrenard »

Dear Stephan,

what version of the firmware do you have ? The ModularEEG EEG driver Chris developed was for P2 only.

Yann

unidesigner
Posts: 5
Joined: Wed Jul 15, 2009 12:49 pm

Re: Problems with ModularEEG Data aquisition

Post by unidesigner »

The P2 firmware is uploaded to my modularEEG device.

Stephan

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: Problems with ModularEEG Data aquisition

Post by yrenard »

Dear unidesigner,

the message you are talking about happens when the loop function returns false.

according to the current code :

Code: Select all

boolean CDriverOpenEEGModularEEG::loop(void)
{
	if(!m_rDriverContext.isConnected()) { return false; }
	if(!m_rDriverContext.isStarted()) { return true; }

	uint32 l_i32ReceivedSamples=0;
	uint32 l_ui32StartTime=System::Time::getTime();
	while(l_i32ReceivedSamples < m_ui32SampleCountPerSentBlock && System::Time::getTime()-l_ui32StartTime < 1000)
	{
		switch(this->readPacketFromTTY(m_i32FileDescriptor))
		{
			case 0: // No Packet finished
				break;

			case 1: // Packet with Samples arrived
				// m_ui8LastPacketNumber++;
				m_ui8LastPacketNumber=m_ui8PacketNumber;
				for(uint32 j=0; j<m_oHeader.getChannelCount(); j++)
				{
					m_pSample[j*m_ui32SampleCountPerSentBlock+l_i32ReceivedSamples]=(float32)m_pChannelBuffer[j]-512.f;
				}
				l_i32ReceivedSamples++;
				break;

			case -1: // Timeout, could inidicate communication error
				return false;
		}
	}

	if(l_i32ReceivedSamples!=m_ui32SampleCountPerSentBlock)
	{
		// Timeout
		return false;
	}

	m_pCallback->setSamples(m_pSample);
	return true;
}
the function returns false in two cases :
  • - first one is that readPacketFromTTY returns -1, reflecting a timeout
    - second one is that the while block takes more than a second to execute, reflecting a different timeout
Did you push that "start" button (or whatever its name, I can't remember) on your device before pushing the start button on the acquisition server ?

Yann

fleur
Posts: 17
Joined: Mon Nov 23, 2009 12:32 pm

Re: Problems with ModularEEG Data aquisition

Post by fleur »

Hello,
We have the same problem with our Modular EEG. Tha card is well powered. The RS232 Cable sends signals: we have tested with Hyperterminal.
We still have the error: "something bad happen in the callback loop".
We have also tested the acquisition with the software ElectricGuru and we have no signals.

Best Regards,

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: Problems with ModularEEG Data aquisition

Post by yrenard »

Dear fleur,

Did you push that "start" button (or whatever its name, I can't remember) on your device before pushing the start button on the acquisition server ?

Yann

fleur
Posts: 17
Joined: Mon Nov 23, 2009 12:32 pm

Re: Problems with ModularEEG Data aquisition

Post by fleur »

Hello,

We don't find any start button on the openEEG.

Best Regards,

fleur
Posts: 17
Joined: Mon Nov 23, 2009 12:32 pm

Re: Problems with ModularEEG Data aquisition

Post by fleur »

Hello,

We would like to know if we should change the port number?

Best Regards,

unidesigner
Posts: 5
Joined: Wed Jul 15, 2009 12:49 pm

Re: Problems with ModularEEG Data aquisition

Post by unidesigner »

Yes, there is no start button on my openeeg either.

Stephan

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: Problems with ModularEEG Data aquisition

Post by yrenard »

Dear fleur,

Chris Veigl who wrote the driver told me in the past :
there were some "bad things happening" in the aquististion server (i suppose because of a timeout when the device is in pause mode) but when i chose the right sequence (connect to COM port, press play on device, press play in aquisition server, press play in designer) i got a clean 14Hz calibration signal from the device.

We don't have an OpenEEG acquisition machine ourselves so I can't test it.
If you can't handle this on the acquisition server side, maybe you could have a look to the sources of the driver to let us know which part of the function returned false. (Just print something at those return false points).

Yann

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: Problems with ModularEEG Data aquisition

Post by yrenard »

unidesigner wrote:Yes, there is no start button on my openeeg either.
Thank you unidesigner for this feedback !

Glad that you came back to read this post.

Have you tried the older version of the driver that Chris initially released ? Also, he told me he contacted you to provide help but that he did not receive required information. Could you give them to him ?

Yann

unidesigner
Posts: 5
Joined: Wed Jul 15, 2009 12:49 pm

Re: Problems with ModularEEG Data aquisition

Post by unidesigner »

No, I have'nt tried the older version of the driver. I need to take time to look into this.
I don't know what information he meant regarding this.

From the description he gave, it seems that he has a start button on his device. My device is configured
(with serial to usb converter on board) to continously send data, so i no start button is necessary or even available.

it works with bioexplorer.

i'm not sure to which kind of the "bad things happening" is to be attributed.

unidesigner
yrenard wrote:
unidesigner wrote:Yes, there is no start button on my openeeg either.
Thank you unidesigner for this feedback !

Glad that you came back to read this post.

Have you tried the older version of the driver that Chris initially released ? Also, he told me he contacted you to provide help but that he did not receive required information. Could you give them to him ?

Yann

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: Problems with ModularEEG Data aquisition

Post by yrenard »

unidesigner wrote:No, I have'nt tried the older version of the driver. I need to take time to look into this. I don't know what information he meant regarding this.
Well, that would help me know if I made a mistake when integrating Chris's driver. Feedback appreciated if you have time.
unidesigner wrote:From the description he gave, it seems that he has a start button on his device. My device is configured (with serial to usb converter on board) to continously send data, so i no start button is necessary or even available.
Ok, so do you have an idea if he added this start button for his own device only ?
unidesigner wrote:it works with bioexplorer.
Ok, we definitely have to fix this bug...
I'd be glade to help any user with OpenEEG hardware to debug/fix this live... join on IRC !
unidesigner wrote:i'm not sure to which kind of the "bad things happening" is to be attributed.
Indeed, the driver does not print any error message. The bad things happening is just the acquisition driver telling that the driver returned an error status ;) I can print a message depending on which of the two cases returned the error status but I don't know exactly the circumstances that made this error status happen.

Anyone, please join on IRC for a live debug session ;)

Yann

fleur
Posts: 17
Joined: Mon Nov 23, 2009 12:32 pm

Re: Problems with ModularEEG Data aquisition

Post by fleur »

Hello,

We have the following problem in the source code:
On the console, the problem are identified:

Code: Select all

printf("switch 0: No Packet finished\n");
printf("  l_i32ReceivedSamples!=m_ui32SampleCountPerSentBlock => Timeout");
The source code is (We have put printf in the loop ):

Code: Select all

boolean CDriverOpenEEGModularEEG::loop(void)
{
	printf("enter loop");
	if(!m_rDriverContext.isConnected()) { return false; }
	printf("connection ok");
	if(!m_rDriverContext.isStarted()) { return true; }

	uint32 l_i32ReceivedSamples=0;
	uint32 l_ui32StartTime=System::Time::getTime();
	while(l_i32ReceivedSamples < m_ui32SampleCountPerSentBlock && System::Time::getTime()-l_ui32StartTime < 1000)
	{
		printf("enter while");
		switch(this->readPacketFromTTY(m_i32FileDescriptor))
		{
			case 0: // No Packet finished
				[color=#FFFF00]printf("switch 0: No Packet finished\n");[/color]
				break;

			case 1: // Packet with Samples arrived
				// m_ui8LastPacketNumber++;
				printf("switch 1 : Packet with Samples arrived\n");
				m_ui8LastPacketNumber=m_ui8PacketNumber;
				for(uint32 j=0; j<m_oHeader.getChannelCount(); j++)
				{
					m_pSample[j*m_ui32SampleCountPerSentBlock+l_i32ReceivedSamples]=(float32)m_pChannelBuffer[j]-512.f;
				}
				l_i32ReceivedSamples++;
				break;

			case -1: // Timeout, could inidicate communication error
				printf("switch -1 : Timeout\n");
				return false;
		}
	}

	if(l_i32ReceivedSamples!=m_ui32SampleCountPerSentBlock)
	{
		// Timeout
		[color=#FFFF00]printf("  l_i32ReceivedSamples!=m_ui32SampleCountPerSentBlock => Timeout");[/color]
		return false;
	}

	m_pCallback->setSamples(m_pSample);
	printf("end loop");
	return true;
}

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: Problems with ModularEEG Data aquisition

Post by yrenard »

After some live debugging on the driver, it appears that a problem is happening on Windows. Windows has a rather big buffer for COM ports and doesn't let client applications get the data as often as it should. This results in multiple packets being decoded at the same time. Function readPacketFromTTY returns bigger than 1 values. This case is not considered in the switch/case statement...

I'm working on a patch thanks to someone on IRC.

I'll keep you posted and I hope we'll have a working fix soon

Yann

Post Reply