Esempio n. 1
0
void writeGPSString(char* str)
{
 	int len;
	int n;

	len = strlen(str);
	//printf("string length: %d",len);
	//printf("string %s\n",str);
    for(n=0;n<len;n++) {
		serCputc(str[n]);
	}
	serCputc('*');
	serCputc(13);
	serCputc(10);
}
void sendPacket (unsigned char cmd, unsigned char length, unsigned char *data) {
	unsigned char checksum, i;

   serCputc(0xFF); // start
	serCputc(cmd);
   serCputc(length);
   checksum = 0;
   //printf("[packet: %x %x %x ", 0xFF, cmd, length);
   for (i = 0; i < length; i += 1) {
   	serCputc(data[i]);
   	//printf("%x ", data[i]);
   	checksum ^= data[i];
   }
   //printf("%x]\n", checksum);
   serCputc(checksum);
}
Esempio n. 3
0
main()
{
	auto int nIn1, nIn2;
	auto char cOut;

   serCopen(_232BAUD);
	serDopen(_232BAUD);
	serCwrFlush();
	serCrdFlush();
	serDwrFlush();
	serDrdFlush();

	while (1)
	{
		for (cOut='a';cOut<='z';++cOut)
		{
			serCputc (cOut);								//	Send lowercase byte
			while ((nIn1=serDgetc()) == -1);			// Wait for echo
			serDputc (toupper(nIn1));					//	Send the converted upper case byte
			while ((nIn2=serCgetc()) == -1);			// Wait for echo
			printf ("Serial C sent %c, serial D sent %c, serial C received %c\n",
						cOut, toupper(nIn1), nIn2);
		}
	}
}
Esempio n. 4
0
void main()
{
	auto int nIn1, nIn2;
	auto char cOut;

	brdInit();				//initialize board for this demo

	serCopen(_232BAUD);
	serBopen(_232BAUD);
	serCwrFlush();
	serCrdFlush();
	serBwrFlush();
	serBrdFlush();
	serMode(0);			//enable serial device

	while (1)
	{
		for (cOut='a';cOut<='z';++cOut)
		{
			serCputc (cOut);								//	Send lowercase byte
			while ((nIn1=serBgetc()) == -1);			// Wait for echo
			serBputc (toupper(nIn1));					//	Send the converted upper case byte
			while ((nIn2=serCgetc()) == -1);			// Wait for echo
			printf ("Serial C sent %c, serial B sent %c, serial C received %c\n",
						cOut, toupper(nIn1), nIn2);
		}
	}
}
Esempio n. 5
0
void task2(void* pdata)
{
	while(1)
	{
		// Send byte out serial port C and count it as sent
		if(serCputc('Z'))
			bytessent++;
	}
}
Esempio n. 6
0
void main()
{
   int chr;

	chr = 0;
   serBopen(19200);
   serCopen(19200);
   while (chr != 27) {  // Exit on Esc
      if ((chr = serBgetc()) != -1 && chr != 27) {
         	serCputc(chr);
      }
   }
   serCputs("Done");
   while (serCwrFree() != COUTBUFSIZE) ; // allow tx to complete before closing
   serCclose();
   serBclose();
}
Esempio n. 7
0
void main()
{
	auto int nIn;
	auto char cOut;
	auto char inkey;

	brdInit();
	keypadDef();

	serCopen(_232BAUD);
	serMode(0);
	serCwrFlush();
	serCrdFlush();


	while (1) {
		costate {									//	Process Keypad Press/Hold/Release
			keyProcess();
			waitfor(DelayMs(10));
			}

		costate {
			if ((inkey = keyGet()) != 0) {	//	Wait for Keypress
				dispPrintf ("%c", inkey);		//	Display Byte
				serCputc(inkey);					// Transmit byte
				}
			waitfor(DelayMs(10));
			}

		costate {
			if ((nIn=serCgetc()) != -1)		// Wait for receive byte
				dispPrintf ("%c", nIn);			//	Display Byte
			waitfor(DelayMs(10));
			}
		}
}
Esempio n. 8
0
void main()
{

   int c,i,n,g, rvalue;
   auto int nIn;
   auto char cOut;

   brdInit();
   serCopen(9600);
  // serPORT(9600);
   //serCopen(BAUDGPS);
   serMode(0);
   serCrdFlush();// main loop
   serCwrFlush();
	serCrdFlush();
   serCputc('t');
   serCputc('e');
   printf("starting the loop");
   memset(sentence,0x00,sizeof(sentence));
   while(1)
	{
   	c = serCgetc();
      if( c == -1){
       	printf("nothing recieved\n");
      }
      else{
      printf("recieved: %c\n",serCgetc());
      }
      // this costate will check if the GPS has sent some data or not and
		// call the appropriate functions to process the data
		costate GPSRead always_on
		{
			// wait until gps mode is engaged and a gps string has been recieved
			waitfor(serCrdUsed() > 0);
			//printf("gps read:   ");

			// read until finding the beginning of a gps string then wait
			while(1)
			{
            //int test2;
            c = serCgetc();
            printf("%c\n",c);
            if (c == -1)
				{
					serCrdFlush();
					abort;
				}
				else
				{
            	i = 0;
               sentence[i++] = c;
            	waitfor(DelayMs(10));  //should only take 5ms or so at 115200 baud
					break;
				}
			}//end while(1)

			// now that 20 ms have passed, read in the gps string (it must all
			// be there by now, since so much time has passed

      //serCwrFlush();
      //serCrdFlush();
      //serCrdFlush();
      //i = 0;
      while((nIn=serCgetc()) != -1){
        sentence[i++] = nIn;

      }
      for(n = 0; n<i;n++){
       	serCputc(sentence[n]);
      }
      sentence[i] = '\0';

      printf("%s\n",sentence);
      memset(sentence,0x00,sizeof(sentence));
		}//end costate
	}// end while(1)
}//end main()