string SendBurnHandshake(byte op) { EnsureBurnMode(); CommandBlockWrapper cbw = CommandBlockWrapper.Create(true); cbw.dCBWTag = 0x4b485348 + (uint)op; cbw.dCBWDataTransferLength = 32; cbw.bCBWCBLength = 2; cbw.CBWCB[0] = 0xf8; cbw.CBWCB[1] = op; WriteToUSB(StructToBytes(cbw)); byte[] handshakeResponse = ReadFromUSB(32); byte[] cswBytes = ReadFromUSB((uint)Marshal.SizeOf(typeof(CommandStatusWrapper))); CommandStatusWrapper csw = BytesToStruct <CommandStatusWrapper>(cswBytes); if (csw.dCSWSignature != CommandStatusWrapper.SIGNATURE) { return(null); } if (csw.dCSWTag != cbw.dCBWTag) { return(null); } if (csw.bCSWStatus != 0) { return(null); } return(Encoding.ASCII.GetString(handshakeResponse).TrimEnd('\0')); }