示例#1
0
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);
		}
	}
}
示例#2
0
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        
}
示例#3
0
TEST(misc, testMisc) {
	print("******************************************* testMisc\r\n");
	strcpy(buff, "  ab  ");
	// we need a mutable array here
	ASSERT_TRUE(strEqual("ab", efiTrim(buff)));


	{
		float v = atoff("1.0");
		assertEqualsM("atoff", 1.0, v);
	}
	{
		float v = atoff("nan");
		ASSERT_TRUE(cisnan(v)) << "NaN atoff";
	}
	{
		float v = atoff("N");
		ASSERT_TRUE(cisnan(v)) << "NaN atoff";
	}

//	ASSERT_EQ(true, strEqual("spa3", getPinName(SPARKOUT_3_OUTPUT)));
//	ASSERT_EQ(SPARKOUT_12_OUTPUT, getPinByName("spa12"));
}
示例#4
0
static void handleExecuteCommand(ts_channel_s *tsChannel, char *data, int incomingPacketSize) {
	tunerStudioWriteCrcPacket(tsChannel, TS_RESPONSE_COMMAND_OK, NULL, 0);
	data[incomingPacketSize] = 0;
	char *trimmed = efiTrim(data);
	(console_line_callback)(trimmed);
}