super(setupPacket, dataPacket);
}
public void createTDs(UHCIPipe pipe)
throws USBException {
final SetupPacket setupPacket = getSetupPacket();
// The setup TD
setupTD = pipe.createTD(USB_PID_SETUP, true, setupPacket.getData(), 0, setupPacket.getSize(), false);
//log.debug("setupTD: " + setupTD + ", ls=" + ls);
// Add the data TD's
final USBPacket dataPacket = getDataPacket();
final int transferLength = setupPacket.getLength();
int length = transferLength;
int offset = 0;
final int dataPid = (setupPacket.isDirIn() ? USB_PID_IN : USB_PID_OUT);
boolean dataToggle = false; // Start with DATA1
final int maxPacketSize = pipe.getMaxPacketSize();
if (maxPacketSize <= 0) {
throw new USBException("Invalid maximum packet size " + maxPacketSize);
}
while (length > 0) {
// Create the TD for this part of the data packet
final TransferDescriptor dataTD;
final int curlen = Math.min(length, maxPacketSize);
dataTD = pipe.createTD(dataPid, dataToggle, dataPacket.getData(), offset, curlen, false);
// Add the TD to the list
setupTD.append(dataTD, false);
// Update fields
dataToggle = !dataToggle;
length -= curlen;
offset += curlen;
}
// Add final control packet
final TransferDescriptor statusTD;
final int statusPid = ((setupPacket.isDirOut() || (transferLength == 0)) ? USB_PID_IN : USB_PID_OUT);
statusTD = pipe.createTD(statusPid, false, null, 0, 0, true);
// Append theTD to the list
setupTD.append(statusTD, false);
}