Example #1
0
void JDnsShared::jdns_debugLinesReady()
{
	QJDns *jdns = (QJDns *)sender();
	int x = indexByJDns(jdns);
	if(x != -1)
		doDebug(jdns, x);
}
Example #2
0
STATIC void parseString( const char *str ) {

/**/myassert( str != NULL );
    for(;;) {
        while( isspace( *str ) ) ++str;
        switch( *str ) {
        case 0:
            return;
        case SWCHAR:
        case '-':
            str += 2;
            switch( str[-1] ) {
            case 'o':   str = doOutput( str );      break;
            case 'd':   str = doDebug( str );       break;
            case 'p':   str = doParse( str );       break;
            case 'f':   str = doFile( str );        break;
            case 'q':   /* FALL THROUGH */
#if 0
            case 'l':
#endif
            case 'b':   str = doToggle( str );      break;
            default:    usage();
            }
            if( !isBreakChar( *str ) ) usage();
            break;
        case INCCHAR:
            str = doInclude( str + 1 );
            break;
        case CMTCHAR:
            str = doComment( str + 1 );
            break;
        default:
            str = addFile( str );
            break;
        }
    }

}
Example #3
0
	static void doAll() { doDebug(); doInfo(); doWarn(); doError(); }
Example #4
0
bool JDnsShared::addInterface(const QHostAddress &addr)
{
	if(shutting_down)
		return false;

	QString str;
	int index = instances.count();

	str = QString("attempting to use interface %1").arg(addr.toString());
	if(db)
		db->addDebug(dbname + QString::number(index), QStringList() << str);

	QJDns *jdns;

	if(mode == UnicastInternet || mode == UnicastLocal)
	{
		jdns = new QJDns(this);
		jdns_link(jdns);
		if(!jdns->init(QJDns::Unicast, addr))
		{
			doDebug(jdns, index);
			delete jdns;
			return false;
		}

		if(mode == UnicastLocal)
		{
			QJDns::NameServer host;
			host.address = QHostAddress("224.0.0.251");
			host.port = 5353;
			jdns->setNameServers(QList<QJDns::NameServer>() << host);
		}
	}
	else
	{
		// only one instance supported for now (see more in the
		//   comment below)
		if(!instances.isEmpty())
			return false;

		jdns = new QJDns(this);
		jdns_link(jdns);

		// instead of binding to the requested address, we'll bind
		//   to "Any".  this is because QJDns doesn't support
		//   multiple interfaces.  however, if that ever changes,
		//   we can update the code here and things should be mostly
		//   transparent to the user of JDnsShared.
		//if(!jdns->init(QJDns::Multicast, addr))
		if(!jdns->init(QJDns::Multicast, QHostAddress::Any))
		{
			doDebug(jdns, index);
			delete jdns;
			return false;
		}
	}

	Instance *i = new Instance;
	i->jdns = jdns;
	i->addr = addr;
	instances += i;

	if(mode == UnicastInternet)
		applyNameServers(i);

	str = QString("interface ready");
	if(db)
		db->addDebug(dbname + QString::number(index), QStringList() << str);

	return true;
}
Example #5
0
int main(void)
{
	/* Initialize System */
	initSystem();

	/* switch Spektrum Receiver ON */
	/* no Bind at the moment */
	*SPEKTRUM_BIND = 1;

	/* Init virtual EEPROM */
	initEEPROM();
	
  
	print_uart1("CorvusM3 FC - Version 0.1\r\n");
	
	// for test
	//char x [80];
	//sprintf(x,"%d:%d:%d\r\n",smoothValue(100,150,0),smoothValue(100,150,100),smoothValue(100,150,40));
	//print_uart1(x);
	
	
	// read sensors for calibration
	setLEDStatus(LED_FLASH);
	
	// read parameters from flash
	loadParameter();
	
	// function open ....
	setLEDStatus(LED_BLINK);
	
	
	// Controlloop --> statemachine() --> Timer 3
	TIM_ITConfig(TIM3, TIM_IT_Update, ENABLE);
  
	while (1)
	{

		// test accu
		if (getParameter(PARA_VOLT) > ADCSensorValue[VOLT])
		{
			// low accu
			errorCode |= ERROR_AKKU; // set bit
		}
		else
		{
			// accu OK
			errorCode &= ~ERROR_AKKU; // delete bit
		}
		
		// if something in RxBuffer
		if (is_read_uart1())
		{
			getComm();
		}
		
		/* Debug Output 20Hz ---------------------------------------------------*/
		if (msCount % 50 == 0)
		{
			doDebug();
			
			// for test
			//char x [80];
			//sprintf(x,"%d\r\n",errorCode);
			//print_uart1(x);
		}
		

		
		/* do LED -----------------------------------------------------------*/
		if (errorCode == 0)
		{
			setLEDStatus(LED_ON);
		}
		else if (errorCode < 2) // akku
		{
			setLEDStatus(LED_BLINK);
		}
		else if (errorCode < 8) // rc and sensor
		{
			setLEDStatus(LED_FLASH);
		}
		
	}
}