Fix VCP support for new Tx bytes free vtable entry

This commit is contained in:
Nicholas Sherlock 2015-09-24 21:46:52 +12:00
parent 94affd5841
commit ca2a6d9cdd
2 changed files with 11 additions and 3 deletions

View File

@ -648,8 +648,11 @@ blackboxBufferReserveStatus_e blackboxDeviceReserveBufferSpace(int32_t bytes)
// Handle failure:
switch (masterConfig.blackbox_device) {
case BLACKBOX_DEVICE_SERIAL:
// One byte of the tx buffer isn't available for user data (due to its circular list implementation), hence the -1
if (bytes > (int32_t) blackboxPort->txBufferSize - 1) {
/*
* One byte of the tx buffer isn't available for user data (due to its circular list implementation),
* hence the -1. Note that the USB VCP implementation doesn't use a buffer and has txBufferSize set to zero.
*/
if (blackboxPort->txBufferSize && bytes > (int32_t) blackboxPort->txBufferSize - 1) {
return BLACKBOX_RESERVE_PERMANENT_FAILURE;
}

View File

@ -99,7 +99,12 @@ void usbVcpWrite(serialPort_t *instance, uint8_t c)
}
const struct serialPortVTable usbVTable[] = { { usbVcpWrite, usbVcpAvailable, usbVcpRead, usbVcpSetBaudRate, isUsbVcpTransmitBufferEmpty, usbVcpSetMode } };
uint8_t usbTxBytesFree() {
// Because we block upon transmit and don't buffer bytes, our "buffer" capacity is effectively unlimited.
return 255;
}
const struct serialPortVTable usbVTable[] = { { usbVcpWrite, usbVcpAvailable, usbTxBytesFree, usbVcpRead, usbVcpSetBaudRate, isUsbVcpTransmitBufferEmpty, usbVcpSetMode } };
serialPort_t *usbVcpOpen(void)
{