/// <summary> /// Prefix a given command to the packet in question. /// </summary> /// <param name="instr"> /// The instruction to be prefixed. /// </param> /// <param name="data"> /// The data to which the instruction will be prefixed, or null to create an empty packet with a 128-byte null payload. /// </param> /// <returns> /// The fully formed packet. /// </returns> private byte[] prefixCommand(ProgrammerInstruction instr, byte[] data) { //Get the ushort code for the instruction. ushort instruction = (ushort)instr; //Create a new USB-HID packet. byte[] packet = new byte[130]; //FIXME in special compressed 128-byte case //If we received a data packet, copy it in. if (data != null) data.CopyTo(packet, 2); //Copy in the instruction code packet[0] = (byte)(instruction & 0xFF); packet[1] = (byte)((instruction >> 8) & 0xFF); //return the completed packet return packet; }
public ProgrammerPacket(ProgrammerInstruction instr, byte[] control, byte[] address, byte[] payload) { if(control.Length != 3) throw new InvalidPacketException(); }