Beispiel #1
0
	void systemSpecificInit(){
		debugWrite("Begin of x86 init...");

		// Initialize the GDT
		gdtInit();		

		// TODO: Actual init stuff...
		debugWrite("Done with x86 init.");
	}
Beispiel #2
0
// Waits for the given string. Returns true if the string is received before a timeout.
// Returns false if a timeout occurs or if another string is received.
bool Sodaq_RN2483::expectString(const char* str, uint16_t timeout)
{
    debugPrint("[expectString] expecting "); debugPrint(str);
	
	

    unsigned long end  = millis() + timeout;
    while (millis() < end) {
        debugPrint(".");
		uint16_t len = readLn();
        if (len > 0) {
            debugPrint("("); debugWrite((uint8_t*)this->inputBuffer, len); debugPrint(")");

            if (strstr(this->inputBuffer, str) != NULL) {
                debugPrintLn(" found a match!");

                return true;
            }

            //return false;
        }
    }

    return false;
}
Beispiel #3
0
void onEndTestSet()
{
	ASSERT(s_currentTestCase.empty());
	ASSERT(s_currentTestCaseAsserts.empty());

	if (!s_quiet && !s_verbose)
	{
		tcout << std::endl;
	}

	if (!s_failures.empty())
	{
		const tstring failureCount = (s_quiet) ? Core::fmt(TXT(" %s: %u failure(s)"), s_currentTestSet.c_str(), s_failures.size())
											   : Core::fmt(TXT(" %u failure(s)"), s_failures.size());

		tcout << std::endl;
		tcout << failureCount << std::endl;

		for (size_t i = 0; i != s_failures.size(); ++i)
		{
			debugWrite(TXT(" > %s\n"), s_failures[i].c_str());
			tcout << TXT(" > ") << s_failures[i] << std::endl;

			for (size_t j = 0; j != s_failuresAsserts[i].size(); ++j)
			{
				debugWrite(TXT("  %s\n"), s_failuresAsserts[i][j].c_str());
				tcout << TXT("  ") << s_failuresAsserts[i][j] << std::endl;
			}
		}
	}

	if (!s_quiet)
	{
		tcout << std::endl;
	}

	s_currentTestSet.clear();
	s_failures.clear();
	s_failuresAsserts.clear();
	s_executed.clear();
	s_setup = nullptr;
	s_teardown = nullptr;
}
Beispiel #4
0
/******************************************************************************
 *
 * dtDebug
 *
 * PURPOSE
 *      This routine writes a time-stamped debug message.  The debug message
 *      string provided by the caller is prefixed with the current date & time
 *      using the following format:  "YYYY-MM-DD HH:MM:SS  ".
 *
 * PARAMETERS
 *      pData   IN  pointer to debug message
 *
 * RETURN VALUE
 *      None.
 *
 * NOTES
 *      The caller is responsible for providing any linefeed termination and
 *      messages longer than 100 characters will be truncated.
 *
 *****************************************************************************/
void dtDebug(const char *pData)
{
    char debugBuf[144];
    char tmpBuf[41];

    /* Print a time-stamped debug message. */
    sprintf(debugBuf, "%s  %.100s",
            dtFormatDebugDateTime(tmpBuf),
            pData);
    debugWrite(debugBuf);
}
Beispiel #5
0
bool DigiFi::get(char *aHost, char *aPath){
    if(connect(aHost) == 1){
        //delay(500);
        Serial1.print("GET ");
        Serial1.print(aPath);
        Serial1.print(" HTTP/1.1\r\nHost: ");
        Serial1.print(aHost);
        Serial1.print("\r\nCache-Control: no-cache\r\nConnection: close\r\n\r\n");
        Serial1.flush();

        //don't block while awating reply
        debug("wait for response...");
        bool success = true;
        int i=0;
        int st = millis();
        while(!Serial1.available()){
            if(millis() - st > requestTimeout * 1000) {
                success = false; 
                break;
            } 
            if(((millis() - st) % 1000) == 1)
                debugWrite('.');
            i++; 
        }
        debug("get header");
        if(success == false)
            return 0;
        aHeader = readResponse(0);
        debug(aHeader);

        String contentLength = aHeader.substring(aHeader.lastIndexOf("Content-Length: "));
        contentLength = contentLength.substring(16,contentLength.indexOf("\n"));
        debug(contentLength);

         debug("get body");
        aBody = readResponse(contentLength.toInt());

        return 1;
    }
    else
        return 0;

    //To do:
    /*
    User agent!
    Better handle timeouts/other errors
    Actually look at returned header for status
    Efficiency!
    */

}
Beispiel #6
0
String DigiFi::readResponse(int contentLength) //0 = cmd, 1 = header, 2=body
{
    String stringBuffer;
    char inByte;
    int rCount = 0;
    int nCount = 0;
    int curLength = 0;
    bool end = false;
    Serial1.flush();

    while (!end)
    {
        //look for this to be four bytes in a row
        if (Serial1.available())
        {
            inByte = Serial1.read();
            curLength++;
            debugWrite(inByte);

            if(contentLength == 0){
                if (inByte == '\n' && rCount == 2 && nCount == 1)
                {
                    end = true;
                    int strLength = stringBuffer.length()-3;
                    stringBuffer = stringBuffer.substring(0,strLength);
                }
                else if (inByte == '\r')
                    rCount++;
                else if (inByte == '\n')
                    nCount++;
                else{
                    rCount = 0;
                    nCount = 0;
                }
            }
            else if(curLength>=contentLength)
                end = true;
            
            stringBuffer += inByte;
        }
    }

    if(stringBuffer.substring(0,4) == "+ERR")
        lastErr = stringBuffer.substring(5,2).toInt();
    else
        lastErr = 0;
    return stringBuffer;
}
Beispiel #7
0
void writeTestsSummary()
{
	if (s_quiet)
	{
		tcout << std::endl << std::endl;
	}

	tstring str = Core::fmt(TXT("Test Results: %u Passed %u Failed %u Unknown"),
							s_numPassed, s_numFailed, s_numUnknown);

	if (!s_successful)
		str += TXT(" [RUN TERMINATED ABORMALLY]");

	debugWrite(TXT("%s\n"), str.c_str());
	std::tcout << str << std::endl;
}
Beispiel #8
0
void debugWritecrlf( char *p )
{
	debugWrite( p );
	uart0Puts( "\r\n" );
}
Beispiel #9
0
/******************************************************************************
 *
 * dtPoll
 *
 * PURPOSE
 *      This routine is called by the system's main polling loop to
 *      maintain the real time clock and second tick count.  This routine
 *      also detects start times for scheduled irrigation programs.
 *
 * PARAMETERS
 *      None.
 *
 * RETURN VALUE
 *      None.
 *
 * NOTES
 *      This routine should be called frequently to keep the system clock
 *      up-to-date and to insure that the intervals between tick count
 *      one-second increments are reasonably precise.  To maintain precision
 *      of +/- 5%, this routine needs to be called at least once every 100
 *      ms.
 *
 *****************************************************************************/
void dtPoll(void)
{
    uint8_t pgm;
    char debugBuf[2];

    /* Maintain real time clock. */
    dtPollRtc();

    /* Manage automatic irrigation start. */
    if (dtNewMinute())
    {
       
        /* Check configuration to see if an irrigation program should start. */
        if (sysIsAuto)
        {
            for (pgm = 0; pgm < SYS_N_PROGRAMS; pgm++)
            {
               /* confirm communication with master prior to schedule start
                * time if in pulse mode. if no communication then revert to runtime based system
                */
                if((config.sys.pulseMode ==CONFIG_PULSEMODE_ON) & (config.sys.unitType != UNIT_TYPE_MASTER))
                {
                    if((ntohs(config.sched[dtIrrWday()][pgm].startTime)-TIME_BEFORE_SCHED_TIME) == dtCurTime)
                    {
                        /* send No Op command to Master to test communication */
                        expansionBusSendCmd(RADIO_CMD_NO_OP, config.sys.masterMac);
    
                    } 

                    return;

                }
                
                if ((ntohs(config.sched[dtIrrWday()][pgm].startTime) == dtCurTime) & 
                    (irrStop == FALSE)& (radioCmdIrrStart==FALSE))             
                {                      
                    /* Make sure watchdog doesn't timeout on long debug message writes. */
                    sysExecutionExtend();
                    if ((irrAutoPgmPending == IRR_PGM_NONE) | (irrExpRunningProg == IRR_PGM_NONE))
                    {
                        /* Schedule program to auto-start. */
                        irrAutoPgmPending = pgm;
                        /* Trace auto start queued event. */
                        sysEvent(DT_EVENT_AUTO_START_Q, pgm);
                        dtDebug("PGM '");
                        sprintf(debugBuf, "%c", 'A' + pgm);
                        debugWrite(debugBuf);
                        debugWrite("' queued for auto-start.\n");
                        
                        if(config.sys.unitType == UNIT_TYPE_MASTER)
                        {
                          expansionBusSendCmd(RADIO_CMD_IRR_STOP_OFF,RADIO_EXP_SEND_ALL);
                        }
                    }
                    else
                    {
                        /* Already one program waiting in queue. */
                        /* Trace auto start - queue full event. */
                        sysEvent(DT_EVENT_AUTO_START_QF, pgm);
                        dtDebug("PGM '");
                        sprintf(debugBuf, "%c", 'A' + pgm);
                        debugWrite(debugBuf);
                        debugWrite("' auto-start Failed.  Queue is full.\n");
                    }
                }
                
                /*if a stop command was received before scheduled time cancel
                 * scheduled program and once passed scheduled time clear the stop flag 
                 */
                if (ntohs(config.sched[dtIrrWday()][pgm].startTime) < dtCurTime)
                {
                    irrStop = FALSE;
                    radioCmdIrrStart=FALSE;
                }
                  
            }
        }
    }
}
Beispiel #10
0
void wasm::writeU32(raw_ostream &OS, uint32_t Number, const Twine &Msg) {
  debugWrite(OS.tell(), Msg + "[0x" + utohexstr(Number) + "]");
  support::endian::write(OS, Number, support::little);
}
Beispiel #11
0
void wasm::writeU8(raw_ostream &OS, uint8_t Byte, const Twine &Msg) {
  debugWrite(OS.tell(), Msg + " [0x" + utohexstr(Byte) + "]");
  OS << Byte;
}
Beispiel #12
0
void wasm::writeStr(raw_ostream &OS, StringRef String, const Twine &Msg) {
  debugWrite(OS.tell(),
             Msg + " [str[" + Twine(String.size()) + "]: " + String + "]");
  encodeULEB128(String.size(), OS);
  OS.write(String.data(), String.size());
}
Beispiel #13
0
void wasm::writeBytes(raw_ostream &OS, const char *Bytes, size_t Count,
                      const Twine &Msg) {
  debugWrite(OS.tell(), Msg + " [data[" + Twine(Count) + "]]");
  OS.write(Bytes, Count);
}
Beispiel #14
0
void wasm::writeSleb128(raw_ostream &OS, int32_t Number, const Twine &Msg) {
  debugWrite(OS.tell(), Msg + "[" + utohexstr(Number) + "]");
  encodeSLEB128(Number, OS);
}
Beispiel #15
0
bool DigiFi::post(char *aHost, char *aPath, String postData){
    if(connect(aHost) == 1){



        Serial1.print("POST ");
        Serial1.print(aPath);
        Serial1.print(" HTTP/1.1\r\nHost: ");
        Serial1.print(aHost);
        Serial1.print("\r\nCache-Control: no-cache\r\nContent-Type: application/x-www-form-urlencoded\r\nConnection: close\r\n");
        Serial1.print("Content-Length: ");
        Serial1.print(postData.length());
        Serial1.print("\r\n\r\n");
        Serial1.print(postData);
        Serial1.print("\r\n\r\n");
        Serial1.flush();


        debug("wait for response...");
        bool success = true;
        int i=0;
        int st = millis();
        while(!Serial1.available()){
            if(millis() - st > requestTimeout * 1000) {
                success = false; 
                break;
            } 
            if(((millis() - st) % 1000) == 1)
                debugWrite('.');
            i++; 
        }
        
        if(success == false)
            return 0;

        debug("get header");
        aHeader = readResponse(0);
        debug(aHeader);


        String contentLength = aHeader.substring(aHeader.lastIndexOf("Content-Length: "));
        contentLength = contentLength.substring(16,contentLength.indexOf("\n"));
        debug(contentLength);

        debug("get body");
        aBody = readResponse(contentLength.toInt());

        return 1;
    }
    else
        return 0;

    //To do:
    /*
    User agent!
    accept post data as array or array or string, etc
    Better handle timeouts/other errors
    Actually look at returned header for status
    Efficiency!
    */

}