Beispiel #1
0
        public FaultPDU(byte[] buffer, int offset) : base(buffer, offset)
        {
            offset        += CommonFieldsLength;
            AllocationHint = LittleEndianReader.ReadUInt32(buffer, ref offset);
            ContextID      = LittleEndianReader.ReadUInt16(buffer, ref offset);
            CancelCount    = ByteReader.ReadByte(buffer, ref offset);
            Reserved       = ByteReader.ReadByte(buffer, ref offset);
            Status         = (FaultStatus)LittleEndianReader.ReadUInt32(buffer, ref offset);
            Reserved2      = LittleEndianReader.ReadUInt32(buffer, ref offset);
            int dataLength = FragmentLength - AuthLength - offset;

            Data         = ByteReader.ReadBytes(buffer, ref offset, dataLength);
            AuthVerifier = ByteReader.ReadBytes(buffer, offset, AuthLength);
        }
Beispiel #2
0
        /// <summary>
        /// Get current fault status of PiJuice
        /// </summary>
        /// <returns>PiJuice fault status</returns>
        public FaultStatus GetFaultStatus()
        {
            FaultStatus faultStatus = new FaultStatus();

            var response = _piJuice.ReadCommand(PiJuiceCommand.FaultEvent, 1);

            faultStatus.ButtonPowerOff                  = (response[0] & 0x01) == 0x01;
            faultStatus.ForcedPowerOff                  = (response[0] & 0x02) == 0x02;
            faultStatus.ForcedSystemPowerOff            = (response[0] & 0x04) == 0x04;
            faultStatus.WatchdogReset                   = (response[0] & 0x08) == 0x08;
            faultStatus.BatteryProfileInvalid           = (response[0] & 0x20) == 0x20;
            faultStatus.BatteryChargingTemperatureFault = (BatteryChargingTemperatureFault)(response[0] >> 6 & 0x03);

            return(faultStatus);
        }