private static SpiEngineStatus GetSpiEngineStatusFromBytes(byte[] data) { // according with the manual, the command never faults SpiEngineStatus response = new SpiEngineStatus(); response.ExternalRequestPending = data[2] == 0; switch (data[3]) { case 0: response.BusOwner = SpiBusOwner.NoOwner; break; case 1: response.BusOwner = SpiBusOwner.UsbBridge; break; case 2: response.BusOwner = SpiBusOwner.ExternalMaster; break; default: throw new NotImplementedException(); } response.AttemptedPasswordAccesses = data[4]; response.PasswordGuessed = data[5] == 1; return(response); }
public SpiEngineStatus CancelCurrentTransfer() { // create the packet byte[] packet = new byte[Constants.PacketsSize]; packet[0] = CommandCodes.CancelCurrentSpiTransfer; // send the packet byte[] reply = _hidHandler.WriteData(packet); // check for errors if (reply[0] != CommandCodes.CancelCurrentSpiTransfer) { throw new PacketReplyFormatException(); } // according with the manual, the command never faults SpiEngineStatus response = GetSpiEngineStatusFromBytes(reply); return(response); }
public SpiEngineStatus ReadEngineStatus() { // create the packet byte[] packet = new byte[Constants.PacketsSize]; packet[0] = CommandCodes.ReadCurrentSpiStatus; // send the packet byte[] reply = _hidHandler.WriteData(packet); // check for errors if (reply[0] != CommandCodes.ReadCurrentSpiStatus) { throw new PacketReplyFormatException(); } // get the response SpiEngineStatus response = GetSpiEngineStatusFromBytes(reply); return(response); }