Beispiel #1
0
        private int _rx_buffer_pointer;                       // points to next available element in the rx buffer

        //-------------------------------------------------------------------------------------------------------------------------------------------
        public Amulet(string port, int baudrate, AmuletSlaveResponseType response_type, IAmuletClient client = null)
        {
            _client         = client;
            _response_type  = response_type;
            _response_event = new AutoResetEvent(false);

            Debug.Print("creating serial port");
            _port = new SerialPort(port, baudrate, Parity.None, 8, StopBits.One);
            Debug.Print("setting serial port read timeout");
            _port.ReadTimeout = 1000;
            Debug.Print("opening serial port");
            _port.Open();
            Debug.Print("flushing serial port buffer");
            _port.Flush();
            Debug.Print("registering serial port data event handler");
            _port.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived);
            Debug.Print("RAM left: " + Debug.GC(true) + " bytes");
        }
Beispiel #2
0
        private int _rx_buffer_pointer; // points to next available element in the rx buffer

        //-------------------------------------------------------------------------------------------------------------------------------------------
        public Amulet( string port, int baudrate, AmuletSlaveResponseType response_type, IAmuletClient client=null)
        {
            _client = client;
            _response_type = response_type;
            _response_event = new AutoResetEvent( false);

            Debug.Print( "creating serial port");
            _port = new SerialPort( port, baudrate, Parity.None, 8, StopBits.One);
            Debug.Print( "setting serial port read timeout");
            _port.ReadTimeout = 1000;
            Debug.Print( "opening serial port");
            _port.Open();
            Debug.Print( "flushing serial port buffer");
            _port.Flush();
            Debug.Print( "registering serial port data event handler");
            _port.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived);            
            Debug.Print( "RAM left: " + Debug.GC( true) + " bytes");
        }