Thinkgear Connection API: thinkgear.h Source File

- Main Page
- Files

- File List
- Globals

# thinkgear.h

Go to the documentation of this file.

    00001 /*
    00002  * @(#)thinkgear.h    4.2    Sep 28, 2009
    00003  *
    00004  * Copyright (c) 2008-2009 NeuroSky, Inc. All Rights Reserved
    00005  * NEUROSKY PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
    00006  */
    00007
    00008 /* Ensure this header is only included once */
    00009 #ifndef THINKGEAR_H_
    00010 #define THINKGEAR_H_
    00011
    00069 /* Disable name-mangling when compiling as C++ */
    00070 #ifdef __cplusplus
    00071 extern "C" {
    00072 #endif
    00073
    00074 /* This block is standard for DLL macro definitions, and
    00075  * typical users should ignore this block entirely.
    00076  * Maintainers of the DLL should define THINKGEAR_DLL_COMPILE
    00077  * when compiling the DLL.
    00078  */
    00079 #ifdef NO_DLL_MODIFIERS
    00080 #define THINKGEAR_API
    00081 #else
    00082 #if defined(_WIN32)
    00083 #if defined(THINKGEAR_DLL_COMPILE)
    00084 #define THINKGEAR_API __declspec( dllexport )
    00085 #else /* !THINKGEAR_DLL_COMPILE */
    00086 #define THINKGEAR_API __declspec( dllimport )
    00087 #endif /* !THINKGEAR_DLL_COMPILE */
    00088 #else /* !_WIN32 */
    00089 #define THINKGEAR_API extern
    00090 #endif /* !_WIN32 */
    00091 #endif /* !NO_DLL_MODIFIERS */
    00092 /* Allow only for XP and above */
    00093 #if !defined(WINVER)
    00094 #define WINVER 0x0501
    00095 #endif
    00096
    00101 #define TG_MAX_CONNECTION_HANDLES 128
    00102
    00106 #define TG_BAUD_1200         1200
    00107 #define TG_BAUD_2400         2400
    00108 #define TG_BAUD_4800         4800
    00109 #define TG_BAUD_9600         9600
    00110 #define TG_BAUD_57600       57600
    00111 #define TG_BAUD_115200     115200
    00112
    00116 #define TG_STREAM_PACKETS      0
    00117 #define TG_STREAM_5VRAW        1
    00118 #define TG_STREAM_FILE_PACKETS 2
    00119
    00127 #define TG_DATA_BATTERY             0
    00128 #define TG_DATA_POOR_SIGNAL         1
    00129 #define TG_DATA_ATTENTION           2
    00130 #define TG_DATA_MEDITATION          3
    00131 #define TG_DATA_RAW                 4
    00132 #define TG_DATA_DELTA               5
    00133 #define TG_DATA_THETA               6
    00134 #define TG_DATA_ALPHA1              7
    00135 #define TG_DATA_ALPHA2              8
    00136 #define TG_DATA_BETA1               9
    00137 #define TG_DATA_BETA2              10
    00138 #define TG_DATA_GAMMA1             11
    00139 #define TG_DATA_GAMMA2             12
    00140 #define TG_DATA_BLINK_STRENGTH     37
    00141
    00142
    00150 THINKGEAR_API int
    00151 TG_GetDriverVersion();
    00152
    00153
    00173 THINKGEAR_API int
    00174 TG_GetNewConnectionId();
    00175
    00176
    00201 THINKGEAR_API int
    00202 TG_SetStreamLog( int connectionId, const char *filename );
    00203
    00204
    00229 THINKGEAR_API int
    00230 TG_SetDataLog( int connectionId, const char *filename );
    00231
    00232
    00233 /*
    00234  * Writes a message given by @c msg into the Connection's Stream Log.
    00235  * Optionally the message can be written onto a new line preceded by
    00236  * a timestamp.  The Connection's Stream Log must be already opened
    00237  * by TG_SetStreamLog(), otherwise this function returns an error.
    00238  *
    00239  * @param connectionId    The ID of the ThinkGear Connection to write
    00240  *                        into the Stream Log for, as obtained from
    00241  *                        TG_GetNewConnectionId().
    00242  * @param insertTimestamp If set to any non-zero number, a newline
    00243  *                        and timestamp are automatically prepended
    00244  *                        to the @c msg in the Stream Log file.  Pass
    00245  *                        a zero for this parameter to disable the
    00246  *                        insertion of newline and timestamp before
    00247  *                        @c msg.
    00248  * @param msg             The message to write into the Stream Log
    00249  *                        File.  For Stream Log parsers to ignore
    00250  *                        the message as a human-readable comment
    00251  *                        instead of hex bytes, prepend a '#' sign
    00252  *                        to indicate it is a comment.
    00253  *
    00254  * @return -1 if @c connectionId does not refer to a valid ThinkGear
    00255  *         Connection ID handle.
    00256  *
    00257  * @return -2 if Stream Log for the @c connectionId has not been
    00258  *         opened for writing via TG_SetStreamLog().
    00259  *
    00260  * @return 0 on success.
    00261  */
    00262 THINKGEAR_API int
    00263 TG_WriteStreamLog( int connectionId, int insertTimestamp, const char *msg );
    00264
    00265
    00266 /*
    00267  * Writes a message given by @c msg into the Connection's Data Log.
    00268  * Optionally the message can be written onto a new line preceded by
    00269  * a timestamp.  The Connection's Data Log must be already opened
    00270  * by TG_SetDataLog(), otherwise this function returns an error.
    00271  *
    00272  * @param connectionId    The ID of the ThinkGear Connection to write
    00273  *                        into the Data Log for, as obtained from
    00274  *                        TG_GetNewConnectionId().
    00275  * @param insertTimestamp If set to any non-zero number, a newline
    00276  *                        and timestamp are automatically prepended
    00277  *                        to the @c msg in the Stream Log file.  Pass
    00278  *                        a zero for this parameter to disable the
    00279  *                        insertion of newline and timestamp before
    00280  *                        @c msg.
    00281  * @param msg             The message to write into the Data Log
    00282  *                        File.  For Data Log parsers to ignore
    00283  *                        the message as a human-readable comment
    00284  *                        instead of hex bytes, prepend a '#' sign
    00285  *                        to indicate it is a comment.
    00286  *
    00287  * @return -1 if @c connectionId does not refer to a valid ThinkGear
    00288  *         Connection ID handle.
    00289  *
    00290  * @return -2 if Data Log for the @c connectionId has not been
    00291  *         opened for writing via TG_SetDataLog().
    00292  *
    00293  * @return 0 on success.
    00294  */
    00295 THINKGEAR_API int
    00296 TG_WriteDataLog( int connectionId, int insertTimestamp, const char *msg );
    00297
    00298
    00337 THINKGEAR_API int
    00338 TG_EnableLowPassFilter( int connectionId, int rawSamplingRate );
    00339
    00340
    00360 THINKGEAR_API int
    00361 TG_EnableBlinkDetection( int connectionId, int enable );
    00362
    00363
    00406 THINKGEAR_API int
    00407 TG_Connect( int connectionId, const char *serialPortName, int serialBaudrate,
    00408             int serialDataFormat );
    00409
    00410
    00448 THINKGEAR_API int
    00449 TG_ReadPackets( int connectionId, int numPackets );
    00450
    00451
    00468 THINKGEAR_API int
    00469 TG_GetValueStatus( int connectionId, int dataType );
    00470
    00471
    00499 THINKGEAR_API float
    00500 TG_GetValue( int connectionId, int dataType );
    00501
    00502
    00540 THINKGEAR_API int
    00541 TG_SendByte( int connectionId, int b );
    00542
    00543
    00572 THINKGEAR_API int
    00573 TG_SetBaudrate( int connectionId, int serialBaudrate );
    00574
    00575
    00598 THINKGEAR_API int
    00599 TG_SetDataFormat( int connectionId, int serialDataFormat );
    00600
    00601
    00644 THINKGEAR_API int
    00645 TG_EnableAutoRead( int connectionId, int enable );
    00646
    00647
    00663 THINKGEAR_API void
    00664 TG_Disconnect( int connectionId );
    00665
    00666
    00679 THINKGEAR_API void
    00680 TG_FreeConnection( int connectionId );
    00681
    00682
    00683
    00684 /* BEGIN FUNCTIONS FOR JNI SUPPORT */
    00685 #if defined(COMPILE_FOR_JNI)
    00686
    00687 #include <jni.h>
    00688
    00689 /*
    00690  * Class:     ThinkGear
    00691  * Method:    GetDriverVersion
    00692  * Signature: ()I
    00693  */
    00694 JNIEXPORT jint JNICALL
    00695 Java_ThinkGear_GetDriverVersion( JNIEnv *, jclass );
    00696
    00697 /*
    00698  * Class:     ThinkGear
    00699  * Method:    GetNewConnectionId
    00700  * Signature: ()I
    00701  */
    00702 JNIEXPORT jint JNICALL
    00703 Java_ThinkGear_GetNewConnectionId( JNIEnv *, jclass );
    00704
    00705 /*
    00706  * Class:     ThinkGear
    00707  * Method:    SetStreamLog
    00708  * Signature: (ILjava/lang/String;)I
    00709  */
    00710 JNIEXPORT jint JNICALL
    00711 Java_ThinkGear_SetStreamLog( JNIEnv *, jclass, jint, jstring );
    00712
    00713 /*
    00714  * Class:     ThinkGear
    00715  * Method:    SetDataLog
    00716  * Signature: (ILjava/lang/String;)I
    00717  */
    00718 JNIEXPORT jint JNICALL
    00719 Java_ThinkGear_SetDataLog( JNIEnv *, jclass, jint, jstring );
    00720
    00721 /*
    00722  * Class:     ThinkGear
    00723  * Method:    WriteDataLog
    00724  * Signature: (IILjava/lang/String;)I
    00725  */
    00726 JNIEXPORT jint JNICALL
    00727 Java_ThinkGear_WriteStreamLog( JNIEnv *, jclass, jint, jint, jstring );
    00728
    00729 /*
    00730  * Class:     ThinkGear
    00731  * Method:    WriteDataLog
    00732  * Signature: (IILjava/lang/String;)I
    00733  */
    00734 JNIEXPORT jint JNICALL
    00735 Java_ThinkGear_WriteDataLog( JNIEnv *, jclass, jint, jint, jstring );
    00736
    00737 /*
    00738  * Class:     ThinkGear
    00739  * Method:    Connect
    00740  * Signature: (ILjava/lang/String;II)I
    00741  */
    00742 JNIEXPORT jint JNICALL
    00743 Java_ThinkGear_Connect( JNIEnv *, jclass, jint, jstring, jint, jint );
    00744
    00745 /*
    00746  * Class:     ThinkGear
    00747  * Method:    ReadPackets
    00748  * Signature: (II)I
    00749  */
    00750 JNIEXPORT jint JNICALL
    00751 Java_ThinkGear_ReadPackets( JNIEnv *, jclass, jint, jint );
    00752
    00753 /*
    00754  * Class:     ThinkGear
    00755  * Method:    GetValue
    00756  * Signature: (II)D
    00757  */
    00758 JNIEXPORT jdouble JNICALL
    00759 Java_ThinkGear_GetValue( JNIEnv *, jclass, jint, jint );
    00760
    00761 /*
    00762  * Class:     ThinkGear
    00763  * Method:    GetValueStatus
    00764  * Signature: (II)I
    00765  */
    00766 JNIEXPORT jint JNICALL
    00767 Java_ThinkGear_GetValueStatus( JNIEnv *, jclass, jint, jint );
    00768
    00769 /*
    00770  * Class:     ThinkGear
    00771  * Method:    SendByte
    00772  * Signature: (II)I
    00773  */
    00774 JNIEXPORT jint JNICALL
    00775 Java_ThinkGear_SendByte( JNIEnv *, jclass, jint, jint );
    00776
    00777 /*
    00778  * Class:     ThinkGear
    00779  * Method:    SetBaudrate
    00780  * Signature: (II)I
    00781  */
    00782 JNIEXPORT jint JNICALL
    00783 Java_ThinkGear_SetBaudrate( JNIEnv *, jclass, jint, jint );
    00784
    00785 /*
    00786  * Class:     ThinkGear
    00787  * Method:    SetDataFormat
    00788  * Signature: (II)I
    00789  */
    00790 JNIEXPORT jint JNICALL
    00791 Java_ThinkGear_SetDataFormat( JNIEnv *, jclass, jint, jint );
    00792
    00793 /*
    00794  * Class:     ThinkGear
    00795  * Method:    Disconnect
    00796  * Signature: (I)V
    00797  */
    00798 JNIEXPORT void JNICALL
    00799 Java_ThinkGear_Disconnect( JNIEnv *, jclass, jint );
    00800
    00801 /*
    00802  * Class:     ThinkGear
    00803  * Method:    FreeInstance
    00804  * Signature: (I)V
    00805  */
    00806 JNIEXPORT void JNICALL
    00807 Java_ThinkGear_FreeInstance( JNIEnv *, jclass, jint );
    00808
    00809 #endif /* COMPILE_FOR_JNI */
    00810 /* END FUNCTIONS FOR JNI SUPPORT */
    00811
    00812
    00813 #ifdef __cplusplus
    00814 }  /* extern "C" */
    00815 #endif
    00816
    00817 #endif /* THINKGEAR_H_ */