Driver gMobilabPlus under Windows

Making & changing hardware drivers in Acquisition Server
keldon7
Posts: 12
Joined: Fri Nov 25, 2011 11:31 am

Driver gMobilabPlus under Windows

Post by keldon7 »

Hi Guys!
Here the newest n00b!

I'm trying to create a Driver for the Acquisition Server under Windows for gMobilabPlus device but i'm crashing with a problem.
My Driver compiled and the gMobilabPlus.dll file has been created but when i compile the code but it's not called by ovasCApplicationServerGUI.

Can you help me?
Thanks for all.
Andrea

lbonnet
Site Admin
Posts: 417
Joined: Wed Oct 07, 2009 12:11 pm

Re: Driver gMobilabPlus under Windows

Post by lbonnet »

Hi Andrea, welcome on board !

The driver should not be compiled in the form of a DLL. Everything is included in the acquisition-server application directly; you just need put the code in the acquisition server project and compile it as explained in the tutorials.

did you build a whole new driver or did you modify the existing gMobilabPlus driver ? (this one is so far only compatible with Linux).

Cheers
Laurent
Follow us on twitter >> openvibebci

Checkout my (old) blog for some OpenViBE tips & tricks : here !

keldon7
Posts: 12
Joined: Fri Nov 25, 2011 11:31 am

Re: Driver gMobilabPlus under Windows

Post by keldon7 »

Thank you for the answer, I'll try to be more specific.

I modified the previous driver trying to let it works under windows, I modified only the part related to the connection, all the rest is the same code.
I modified also the FindThirdPartyGMobiLabPlusAPI.cmake adding the "WIN32 section" and when i compile openvibe the compiler create a gMobilabPlus.dll (I don't understand your phrase
The driver should not be compiled in the form of a DLL
also the ThinkGear make a dll file and if i try to eliminate and play the Acquisition Server this last one crash on loading ) but when i open the server my driver not appears in the comboBox.

It means this:
the file gMOBIlabplus.h is found on including gMOBIlabplus.h in ovasCDriverGTecGMobiLabPlus.cpp
the file gMOBIlabplus.h is NOT found on including ovasCDriverGTecGMobiLabPlus.cpp in ovasCAcquisitionServerGUI.cpp

Part of Log when i compile with "win32-build.cmd"

Code: Select all

--   Found OpenViBE plugins global defines...
--   Found boost...
--   Found GTK+...
--     [  OK  ] Third party lib G:/Work_andrea/openvibe-0.12.0-svn3107-src/dependencies/gtk/lib/gtk-win32-2.0.lib
--     [  OK  ] Third party lib G:/Work_andrea/openvibe-0.12.0-svn3107-src/dependencies/gtk/lib/gdk-win32-2.0.lib
...
...
...
--
We Are under WINDOWS
----
G:/Work_andrea/BCI-API/gMOBIlabplus
----
--   Found gMobilabPlusCAPI...
--     [  OK  ] lib G:/Work_andrea/BCI-API/gMOBIlabplus/gMOBIlabplus.lib
...
...
Scanning dependencies of target OpenViBE-acquisition-server-dynamic
[  2%] Building CXX object CMakeFiles/OpenViBE-acquisition-server-dynamic.dir/src/gtec-gmobilabplus/ovasCDriverGTecGMobiLabPlus.obj
cl : Command line warning D9002 : ignoring unknown option '-mms-bitfields'
cl : Command line warning D9002 : ignoring unknown option '-mms-bitfields'
ovasCDriverGTecGMobiLabPlus.cpp
[  5%] Building CXX object CMakeFiles/OpenViBE-acquisition-server-dynamic.dir/src/ovasCAcquisitionServerGUI.obj
cl : Command line warning D9002 : ignoring unknown option '-mms-bitfields'
cl : Command line warning D9002 : ignoring unknown option '-mms-bitfields'
ovasCAcquisitionServerGUI.cpp
G:\Work_andrea\openvibe-0.12.0-svn3107-src\openvibe-applications\acquisition-server\trunc\src\ovasCAcquisitionServerGUI.cpp(363) : warning C4244: 'initializing' : conversion from 'OpenViBE::uint64' to 'OpenViBE::float64', possible loss of data
G:\Work_andrea\openvibe-0.12.0-svn3107-src\openvibe-applications\acquisition-server\trunc\src\ovasCAcquisitionServerGUI.cpp(617) : warning C4244: 'argument' : conversion from 'OpenViBE::uint64' to 'gdouble', possible loss of data
G:\Work_andrea\openvibe-0.12.0-svn3107-src\openvibe-applications\acquisition-server\trunc\src\ovasCAcquisitionServerGUI.cpp(618) : warning C4244: 'argument' : conversion from 'OpenViBE::uint64' to 'gdouble', possible loss of data
G:\Work_andrea\openvibe-0.12.0-svn3107-src\openvibe-applications\acquisition-server\trunc\src\ovasCAcquisitionServerGUI.cpp(619) : warning C4244: 'argument' : conversion from 'OpenViBE::uint64' to 'gdouble', possible loss of data
Linking CXX executable OpenViBE-acquisition-server-dynamic.exe
      --->   Copying dll file G:/Work_andrea/BCI-API/gMOBIlabplus/gMobilabPlus.dll for the g.Tec g.MobilabPlus driver.
[100%] Built target OpenViBE-acquisition-server-dynamic
Part of "ovasCAcquisitionServerGUI.cpp"

Code: Select all

#include <iostream>
cout<<"Trying to load driver"<<endl;
#if defined TARGET_HAS_ThirdPartyGMobiLabPlusAPI
	m_vDriver.push_back(new CDriverGTecGMobiLabPlus(m_pAcquisitionServer->getDriverContext()));
	cout<<"Driver Loaded"<<endl;
#endif
Thanks
Andrea

keldon7
Posts: 12
Joined: Fri Nov 25, 2011 11:31 am

Re: Driver gMobilabPlus under Windows

Post by keldon7 »

problem solved
Finally i can test my driver.


Thanks for All!!!

keldon7
Posts: 12
Joined: Fri Nov 25, 2011 11:31 am

Re: Driver gMobilabPlus under Windows

Post by keldon7 »

Here again!
This is the last problem that i meet:
the driver is compiled and loaded, the connection is created and when i click to Play the device send data but after 20 seconds appear this crash report.
Any idea?

Code: Select all

######################################################################################
##                                                                                  ##
##  WARNING : Microsoft Visual Studio Common tools initialisation script not found  ##
##                                                                                  ##
######################################################################################
[  INF  ] Created kernel loader, trying to load kernel module
[  INF  ] Kernel module loaded, trying to get kernel descriptor
[  INF  ] Got kernel descriptor, trying to create kernel
[  INF  ] Adding [../bin/OpenViBE-plugins-*.dll]
[  INF  ] Added 2 plugin object descriptor(s) from [../bin/OpenViBE-plugins-acquisition-dynamic.dll]
[  INF  ] Added 6 plugin object descriptor(s) from [../bin/OpenViBE-plugins-classification-dynamic.dll]
[  INF  ] Added 1 plugin object descriptor(s) from [../bin/OpenViBE-plugins-classification-gpl-dynamic.dll]
[  INF  ] Added 1 plugin object descriptor(s) from [../bin/OpenViBE-plugins-feature-extraction-dynamic.dll]
[  INF  ] Added 15 plugin object descriptor(s) from [../bin/OpenViBE-plugins-file-io-dynamic.dll]
[  INF  ] Added 1 plugin object descriptor(s) from [../bin/OpenViBE-plugins-matlab-dynamic.dll]
[  INF  ] Added 9 plugin object descriptor(s) from [../bin/OpenViBE-plugins-samples-dynamic.dll]
[  INF  ] Added 28 plugin object descriptor(s) from [../bin/OpenViBE-plugins-signal-processing-dynamic.dll]
[  INF  ] Added 20 plugin object descriptor(s) from [../bin/OpenViBE-plugins-signal-processing-gpl-dynamic.dll]
[  INF  ] Added 17 plugin object descriptor(s) from [../bin/OpenViBE-plugins-simple-visualisation-dynamic.dll]
[  INF  ] Added 11 plugin object descriptor(s) from [../bin/OpenViBE-plugins-stimulation-dynamic.dll]
[  INF  ] Added 19 plugin object descriptor(s) from [../bin/OpenViBE-plugins-stream-codecs-dynamic.dll]
[  INF  ] Added 3 plugin object descriptor(s) from [../bin/OpenViBE-plugins-streaming-dynamic.dll]
[  INF  ] Added 4 plugin object descriptor(s) from [../bin/OpenViBE-plugins-tools-dynamic.dll]
[  INF  ] Added 4 plugin object descriptor(s) from [../bin/OpenViBE-plugins-vrpn-dynamic.dll]
Trying to load driver
Driver Loaded
[WARNING] Registery key Software\VB and VBA Program Settings\Brain Quick - System 98\EEG_Settings is not initialized
[  INF  ] Connecting to device [gTec gMOBIlab+]...
mDevice is: 00000640
l_oPortName is: \\.\COM9
m_oPortName is: \\.\COM9
[  INF  ] Connection succeeded !
[  INF  ] Starting the acquisition...
[  INF  ] Now acquiring...

(OpenViBE-acquisition-server-dynamic.exe:2960): Gdk-WARNING **: gdkpixmap-win32.c:302: CreateDIBSection failed:

(OpenViBE-acquisition-server-dynamic.exe:2960): Gdk-WARNING **: gdkpixmap-win32.c:114: DeleteObject failed: Operazione completata.

(OpenViBE-acquisition-server-dynamic.exe:2960): GLib-GObject-CRITICAL **: g_object_ref: assertion `G_IS_OBJECT (object)' failed

(OpenViBE-acquisition-server-dynamic.exe:2960): Gdk-CRITICAL **: gdk_drawable_get_size: assertion `GDK_IS_DRAWABLE (drawable)' failed
Premere un tasto per continuare . . .

lbonnet
Site Admin
Posts: 417
Joined: Wed Oct 07, 2009 12:11 pm

Re: Driver gMobilabPlus under Windows

Post by lbonnet »

Hi Andrea,

It looks like Gtk crashed somehow...
Did you do/see something special during the acquisition with the interface ?

Please edit your personal configuration file (C:/users/you/openvibe.conf) and add the following line :
Kernel_MainLogLevel = Debug
Don't forget a line feed at the end.

Then reproduce the crash, and send us the log file produced by the acquisition server (in dist/log). Maybe we will find something interesting in it.

You can also build the acquisition server in Debug mode (by calling "win32-build.cmd --debug"). Don't build all openvibe in debug, just the acquisition server (you can select which project you want to build at the end of win32-init_env_command.cmd, when the build-order is produced).
Then you can ask for a debug when the application crashes with visual C++ (if you are using it...).

I hope we will manage to get it working... it's a nice contribution for the software !

Laurent
Follow us on twitter >> openvibebci

Checkout my (old) blog for some OpenViBE tips & tricks : here !

keldon7
Posts: 12
Joined: Fri Nov 25, 2011 11:31 am

Re: Driver gMobilabPlus under Windows

Post by keldon7 »

I'm Late, I know....but the departement was closed so i can't do test until yesterday....

I compiled the acquisition server in debug mode and....It Worked....
No Error, No Crash,No message, Nothing
I will do other test to understand what/where is the problem but if the problem is really inside the gtk library i can't do anything.



Meanwhile here the log.
Attachments
openvibe-acquisition-server.log.zip
(160.6 KiB) Downloaded 528 times

lbonnet
Site Admin
Posts: 417
Joined: Wed Oct 07, 2009 12:11 pm

Re: Driver gMobilabPlus under Windows

Post by lbonnet »

Hm.. strange bahavior indeed.

From the log file I see a problem at the end :

Code: Select all

[ TRACE ] CDriverGTecGMobiLabPlus::start
[ TRACE ] GT_InitChannels failed
[ ERROR ] Starting failed !
GT_InitChannels is called at the beginning of the start method. I assume the acquisition didn't start at some point?


And for the Gtk crash, just to be sure... you didn't change anything in the configuration interface file (interface-GTec-GMobiLabPlus.ui in [trunc/share]) did you?

Laurent-
Follow us on twitter >> openvibebci

Checkout my (old) blog for some OpenViBE tips & tricks : here !

keldon7
Posts: 12
Joined: Fri Nov 25, 2011 11:31 am

Re: Driver gMobilabPlus under Windows

Post by keldon7 »

Ehm...Right!
That lines can be ignored because they are my mistake.

I modified the interface-GTec-GMobiLabPlus.ui file modifying this

Code: Select all

<object class="GtkListStore" id="model2">
    <columns>
      <!-- column-name gchararray -->
      <column type="gchararray"/>
    </columns>
    <data>
      <row>
        <col id="0" translatable="yes">/dev/rfcomm0</col>
      </row>
      <row>
        <col id="0" translatable="yes">/dev/rfcomm1</col>
      </row>
    </data>
  </object>
with this

Code: Select all

<object class="GtkListStore" id="model2">
    <columns>
      <!-- column-name gchararray -->
      <column type="gchararray"/>
    </columns>
    <data>
      <row>
        <col id="0" translatable="yes">////./COM1</col>
      </row>
      <row>
        <col id="0" translatable="yes">////./COM2</col>
      </row>
      <row>
        <col id="0" translatable="yes">////./COM3</col>
      </row>
      <row>
        <col id="0" translatable="yes">////./COM4</col>
      </row>
      <row>
        <col id="0" translatable="yes">////./COM5</col>
      </row>
      <row>
        <col id="0" translatable="yes">////./COM6</col>
      </row>
      <row>
        <col id="0" translatable="yes">////./COM7</col>
      </row>
      <row>
        <col id="0" translatable="yes">////./COM8</col>
      </row>
      <row>
        <col id="0" translatable="yes">////./COM9</col>
      </row>
      <row>
        <col id="0" translatable="yes">////./COM10</col>
      </row>
      <row>
        <col id="0" translatable="yes">////./COM11</col>
      </row>
      <row>
        <col id="0" translatable="yes">////./COM12</col>
      </row>
      <row>
        <col id="0" translatable="yes">////./COM13</col>
      </row>
      <row>
        <col id="0" translatable="yes">////./COM14</col>
      </row>
      <row>
        <col id="0" translatable="yes">////./COM15</col>
      </row>
      <row>
        <col id="0" translatable="yes">////./COM16</col>
      </row>
    </data>
  </object>
but it's only a menu list to choose the connection's port.....and if i don't remember wrong i modified this row after the change in debug mode.

keldon7
Posts: 12
Joined: Fri Nov 25, 2011 11:31 am

Re: Driver gMobilabPlus under Windows

Post by keldon7 »

Here a new log (without my mistakes)
It's clean, no error
Attachments
openvibe-acquisition-server.zip
(34.79 KiB) Downloaded 552 times

lbonnet
Site Admin
Posts: 417
Joined: Wed Oct 07, 2009 12:11 pm

Re: Driver gMobilabPlus under Windows

Post by lbonnet »

Hi !

Ok I'm glad you resolved the gtk error. It's quiet common when you are modifying the interface, happened to me several times :)

The log file is clean, excepted for the warning message about high drift :

Code: Select all

[WARNING] After 6.413000 seconds, theorical samples per second does not match real samples per second
[WARNING]   Received : 1856 (0x740) samples
[WARNING]   Should have received : 1666 (0x682) samples
[WARNING]   Drift was : 190 (0xbe) samples (10.230000%)
[WARNING]   Added : 0 (0x0) samples (0.000000%)
[WARNING]   Removed : 190 (0xbe) samples (10.230000%)
[WARNING]   The driver obviously tried to correct this difference
[WARNING]   Please submit a bug report (including the acquisition server log file or at least this complete message) for the driver you are using
I see in the log file that the sampling frequency is 256Hz and the default drift correction occurs when the drift is above 2ms.

Code: Select all

[ TRACE ] Driver monitoring drift tolerance set to 2 (0x2) milliseconds - eq 0 (0x0) samples
0 samples tolerance is a bit restrictive. When using your driver you can set the tolerance to 4ms (1 sample) or even more (8ms), to check if the driver corrects itself over time. You can also try longer acquisition session. maybe the drift is no longer a problem after some time (6 seconds acquisition is a bit low to judge).

When you are thinking that your driver is quiet stable and working good, we can integrate it in the official release ! (next version is scheduled at the end of January). This would mean that we will mark the driver as compatible on windows, and you would be officially identified as the contributor.

Let me know if you need more help

Laurent
Follow us on twitter >> openvibebci

Checkout my (old) blog for some OpenViBE tips & tricks : here !

keldon7
Posts: 12
Joined: Fri Nov 25, 2011 11:31 am

Re: Driver gMobilabPlus under Windows

Post by keldon7 »

Hi!
I tried different acquisitions with the server compiled in release mode and changing only the DriftTolleranceValue

Code: Select all

AcquisitionServer_DriftToleranceDuration = 2
AcquisitionServer_DriftToleranceDuration = 4
AcquisitionServer_DriftToleranceDuration = 8
AcquisitionServer_DriftToleranceDuration = 16
AcquisitionServer_DriftToleranceDuration = 32
AcquisitionServer_DriftToleranceDuration = 64
and

Code: Select all

Kernel_MainLogLevel = Information
In all of these case the application crash (sometimes after 30 secs sometimes after 2 minutes and seems not to be a correlation between the crash time and the driftTollerance).

BUT
if i change the Kernel_MainLogLevel to debug mode, the application doesn't crash....

in my last test i tried

Code: Select all

Kernel_MainLogLevel = Debug
AcquisitionServer_DriftToleranceDuration = 8
and after 17 minutes the acquisition server was still running

lbonnet
Site Admin
Posts: 417
Joined: Wed Oct 07, 2009 12:11 pm

Re: Driver gMobilabPlus under Windows

Post by lbonnet »

There should be no correlation between log levels and acquisition drift...

I checked rapidly the driver implementation and the log messages printed in them. I found something strange around line 280 in loop().

Code: Select all

m_rDriverContext.getLogManager() << LogLevel_Debug << "Here are the " << l_ui32ChannelCount << " measures of the " << i << " th sample\n" << LogLevel_Debug;
for(j=0; j<l_ui32ChannelCount; j++)
{
	m_rDriverContext.getLogManager() << (m_oBuffer.pBuffer[j]*0.5)/32768. << " ";
	//operation made to modify the short int in a number between 0 and 500mV (in Volt)
	m_pSample[m_ui32SampleCountPerSentBlock*j+i] = (m_oBuffer.pBuffer[j]*0.5)/32768.;
}
m_rDriverContext.getLogManager() << "\n";
Not very common use of the log system. It should work but... Can you modify this part in your version of the code and comment every log ? So you get only the useful part :

Code: Select all

for(j=0; j<l_ui32ChannelCount; j++)
{
	//operation made to modify the short int in a number between 0 and 500mV (in Volt)
	m_pSample[m_ui32SampleCountPerSentBlock*j+i] = (m_oBuffer.pBuffer[j]*0.5)/32768.;
}
And try again.
It's a long shot ... but I'm out of new idea...

L
Follow us on twitter >> openvibebci

Checkout my (old) blog for some OpenViBE tips & tricks : here !

keldon7
Posts: 12
Joined: Fri Nov 25, 2011 11:31 am

Re: Driver gMobilabPlus under Windows

Post by keldon7 »

Hi!
I was looking on internet the warnings
"gdkpixmap-win32.c:302: CreateDIBSection failed"
and
"gdkpixmap-win32.c:114: DeleteObject failed"
and i found a many pages with both problems and crash.
It seems that the problem is a bug in the gtk libraries and in the "gtkrc" file.
As possible i will try to change the gtk libraries with another version...

Cross the finger!


Andrea

keldon7
Posts: 12
Joined: Fri Nov 25, 2011 11:31 am

Re: Driver gMobilabPlus under Windows

Post by keldon7 »

Hi guys!
I'm not forget about you. :mrgreen:
Finally, after a very long time of driver testing, i can say "IT WORKS" :D :D :D
I have one question...
I can give you only the windows driver (and you will update your) or i must add my driver with the Linux's one?

in a few day i will update:
ovasCDriverGTechGMobiLabPlus.cpp and .h
ovasCConfigurationGTechGMobiLabPlus.cpp and .h
interface-GTec-GMobiLabPlus.ui
FindThirdPartyGMobilabPlus.Cmake

sorry for the wait.....
^_^

Post Reply