Example #1
0
    void setupNeuro()
    {
        tgHandleId = ThinkGear.TG_GetNewConnectionId();

        tgConnectionStatus = ThinkGear.TG_Connect(tgHandleId,
                                                  "\\\\.\\COM3",
                                                  ThinkGear.BAUD_9600,
                                                  ThinkGear.STREAM_PACKETS);
        ThinkGear.TG_EnableBlinkDetection(tgHandleId, 1);
    }
Example #2
0
        public bool Connect(string comPort, int baud, bool runAsync, bool trace)
        {
            // get the driver version
            _tgState.Version = ThinkGear.TG_GetDriverVersion();
            LogText("ThinkGear DLL Version: " + _tgState.Version);

            // get a new connection ID
            _connectionId = ThinkGear.TG_GetNewConnectionId();
            LogText("Connection ID: " + _connectionId);

            // if < 0, we have an error
            if (_connectionId < 0)
            {
                return(false);
            }

            // turn on tracing
            if (trace)
            {
                ThinkGear.TG_SetStreamLog(_connectionId, "streamLog.txt");
                ThinkGear.TG_SetDataLog(_connectionId, "dataLog.txt");
            }

            // connect to the device
            int connect = ThinkGear.TG_Connect(_connectionId, @"\\.\" + comPort, baud, ThinkGear.STREAM_PACKETS);

            LogText("Connect: " + connect);

            // if < 0, we have an error
            if (connect < 0)
            {
                return(false);
            }

            _connected = true;

            // if runAsync, start a new polling thread
            if (runAsync)
            {
                _event = new AutoResetEvent(false);

                _polling = true;
                Thread t = new Thread(PollThinkGear);
                t.IsBackground = true;
                t.Start();
            }

            return(true);
        }