thinkgear脑电采集


基于neurosky的脑电采集套件,vs2010上数据接收DEMO
资源截图
代码片段和文件信息
#include 
#include 

#include “thinkgear.h“

/**
 * Prompts and waits for the user to press ENTER.
 */
void
wait() {
    printf( “
“ );
    printf( “Press the ENTER key...
“ );
    fflush( stdout );
    getc( stdin );
}

/**
 * Program which prints ThinkGear EEG_POWERS values to stdout.
 */
int
main( void ) {

    char *comPortName = NULL;
    int   dllVersion = 0;
    int   connectionId = 0;
    int   packetsRead = 0;
    int   errCode = 0;

    /* Print driver version number */
    dllVersion = TG_GetDriverVersion();
    printf( “ThinkGear DLL version: %d
“ dllVersion );

    /* Get a connection ID handle to ThinkGear */
    connectionId = TG_GetNewConnectionId();
    if( connectionId < 0 ) {
        fprintf( stderr “ERROR: TG_GetNewConnectionId() returned %d.
“ 
                 connectionId );
        wait();
        exit( EXIT_FAILURE );
    }

    /* Set/open stream (raw bytes) log file for connection */
    errCode = TG_SetStreamLog( connectionId “streamLog.txt“ );
    if( errCode < 0 ) {
        fprintf( stderr “ERROR: TG_SetStreamLog() returned %d.
“ errCode );
        wait();
        exit( EXIT_FAILURE );
    }

    /* Set/open data (ThinkGear values) log file for connection */
    errCode = TG_SetDataLog( connectionId “dataLog.txt“ );
    if( errCode < 0 ) {
        fprintf( stderr “ERROR: TG_SetDataLog() returned %d.
“ errCode );
        wait();
        exit( EXIT_FAILURE );
    }

    /* Attempt to connect the connection ID handle to serial port “COM5“ */
    comPortName = “\\.\COM3“;
    errCode = TG_Connect( connectionId 
                          comPortName 
                          TG_BAUD_57600 
                          TG_STREAM_PACKETS );
    if( errCode < 0 ) {
        fprintf( stderr “ERROR: TG_Connect() returned %d.
“ errCode );
        wait();
        exit( EXIT_FAILURE );
    }

    /* Read 10 ThinkGear Packets from the connection 1 Packet at a time */
    packetsRead = 0;
    while( 1 ) {

        /* Attempt to read a Packet of data from the connection */
        errCode = TG_ReadPackets( connectionId 1 );

        /* If TG_ReadPackets() was able to read a complete Packet of data... */
        if( errCode == 1 ) {
            packetsRead++;


 if( TG_GetValueStatus(connectionId TG_DATA_POOR_SIGNAL) != 0 ) {

                /* Get and print out the updated attention value */
                fprintf( stdout “New PQ value: %d

                         (int)TG_GetValue(connectionId TG_DATA_POOR_SIGNAL) );
                fflush( stdout );

            }

            /* If attention value has been updated by TG_ReadPackets()... */
            if( TG_GetValueStatus(connectionId TG_DATA_MEDITATION) != 0 ) {

                /* Get and print out the updated attention value */
                fprintf( stdout “New attention value: %d

                         (int)TG_GetValue(connectionId TG_DATA_MEDITATION) );
                fflush( stdout );

            } /* end “

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-08-07 09:48  thinkgear_testapp
     文件     4625936  2013-06-01 13:26  thinkgear_testappdataLog.txt
     目录           0  2013-08-07 09:48  thinkgear_testappDebug
     文件           0  2013-01-12 09:16  thinkgear_testappDebugdataLog.txt
     文件       24201  2013-01-12 09:16  thinkgear_testappDebugstreamLog.txt
     文件      557056  2010-06-29 12:42  thinkgear_testappDebug hinkgear.dll
     文件        2576  2013-08-07 09:48  thinkgear_testappDebug hinkgear_testapp.Build.CppClean.log
     文件         478  2013-08-07 09:48  thinkgear_testappDebug hinkgear_testapp.log
     目录           0  2013-08-07 09:47  thinkgear_testappipch
     目录           0  2013-08-07 09:47  thinkgear_testappipch hinkgear_testapp-e8d51887
     文件     2031616  2013-08-07 09:47  thinkgear_testappipch hinkgear_testapp-e8d51887 hinkgear_testapp-9f109853.ipch
     文件     4917099  2013-06-01 13:26  thinkgear_testappstreamLog.txt
     文件      557056  2010-06-29 12:42  thinkgear_testapp hinkgear.dll
     文件       31198  2010-06-29 12:42  thinkgear_testapp hinkgear.h
     文件        9262  2010-06-29 12:42  thinkgear_testapp hinkgear.lib
     文件        3283  2013-06-01 13:23  thinkgear_testapp hinkgear_testapp.c
     文件        4544  2013-01-11 10:25  thinkgear_testapp hinkgear_testapp.dsp
     文件         557  2013-01-11 09:26  thinkgear_testapp hinkgear_testapp.dsw
     文件       41984  2013-01-14 16:00  thinkgear_testapp hinkgear_testapp.ncb
     文件       55808  2013-01-14 16:00  thinkgear_testapp hinkgear_testapp.opt
     文件        1371  2013-01-14 15:55  thinkgear_testapp hinkgear_testapp.plg
     文件     1855488  2013-08-07 09:48  thinkgear_testapp hinkgear_testapp.sdf
     文件         900  2013-05-06 11:34  thinkgear_testapp hinkgear_testapp.sln
     文件       13824  2013-08-07 09:48  thinkgear_testapp hinkgear_testapp.suo
     文件        6352  2013-08-07 09:47  thinkgear_testapp hinkgear_testapp.vcxproj
     文件        1108  2013-08-07 09:47  thinkgear_testapp hinkgear_testapp.vcxproj.filters
     文件         143  2013-01-15 14:33  thinkgear_testapp hinkgear_testapp.vcxproj.user
     文件        2991  2013-01-12 09:16  thinkgear_testapp hinkgear_testappmmmm.c

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)