Ejemplo n.º 1
0
void erpDisplayPacket(ErpPacket* erpPacket, u08 pktLength)
{
	u08 i;
	u08 flag;

	// show ERP packet header
	erpDisplayHeader(erpPacket);

	// dump complete raw packet data
	if(pktLength)
	{
		// check if all characters are printable
		flag = TRUE;
		for(i=0; i<pktLength; i++)
		{
			if( ((u08*)erpPacket)[i] < 0x20 ) flag = FALSE;
		}

		// print packet data
		rprintf("Data:\r\n");
		if(flag)
		{
			// print as string
			rprintfStrLen(((u08*)erpPacket), 0, pktLength);
		}
		else
		{
			// print as hex
			debugPrintHexTable(pktLength, ((u08*)erpPacket));
		}
		rprintfCRLF();
	}
}
Ejemplo n.º 2
0
// functions
void erpDisplayHeader(ErpPacket* erpPacket)
{
	// show ERP packet header
	rprintf("ERP Header: Callsign=");
	rprintfStrLen(erpPacket->CallSign,0,CALLSIGN_FIELD_LEN);
	rprintf(", Trg=0x%x, Src=0x%x, Seq#=%d, Type=",
		erpPacket->ToAddress,
		erpPacket->FromAddress,
		erpPacket->SequenceNum);
	// try to decode packet type
	switch(erpPacket->Type)
	{
	case ERP_ECHO:			rprintf("ECHO"); break;
	case ERP_ECHOREPLY:		rprintf("ECHOREPLY"); break;
	case ERP_TEST:			rprintf("TEST"); break;
	case ERP_EDPCOMMAND:	rprintf("EDPCOMMAND"); break;
	case ERP_EDPREPLY:		rprintf("EDPREPLY"); break;
	case ERP_EDPREPLYNODEV:	rprintf("EDPREPLYNODEV"); break;
	default:				rprintf("0x%x", erpPacket->Type); break;
	}
	rprintfCRLF();
}
Ejemplo n.º 3
0
uint8_t nmeaProcess(cBuffer* rxBuffer)
{
	uint8_t foundpacket = NMEA_NODATA;
	uint8_t startFlag = FALSE;
	//uint8_t data;
	uint16_t i,j;

	// process the receive buffer
	// go through buffer looking for packets
	while(rxBuffer->datalength)
	{
		// look for a start of NMEA packet
		if(bufferGetAtIndex(rxBuffer,0) == '$')
		{
			// found start
			startFlag = TRUE;
			// when start is found, we leave it intact in the receive buffer
			// in case the full NMEA string is not completely received.  The
			// start will be detected in the next nmeaProcess iteration.

			// done looking for start
			break;
		}
		else
			bufferGetFromFront(rxBuffer);
	}
	
	// if we detected a start, look for end of packet
	if(startFlag)
	{
		for(i=1; i<(rxBuffer->datalength)-1; i++)
		{
			// check for end of NMEA packet <CR><LF>
			if((bufferGetAtIndex(rxBuffer,i) == '\r') && (bufferGetAtIndex(rxBuffer,i+1) == '\n'))
			{
				// have a packet end
				// dump initial '$'
				bufferGetFromFront(rxBuffer);
				// copy packet to NmeaPacket
				for(j=0; j<(i-1); j++)
				{
					// although NMEA strings should be 80 characters or less,
					// receive buffer errors can generate erroneous packets.
					// Protect against packet buffer overflow
					if(j<(NMEA_BUFFERSIZE-1))
						NmeaPacket[j] = bufferGetFromFront(rxBuffer);
					else
						bufferGetFromFront(rxBuffer);
				}
				// null terminate it
				NmeaPacket[j] = 0;
				// dump <CR><LF> from rxBuffer
				bufferGetFromFront(rxBuffer);
				bufferGetFromFront(rxBuffer);

				#ifdef NMEA_DEBUG_PKT
				rprintf("Rx NMEA packet type: ");
				rprintfStrLen(NmeaPacket, 0, 5);
				rprintfStrLen(NmeaPacket, 5, (i-1)-5);
				rprintfCRLF();
				#endif
				// found a packet
				// done with this processing session
				foundpacket = NMEA_UNKNOWN;
				break;
			}
		}
	}

	if(foundpacket)
	{
		// check message type and process appropriately
		if(!strncmp(NmeaPacket, "GPGGA", 5))
		{
			// process packet of this type
			nmeaProcessGPGGA(NmeaPacket);
			// report packet type
			foundpacket = NMEA_GPGGA;
		}
		else if(!strncmp(NmeaPacket, "GPVTG", 5))
		{
			// process packet of this type
			nmeaProcessGPVTG(NmeaPacket);
			// report packet type
			foundpacket = NMEA_GPVTG;
		}
	}
	else if(rxBuffer->datalength >= rxBuffer->size)
	{
		// if we found no packet, and the buffer is full
		// we're logjammed, flush entire buffer
		bufferFlush(rxBuffer);
	}
	return foundpacket;
}
Ejemplo n.º 4
0
void rprintfTest(void)
{
	u16 val;
	u08 mydata;
	u08 mystring[10];
	float b;
	u08 small;
	u16 medium;
	u32 big;

	// print a little intro message so we know things are working
	rprintf("\r\nThis is my cool program!\r\n");

	
	rprintf("\r\nWelcome to rprintf Test!\r\n");

	// print single characters
	rprintfChar('H');
	rprintfChar('e');
	rprintfChar('l');
	rprintfChar('l');
	rprintfChar('o');
	// print a constant string stored in FLASH
	rprintfProgStrM(" World!");
	// print a carriage return, line feed combination
	rprintfCRLF();
	// note that using rprintfCRLF() is more memory-efficient than
	// using rprintf("\r\n"), especially if you do it repeatedly

	mystring[0] = 'A';
	mystring[1] = ' ';
	mystring[2] = 'S';
	mystring[3] = 't';
	mystring[4] = 'r';
	mystring[5] = 'i';
	mystring[6] = 'n';
	mystring[7] = 'g';
	mystring[8] = '!';
	mystring[9] = 0;	// null termination

	// print a null-terminated string from RAM
	rprintfStr(mystring);
	rprintfCRLF();

	// print a section of a string from RAM
	// - start at index 2
	// - print 6 characters
	rprintfStrLen(mystring, 2, 6);
	rprintfCRLF();


	val = 24060;
	mydata = 'L';

	// print a decimal number
	rprintf("This is a decimal number: %d\r\n", val);

	// print a hex number
	rprintf("This is a hex number: %x\r\n", mydata);
	
	// print a character
	rprintf("This is a character: %c\r\n", mydata);

	// print hex numbers
	small = 0x12;		// a char
	medium = 0x1234;	// a short
	big = 0x12345678;	// a long

	rprintf("This is a 2-digit hex number (char) : ");
	rprintfu08(small);
	rprintfCRLF();

	rprintf("This is a 4-digit hex number (short): ");
	rprintfu16(medium);
	rprintfCRLF();

	rprintf("This is a 8-digit hex number (long) : ");
	rprintfu32(big);
	rprintfCRLF();

	// print a formatted decimal number
	// - use base 10
	// - use 8 characters
	// - the number is signed [TRUE]
	// - pad with '.' periods
	rprintf("This is a formatted decimal number: ");
	rprintfNum(10, 8, TRUE, '.', val);
	rprintfCRLF();

	b = 1.23456;

	// print a floating point number
	// use 10-digit precision
	
	// NOTE: TO USE rprintfFloat() YOU MUST ENABLE SUPPORT IN global.h
	// use the following in your global.h: #define RPRINTF_FLOAT

	//rprintf("This is a floating point number: ");
	//rprintfFloat(8, b);
	//rprintfCRLF();
}
Ejemplo n.º 5
0
Archivo: main.c Proyecto: sndae/b3r1
/*******************************************************************
*		rprintf_test
*******************************************************************/
void rprintf_test(void)
{
    u16 val;
    u08 mydata;
    u08 mystring[10];
    double b;
    u08 small;
    u16 medium;
    u32 big;

    // initialize the UART (serial port)
    uartInit();

    // set the baud rate of the UART for our debug/reporting output
    uartSetBaudRate(38400);

    // initialize rprintf system
    // - use uartSendByte as the output for all rprintf statements
    //   this will cause all rprintf library functions to direct their
    //   output to the uart
    // - rprintf can be made to output to any device which takes characters.
    //   You must write a function which takes an unsigned char as an argument
    //   and then pass this to rprintfInit like this: rprintfInit(YOUR_FUNCTION);
    rprintfInit(uartSendByte);

    // initialize vt100 library
    vt100Init();

    // clear the terminal screen
    vt100ClearScreen();

    while (!(getkey() == 1))		//do the folling block until enter is pressed
    {

        // print a little intro message so we know things are working
        rprintf("\r\nWelcome to rprintf Test!\r\n");

        // print single characters
        rprintfChar('H');
        rprintfChar('e');
        rprintfChar('l');
        rprintfChar('l');
        rprintfChar('o');
        // print a constant string stored in FLASH
        rprintfProgStrM(" World!");
        // print a carriage return, line feed combination
        rprintfCRLF();
        // note that using rprintfCRLF() is more memory-efficient than
        // using rprintf("\r\n"), especially if you do it repeatedly

        mystring[0] = 'A';
        mystring[1] = ' ';
        mystring[2] = 'S';
        mystring[3] = 't';
        mystring[4] = 'r';
        mystring[5] = 'i';
        mystring[6] = 'n';
        mystring[7] = 'g';
        mystring[8] = '!';
        mystring[9] = 0;	// null termination

        // print a null-terminated string from RAM
        rprintfStr(mystring);
        rprintfCRLF();

        // print a section of a string from RAM
        // - start at index 2
        // - print 6 characters
        rprintfStrLen(mystring, 2, 6);
        rprintfCRLF();


        val = 24060;
        mydata = 'L';

        // print a decimal number
        rprintf("This is a decimal number: %d\r\n", val);

        // print a hex number
        rprintf("This is a hex number: %x\r\n", mydata);

        // print a character
        rprintf("This is a character: %c\r\n", mydata);

        // print hex numbers
        small = 0x12;		// a char
        medium = 0x1234;	// a short
        big = 0x12345678;	// a long

        rprintf("This is a 2-digit hex number (char) : ");
        rprintfu08(small);
        rprintfCRLF();

        rprintf("This is a 4-digit hex number (short): ");
        rprintfu16(medium);
        rprintfCRLF();

        rprintf("This is a 8-digit hex number (long) : ");
        rprintfu32(big);
        rprintfCRLF();

        // print a formatted decimal number
        // - use base 10
        // - use 8 characters
        // - the number is signed [TRUE]
        // - pad with '.' periods
        rprintf("This is a formatted decimal number: ");
        rprintfNum(10, 8, TRUE, '.', val);
        rprintfCRLF();

        b = 1.23456;

        // print a floating point number
        // use 10-digit precision

        // NOTE: TO USE rprintfFloat() YOU MUST ENABLE SUPPORT IN global.h
        // use the following in your global.h: #define RPRINTF_FLOAT

        rprintf("This is a floating point number: ");
        rprintfFloat(8, b);
        rprintfCRLF();
    }
}