Example #1
0
static void checkSignals(void) {
	// Check for UNIT IRQ
	if (signal_pending(SIGNAL_UNIT_IRQ) &&
			signal_status(SIGNAL_UNIT_IRQ)) {
		// Notify only on transitionn to LOW value
		notifyFault();
	}
	// Checking for BUTTON
	if (signal_pending(SIGNAL_PLAT_BUTTON)) {
		DB2(LOG_INFO("USR BUTTON [%d]\r\n\n",
					signal_status(SIGNAL_PLAT_BUTTON)));
		buttonHandler();
	}
}
Example #2
0
// The task to process Console events
static void btn_task(iptr_t timer) {
	ticks_t start = timer_clock();
	ticks_t elapsed;
	(void)timer;

	DB2(LOG_INFO("Button timer...\r\n"));

	// LightUp all LEDS to notify calibration/reset pending
	LED_NOTIFY_ON();

	// Wait for button release or reset timeout
	while (!signal_status(SIGNAL_PLAT_BUTTON)) {
		elapsed = timer_clock() - start;
		if ( ms_to_ticks(BTN_RESET_SEC*1000) <= elapsed ) {
			// Button pressed fot t > BTN_CHECK_SEC+BTN_RESET_SEC
			reset_board();
		}
		DELAY(100);
	}

	// Button pressed BTN_CHECK_SEC < t < BTN_CHECK_SEC+BTN_RESET_SEC
	LED_NOTIFY_OFF();
	ERR_OFF();

	controlCalibration();

}
Example #3
0
void NORETURN chsTesting(void) {

	LOG_INFO(".:: CHs Testing\r\n");

	// Enabling all channels
	chEnabled = 0xFFFF;
	// Starting from CH[0]
	curCh = 0;

	while(1) {

		// Read power from ADE7753 meter
		readMeter(curCh);

		// Switch channel on Button push
		if (signal_pending(SIGNAL_PLAT_BUTTON) &&
				signal_status(SIGNAL_PLAT_BUTTON)) {
			curCh++;
			if (curCh>15)
				curCh=0;
			switchAnalogMux(curCh);
		}
	}

}
Example #4
0
void		interpret_status(int status)
{
	if (WIFEXITED(status))
		exit_status(WEXITSTATUS(status));
	if (WIFSTOPPED(status))
		stop_status(WSTOPSIG(status));
	if (WIFSIGNALED(status))
		signal_status(WTERMSIG(status));
}
Example #5
0
void sigTesting() {

	LOG_INFO(".:: External Interrupt Testing\r\n");

	while(1) {

		DELAY(1000);

		LOG_INFO("PINC: 0x%02X\r\n", PINC);
		if (signal_pending(SIGNAL_PLAT_BUTTON)) {
			LOG_INFO("EVT: Button [%hd]\r\n",
					signal_status(SIGNAL_PLAT_BUTTON));
		}
		if (signal_pending(SIGNAL_UNIT_IRQ)) {
			LOG_INFO("EVT: RCT Unit Fault [%hd]\r\n",
					signal_status(SIGNAL_UNIT_IRQ));
		}
	}
}
Example #6
0
static void buttonHandler(void) {

	// Button pressed
	if (!signal_status(SIGNAL_PLAT_BUTTON)) {
		// Schedule timer task
		synctimer_add(&btn_tmr, &timers_lst);
		return;
	}

	// Button released
	synctimer_abort(&btn_tmr);

}
Example #7
0
/*
 * put a line from host to parser
 * if info is recognized, a signal is sent, and, however,
 * the return type indicates the type of information
 */
InfoType Parser::put_line(const QString &txt, class NetworkConnection * connection, GSName gsName)
{
	
	QString line = txt.trimmed();
	int pos;
	class BoardDispatch * boarddispatch = 0;
	class RoomDispatch * roomdispatch = connection->getDefaultRoomDispatch();
	class NetworkDispatch * dispatch = connection->getDefaultDispatch();
	class ConsoleDispatch * console = connection->getConsoleDispatch();
	qDebug(line.toLatin1().constData());
	if (line.length() == 0)
	{
		// skip empty lines but write message if
		// a) not logged in
		// b) help files
		if ((gsName == GS_UNKNOWN) || (!memory_str.isEmpty() && memory_str.contains("File")))
		{
			console->recvText(txt.toLatin1().constData());
			return MESSAGE;
		}

		// white space only
		return WS;
	}

	// skip console commands
	if (line.indexOf(CONSOLECMDPREFIX,0) != -1)
		return NONE;

	// check for connection status
	if (line.indexOf("Connection closed",0,Qt::CaseInsensitive) != -1)
	{
		emit signal_connexionClosed();
		console->recvText(txt.toLatin1().constData());
		gsName = GS_UNKNOWN;
		return IT_OTHER;
	}
	else if (line.indexOf("IGS entry on",0) != -1)
	{
		connection->onReady();
		return SERVERNAME;
	}

	//
	// LOGON MODE ----------------------
	//
	// try to find out server and set mode
#ifdef OLD
	// why would we not know the server type?
	if (gsName == GS_UNKNOWN)
	{
		if (line.indexOf("IGS entry on",0) != -1)
		{
			gsName = IGS;
			emit signal_svname(gsName);
			return SERVERNAME;
		}

		if (line.indexOf("LGS #",0) != -1)
		{
			gsName = LGS;
			emit signal_svname(gsName);
			return SERVERNAME;
		}

		if (line.indexOf("NNGS #",0) != -1)
		{
			gsName = NNGS;
			emit signal_svname(gsName);
			return SERVERNAME;
		}

		// suggested by Rod Assard for playing with NNGS version 1.1.14
		if (line.indexOf("Server (NNGS)",0) != -1)
		{
			gsName = NNGS;
			emit signal_svname(gsName);
			return SERVERNAME;
		}

		if (line.indexOf("WING #",0) != -1)
		{
			gsName = WING;
			emit signal_svname(gsName);
			return SERVERNAME;
		}

		if (line.indexOf("CTN #",0) != -1)
		{
			gsName = CTN;
			emit signal_svname(gsName);
			return SERVERNAME;
		}

		// adapted from NNGS, chinese characters
		if (line.indexOf("CWS #",0) != -1 || line.indexOf("==CWS",0) != -1)
		{
			gsName = CWS;
			emit signal_svname(gsName);
			return SERVERNAME;
		}

		// critical: TO BE WATCHED....
		if (line.indexOf("#>",0) != -1)
		{
			gsName = DEFAULT;
			emit signal_svname(gsName);
			return SERVERNAME;
		}

		// account name
		if (line.indexOf("Your account name is",0) != -1)
		{
			buffer = line.right(line.length() - 21);
			buffer.replace(QRegExp("[\".]"), "");
			emit signal_accname(buffer);
			return ACCOUNT;
		}

		// account name as sent from telnet.cpp
		if (line.indexOf("...sending:") != -1)
		{
			if ((buffer = element(line, 0, "{", "}")) == NULL)
				return IT_OTHER;
			emit signal_accname(buffer);
			return ACCOUNT;
		}

		if ((line.indexOf("guest account",0) != -1) || line.contains("logged in as a guest"))
		{
			emit signal_status(GUEST);
			return STATUS;
		}

		if (line.at(0) != '9' && !memory)
		{
			//emit signal_message(txt);
			console->recvText(txt.toLatin1().constData());
			return MESSAGE;
		}
	}
#endif //OLD

	//
	// LOGON HAS DONE, now parse: ----------------------
	//
	// get command type:
	bool ok;
	int cmd_nr = element(line, 0, " ").toInt(&ok);
	if (!ok && !memory_str.isEmpty() && memory_str.contains("CHANNEL"))
	{
		connection->onReady();
		// special case: channel info
		cmd_nr = 9;
	}
	else if (!ok || !memory_str.isEmpty() && memory_str.contains("File") && !line.contains("File"))
	{
		// memory_str == "File": This is a help message!
		// skip action if entering client mode
		if (line.indexOf("Set client to be True", 0, Qt::CaseInsensitive) != -1)
			return IT_OTHER;

		if (memory == 14)
			// you have message
			emit signal_msgBox(line);
		else
			console->recvText(txt.toLatin1().constData());

		if (line.indexOf("#>") != -1 && !memory_str.isEmpty() && !memory_str.contains("File"))
			return NOCLIENTMODE;

		return MESSAGE;
	}
	else
	{
		// remove command number
		line = line.remove(0, 2).trimmed();
	}
	//qDebug("%s", line.toLatin1().constData());

	// correct cmd_nr for special case; if quiet is set to false a game may not end...
	if (cmd_nr == 9 && line.contains("{Game"))
	{
		qDebug("command changed: 9 -> 21 !!!");
		cmd_nr = 21;
	}

	// case 42 is equal to 7
	if (cmd_nr == 42 && gsName != IGS)
	{
		// treat as game info
		cmd_nr = 7;
		qDebug("command changed: 42 -> 7 !!!");
	}

	// process for different servers has particular solutions
	// command mode -> expect result
	switch (cmd_nr)
	{
		// PROMPT
		

	
// IGS:48 Game 354 qGoDev requests an adjournment
		case 48:
			// have a look at case 9

			break;
// 51 Say in game 583
		case 51:
			// we could get the game id number here and store it
			// its weird that there's also a case 11 message
			break;
		// IGS review protocol
		// 56 CREATE 107
		// 56 DATA 107
		// 56 OWNER 107 eb5 3k
		// 56 BOARDSIZE 107 19
		// 56 OPEN 107 1
		// 56 KIBITZ 107 1
		// 56 KOMI 107 0.50
		// 56 TITLE 107 yfh22-eb5(B) IGS
		// 56 SGFNAME 107 yfh22-eb5-09-03-24
		// 56 WHITENAME 107 yfh22
		// 56 WHITERANK 107 1d?
		// 56 BLACKNAME 107 eb5
		// 56 BLACKRANK 107 3k
		// 56 GAMERESULT 107 B+Resign
		// 56 NODE 107 1 0 0 0
		// 56 NODE 107 2 1 16 4
		// 56 NODE 107 3 2 16 16
		// 56 NODE 107 4 1 4 4
		// 56 NODE 107 5 2 4 16
		// 56 NODE 107 1 0 0 0
		// 56 CONTROL 107 eb5
		// 56 DATAEND 107
		// 56 ERROR That user's client does not support review.
		// 56 INVITED_PLAY 58 yfh2test

		case 56:
#ifdef FIXME
			if (line.contains("CREATE"))
				aGame->number = element(line, 1, " ").toInt();
			if (line.contains("OWNER"))
				aGame->player = element(line, 2, " ");
			if (line.contains("BOARDSIZE"))
			{
				aGame->board_size = element(line, 2, " ").toInt();			
				memory = aGame->board_size;
			}
			if (line.contains("KOMI"))
				aGame->K = element(line, 2, " ");
			if (line.contains("WHITENAME"))
				aGame->wname = element(line, 2, " ");
			if (line.contains("WHITERANK"))
			{
				aGame->white_rank = element(line, 2, " ");
				fixRankString(&(aGame->white_rank));
				aGame->white_rank_score = rankToScore(aGame->white_rank);
			}
			if (line.contains("BLACKNAME"))
				aGame->black_name = element(line, 2, " ");
			if (line.contains("BLACKRANK"))
			{
				aGame->black_rank = element(line, 2, " ");
				fixRankString(&(aGame->black_rank));
				aGame->black_rank_score = rankToScore(aGame->black_rank);
			}
			if (line.contains("GAMERESULT"))
			{
				aGame->res = element(line, 2, " ");
				emit signal_gameReview(aGame);
				break;
			}

			if (line.contains("INVITED_PLAY"))
			{
				emit signal_reviewInvite(element(line, 1, " "), element(line, 2, " "));
				break ;
			}

			if (line.contains("NODE"))
			{
				
				StoneColor sc = stoneNone;
				int c = element(line, 3, " ").toInt();
				
				if (c==1)
					sc = stoneBlack;
				else if(c==2)
					sc=stoneWhite;


				emit signal_reviewNode(element(line, 1, " ").toInt(), element(line, 2, " ").toInt(), sc, element(line, 4, " ", "EOL").toInt() ,element(line, 3, " ").toInt() );
				break ;
			}
#endif //FIXME



			break;


	}

	return IT_OTHER;
}