예제 #1
0
        public void TestNewDataSubscriber()
        {
            ConfigurationData config = new ConfigurationData();
            OBDDeviceCommunicatorAsync obd = new OBDDeviceCommunicatorAsync(null, config);

            string PIDreturn_engineLoad = "7E8 03 41 04 FF";
            // 0x03 bytes, mode (0x41 - 0x40) = 0x01, PID 0x04, message 0xFF = 0d255
            // betekenis: Calculated engine load value (%). Formule: A*100/255 = 255*100/255 = 100%
            string expectedAnswer = "100";
            int mode = 0x01;
            int sensor = 0x04;

            bool answered = false;
            string answer = "";
            PIDSensor loadValueSensor = config.GetSensor(mode, sensor);
            loadValueSensor.RaiseOBDSensorData += (object sender, OBDSensorDataEventArgs s) =>
            {
                answer = s.value;
                answered = true;
            };
            obd.cleanAndHandleResponses(PIDreturn_engineLoad);
            DateTime startWaiting = DateTime.Now;
            while (!answered && DateTime.Now > startWaiting.AddSeconds(1)) ;
            Assert.IsTrue(answered, "Event didn't raise within one second");
            Assert.IsTrue(answer == expectedAnswer, "Event value incorrect: is %s, should be %s", answer, expectedAnswer);

            // string PIDreturn_throttlePosition = "7E8 03 41 04 1B";
            // 0x03 bytes, mode (0x41 - 0x40) = 0x01, PID 0x11 = 0d17, message 0x26 = 0d38
            // betekenis: Throttle position (%). Formule: A*100/255 = 38*100/255 = 7%
        }
예제 #2
0
        public void TestPartiallyValidMessage()
        {
            string PIDreturn = "STOPPED\r\r>7E8 03 7F 10 13 \r7E8 03 41 04 1B \r7E8 03 41 11 26 \r\r>STOPPED\r\r>7E8 03 7F 11 13 ";
            OBDDeviceCommunicatorAsync obd = new OBDDeviceCommunicatorAsync(null, new ConfigurationData());

            obd.cleanAndHandleResponses(PIDreturn); // shouldn't raise an error
        }
예제 #3
0
        public void TestMultipleMessagesMixed()
        {
            string PIDreturn = "ELM327 v1.5\r\n\r\n>01 00\r\n41 00 BE 3F A8 11 \r\n\r\n>";
            OBDDeviceCommunicatorAsync obd = new OBDDeviceCommunicatorAsync(null, new ConfigurationData());

            obd.cleanAndHandleResponses(PIDreturn); // shouldn't raise an error
        }