void runConsoleLoop(ts_channel_s *console) { if (boardConfiguration->startConsoleInBinaryMode) { // switch to binary protocol consoleInBinaryMode = true; runBinaryProtocolLoop(console, true); } while (true) { efiAssertVoid(getRemainingStack(chThdGetSelfX()) > 256, "lowstck#9e"); bool end = getConsoleLine((BaseSequentialStream*) console->channel, console->crcReadBuffer, sizeof(console->crcReadBuffer) - 3); if (end) { // firmware simulator is the only case when this happens continue; } char *trimmed = efiTrim(console->crcReadBuffer); (console_line_callback)(trimmed); if (consoleInBinaryMode) { #if EFI_SIMULATOR || defined(__DOXYGEN__) logMsg("Switching to binary mode\r\n"); #endif // switch to binary protocol runBinaryProtocolLoop(console, true); } } }
static msg_t tsThreadEntryPoint(void *arg) { (void) arg; chRegSetThreadName("tunerstudio thread"); #if EFI_PROD_CODE || defined(__DOXYGEN__) startTsPort(); #endif runBinaryProtocolLoop(&tsChannel, false); #if defined __GNUC__ return 0; #endif }
static msg_t consoleThreadThreadEntryPoint(void *arg) { (void) arg; chRegSetThreadName("console thread"); #if (EFI_PROD_CODE && EFI_USB_SERIAL) || defined(__DOXYGEN__) if (!isSerialOverUart()) { /** * This method contains a long delay, that's the reason why this is not done on the main thread */ usb_serial_start(); } #endif /* EFI_PROD_CODE */ binaryConsole.channel = (BaseChannel *) getConsoleChannel(); while (true) { efiAssert(getRemainingStack(chThdSelf()) > 256, "lowstck#9e", 0); bool end = getConsoleLine((BaseSequentialStream*) getConsoleChannel(), consoleInput, sizeof(consoleInput)); if (end) { // firmware simulator is the only case when this happens continue; } char *trimmed = efiTrim(consoleInput); (console_line_callback)(trimmed); if (consoleInBinaryMode) { #if EFI_SIMULATOR || defined(__DOXYGEN__) logMsg("Switching to binary mode\r\n"); #endif // switch to binary protocol runBinaryProtocolLoop(&binaryConsole, true); } } #if defined __GNUC__ return false; #endif }