hobd.OBD2Sensor.SetValue C# (CSharp) Method

SetValue() public method

public SetValue ( byte dataraw ) : bool
dataraw byte
return bool
        public virtual bool SetValue(byte[] dataraw)
        {
            data_offset = 0;
            while(data_offset < dataraw.Length-1 && !(dataraw[data_offset] == 0x41 && dataraw[data_offset+1] == this.Command))
            {
            data_offset++;
            }
            if (data_offset >= dataraw.Length-1)
            {
            data_offset = 0;
            /*
               If we set OBD2 command explicitly,
               this means we should find this command in response.
               In case command was not found - response is assumed to be invalid.
            */
            if (Command != -1)
                return false;
            }

            this.dataraw = dataraw;

            try{
            this.Value = obdValue(this);
            }catch(Exception){
            string r = "";
            for (int i = 0; i < dataraw.Length; i++)
               r += dataraw[i].ToString("X2") + " ";
            Logger.error("OBD2Sensor", "Fail parsing sensor value: " + this.ID + " " + r);
            return false;
            }
            this.TimeStamp = DateTimeMs.Now;
            registry.TriggerListeners(this);
            return true;
        }