void sr5WriteData(ts_channel_s *tsChannel, const uint8_t * buffer, int size) { efiAssertVoid(CUSTOM_ERR_6570, getRemainingStack(chThdGetSelfX()) > 64, "tunerStudioWriteData"); #if EFI_SIMULATOR || defined(__DOXYGEN__) logMsg("chSequentialStreamWrite [%d]\r\n", size); #endif #if TS_UART_DMA_MODE && EFI_PROD_CODE UNUSED(tsChannel); int transferred = size; uartSendTimeout(TS_DMA_UART_DEVICE, (size_t *)&transferred, buffer, BINARY_IO_TIMEOUT); #else if (tsChannel->channel == NULL) return; // int transferred = chnWriteTimeout(tsChannel->channel, buffer, size, BINARY_IO_TIMEOUT); // temporary attempt to work around #553 // instead of one huge packet let's try sending a few smaller packets int transferred = 0; int stillToTransfer = size; while (stillToTransfer > 0) { int thisTransferSize = minI(stillToTransfer, 768); transferred += chnWriteTimeout(tsChannel->channel, buffer, thisTransferSize, BINARY_IO_TIMEOUT); buffer += thisTransferSize; stillToTransfer -= thisTransferSize; } #endif #if EFI_SIMULATOR || defined(__DOXYGEN__) logMsg("transferred [%d]\r\n", transferred); #endif if (transferred != size) { #if EFI_SIMULATOR || defined(__DOXYGEN__) logMsg("!!! NOT ACCEPTED %d out of %d !!!", transferred, size); #endif /* EFI_SIMULATOR */ scheduleMsg(&tsLogger, "!!! NOT ACCEPTED %d out of %d !!!", transferred, size); } }
void bus_tx() { size_t n = sizeof(Frame); uartSendTimeout(&UARTD2, &n, &framebuf.raw, TIME_INFINITE); }