int8_t STM32F7USB::notify(ManuvrMsg* active_event) { int8_t return_value = 0; switch (active_event->eventCode()) { case MANUVR_MSG_XPORT_QUEUE_RDY: read_port(); if (_accumulator.count()) { char* working_chunk = _accumulator.position(0); if (write_port((uint8_t*) working_chunk, strlen(working_chunk))) { // TODO: Fail-over timer? Disconnection signal? _accumulator.drop_position(0); } } return_value++; break; case MANUVR_MSG_SYS_BOOTLOADER: case MANUVR_MSG_SYS_REBOOT: case MANUVR_MSG_SYS_SHUTDOWN: connected(false); listening(false); TM_USBD_Stop(TM_USB_FS); // DeInit() The USB device. return_value++; break; default: return_value += ManuvrXport::notify(active_event); break; } if (local_log.length() > 0) Kernel::log(&local_log); return return_value; }
/** * Log has reached the end of its journey. This class will render it to the user. * * @param buf A pointer to the buffer. * @param len How long the buffer is. * @param mm A declaration of memory-management responsibility. * @return A declaration of memory-management responsibility. */ int8_t STM32F7USB::toCounterparty(StringBuilder* buf, int8_t mm) { _accumulator.concatHandoff(buf); if (connected() && !_tx_in_progress) { char* working_chunk = _accumulator.position(0); if (write_port((uint8_t*) working_chunk, strlen(working_chunk))) { // TODO: Fail-over timer? Disconnection signal? _accumulator.drop_position(0); } } return MEM_MGMT_RESPONSIBLE_BEARER; // We took the buffer. }