TMSi Refa8 Acquisition Module

Forum for software developers to discuss BCI2000 software development
Locked
louismayo
Posts: 20
Joined: 25 Jun 2007, 05:40

TMSi Refa8 Acquisition Module

Post by louismayo » 13 Jul 2007, 10:37

Hello,

I have develloped an acquisition module for TMSi device called Refa8. In oder to do so, I applied the following procedure:
  • * Download Borland
    * Token the bci2000 sources with SVN
    * Create a new Refa Directory and place the RandomNumber Project (*.cpp *ADC.cpp *ADC.h properly renamed as refa.cpp refaADC.cpp refaADC.h)
    * Inserted the home-made TMSiLib.h and TMSiLib.cpp with the three TMSiStrat() TMSiStop() and TMSiWaitForData() function, as required in the wiki. All those functions have been tested.
    * Compile everythink from bci2000.bdsgroup in Borland
Then I used the acquisition module (Refa.exe) from bcilauncher.exe with P3Procesing and P3Speller but get the following messages:

Code: Select all

13/07/2007 14:33:45 -  DataIOFilter::Preflight: Expected an ADC filter instance to be present.

13/07/2007 14:33:45 -  TransmissionFilter: A necessary condition is violated. Please make sure 
that the following is true: Parameter( "SoftwareCh" ) <= InputProperties.Channels().
Here is a part from the P3Speller_Refa.prm.

Code: Select all

Source:DataIOFilter int SoftwareCh= 32 16 1 128 
Source:DataIOFilter int SampleBlockSize= 8 5 1 128 
Source:DataIOFilter int SamplingRate= 128 128 1 4000
Source:DataIOFilter list ChannelNames= 32 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 
Source:TransmissionFilter int TransmitCh= 4 4 1 128 
Source:TransmissionFilter intlist TransmitChList= 32 6 7 8 9 1 1 128 
it looks different from what I thought I had fill in the config panel:

Code: Select all

Source:DataIOFilter int SoftwareCh= 32 
Source:DataIOFilter int SampleBlockSize= 8 
Source:DataIOFilter int SamplingRate= 128 
Source:DataIOFilter list ChannelNames= 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 
Source:TransmissionFilter int TransmitCh= 4
Source:TransmissionFilter intlist TransmitChList=  6 7 8 9 
The last 3 params seems to come from PARAMATER_DEFINITIONS in the RefaADC.cpp

Code: Select all

  BEGIN_PARAMETER_DEFINITIONS
	"Source int SourceCh=        32 64 128 "
        "// this is the number of digitized channels",
    "Source int SampleBlockSize= 16 5 1 128 "
        "// this is the number of samples transmitted at a time",
    "Source int SamplingRate=    128 128 1 4000 "
        "// this is the sample rate",
  END_PARAMETER_DEFINITIONS
but I don't get how they are used (why 4 of them for exemple and why those values).

In order to understand how it worked, I launch the operat. exe without the Refa.exe which I used from Borland Debugger: the point is I was unable to place a Stop-point at this point (in the creator Refa::RefaADC() ).

The questions are:
  • * Could you give me some pointers to understand better how does this PARAMETERS_DEFINITION works. (For exemple, I imagine I can get the channels names from the device and put them to BCI2k)
    * Is there a better way to debug the acquisition module (Is there any fault in the way I do?)
If anybody could give some tips it will be really appreciated.

Thanks

Louis

mellinger
Posts: 1341
Joined: 12 Feb 2003, 11:06

Post by mellinger » 16 Jul 2007, 09:25

Louis,

the error message from the DataIOFilter suggests that there is a problem with your ADC filter's instantiation -- the DataIOFilter cannot find an ADC filter instance to use for data input.

There are some possible reasons for this --
- Is your ADC filter's cpp listed as part of your source module in the project view?
- Does your ADC filter inherit from GenericADC (rather than from GenericFilter directly)?
- Is there a statement

Code: Select all

RegisterFilter( ClassName, 1 )
in your ADC's cpp (replace ClassName with your ADC filter's class name)?

Regarding your other questions:
* Could you give me some pointers to understand better how does this PARAMETERS_DEFINITION works. (For exemple, I imagine I can get the channels names from the device and put them to BCI2k)
BEGIN_PARAMETER_DEFINITIONS and END_PARAMETER_DEFINITIONS are preprocessor macros defined in shared/Environment.h. The code hiding behind them creates parameter objects from the string literals listed between the two macros. The format of those strings is the BCI2000 parameter line format as defined here: http://www.bci2000.org/wiki/index.php/P ... eter_Lines
You may modify parameter values in the constructor (after the definitions, if any). Use the standard way to access parameters:

Code: Select all

Parameter( "ChannelNames" )->SetNumValues( 5 );
Parameter( "ChannelNames" )( 2 ) = "CP3";
Modifying parameter values from the Initialize() function is not recommended because this will break the parameter validation scheme behing the Preflight() function.
* Is there a better way to debug the acquisition module (Is there any fault in the way I do?)
I think you are doing the right thing. If you cannot set a breakpoint in your code, there are two possible reasons I'm aware of:
- Sometimes, the IDE has a problem debugging executables that are not created in their associated bpr's directory. By default, BCI2000 modules are created in the BCI2000/prog directory. If you cannot set a breakpoint anywhere in the executable, change the project's output directory to empty in the project options, recompile, and run it from the IDE debugger. You should now be able to set breakpoints. Don't forget to remove its previous version from the BCI2000/prog directory to avoid confusion.
- Your code is never executed. E.g., if you omit the RegisterFilter statement, no instance of your ADC class is ever created, so the linker will not link your code into the executable. Consequently, you cannot set a breakpoint there.

Hope this helps,
Juergen

louismayo
Posts: 20
Joined: 25 Jun 2007, 05:40

Post by louismayo » 18 Jul 2007, 09:27

Juergen,

Thank you for your help. The acquisition module does work now. I still want to improve some parts and to clean and comment the source. After what I would be able to give it to you if you have any interrest in it (just let me know).

Thank you again

Louis

mellinger
Posts: 1341
Joined: 12 Feb 2003, 11:06

Post by mellinger » 18 Jul 2007, 10:26

Louis,

you are welcome to submit your source module.
In the future, we plan to have a contribution area on the server. For now, I ask you to send your code to Gerv once it is finished, along with some documentation that allows others to use it.

Cheers,
Juergen

Locked

Who is online

Users browsing this forum: No registered users and 0 guests