예제 #1
0
        public void ToggleLight()
        {
            SerialPort oCon = (SerialPort)this.HttpContext.Application["SerialSensor"];
            var sc = new SerialClient();

            sc.ToggleLight(oCon);
        }
예제 #2
0
        public string GetSensors()
        {
            SerialPort oCon = (SerialPort)this.HttpContext.Application["SerialSensor"]; // We put the serial connection in here so that it's a global object

            var sc = new SerialClient();
            SensorModel stats;

            try
            {
                stats = sc.SensorReadLine(oCon);
                string output = JsonConvert.SerializeObject((object)stats);
                return output;
            }
            catch(Exception ex)
            {
                return "error: " + ex.Message;
            }
        }