Esempio n. 1
0
result_t rf230radio_Send_send(Radio_MsgPtr pMsg)
{
    unsigned char result;
	  

  	// format the 802.15.4 packet
	#ifdef VER_DEBUG
	temp = pMsg; 
	#endif
	
    pMsg->fcflo=0x08;
    pMsg->fcfhi=0x01;
    pMsg->dsn = rf230radiom_currentDSN ++; //seq ++
    pMsg->destpan=BCAST_ADDRESS;

    //pMsg->addr==BCAST_ADDRESS;

    pMsg->addr = toLSB16 (pMsg->addr);
   // pMsg->port=0x3377;  //specify the port number to 0x0077
    
    if ( pMsg->dsn==255) pMsg->dsn=0;
      pMsg->time=0;
    
     
    pMsg->length=pMsg->length+MSG_HEADER_SIZE; //Set the length like in cc2420radiom.c, check if bug happens
    
    
     
    
     
   // just send out payload data first, add 15.4 header later
   
   /*Ensure that it is possible to enter PLL_ON*/
      // tat_reset_trx();
      
      //tat_reset_state_machine();
   if (tat_set_trx_state( PLL_ON ) == TAT_SUCCESS) {
       
   result= tat_send_data((pMsg->length+2), ((uint8_t*) pMsg)+1); //Note: Include MSG_FOOTER_SIZE
   
     if (result == TAT_SUCCESS)
   	  {  result=SUCCESS;
       if( tat_get_trx_state( )!=PLL_ON) {
       	 
         if(tat_set_trx_state( PLL_ON )!=TAT_SUCCESS) 
         	{
         		result= FAIL;
         		return result;
         	} 	     
      }
       else {
       	}
      
        //delay_us(1000);
        
       // for (i=0;i++;i<100000)
       // {
       // asm volatile("nop"::); 
       // }
	
        
       // Option-Go to RX_ON after Send-Important!
   	  	if (tat_set_trx_state( RX_ON )==TAT_SUCCESS)
			  printfstr ("\n after send go to RX_ON sucessfully "); 
   	  	else {
   	  		result=FAIL;
   	  	}
   	  }
     else {
		 
		if (tat_set_trx_state( RX_ON )==TAT_SUCCESS)
		  printfstr ("\n after send go to RX_ON sucessfully "); 
   	  	else {
   	  		result=FAIL;
   	  	}
     	result=FAIL;   
    }
   	}
   else {
   	result=FAIL; 
  }
	
	return result; 
}
Esempio n. 2
0
int main(void)
{
  int i = 0;
  float vx;
  float vy;
  DoubleInt dTemp;
  int count = 0;
  char temp[100];
  char tempStr[24];
  ssize_t ret = 0;
  Coords* c = NULL;
  ret = allocate(PAGE_SIZE, 0, (void**)(&c));
  if (ret != 0)
  {
    return (-1);
  }

  do
  {
    printfstr(STDOUT, "Initial Velocity X: ");
    ret = readLine(STDIN, temp, 100);
    if (ret < 0)
    {
      return (-1);
    }

    dTemp.d = strToDouble(temp);
  } while (dTemp.u == NAN.u);

  vx = (float)dTemp.d;

  do
  {
    printfstr(STDOUT, "Initial Velocity Y: ");
    ret = readLine(STDIN, temp, 100);
    if (ret < 0)
    {
      return (-1);
    }
   
    dTemp.d = strToDouble(temp);
  } while (dTemp.u == NAN.u);

  vy = (float)dTemp.d;

  printfstr(STDOUT, "Initial Count: ");
  ret = readLine(STDIN, temp, 100);
  if (ret < 0)
  {
    return (-1);
  }
  count = strToUint32(temp);

  do
  {
    fillPage(vx, vy, c, &count, 10);
    ret = readLine(STDIN, temp, 100);
    if (ret < 0)
    {
      return (-1);
    }
    if (temp[0] == 'p')
    {
      for (i = 0; i < 510; i++)
      {
        tempStr[0] = 'x';
        tempStr[1] = '=';
        tempStr[2] = '\0';
        snprintfloat(tempStr+2, 24, c[i].x);
        printfstr(STDOUT, tempStr);
        printfstr(STDOUT, ", ");
        tempStr[0] = 'y';
        tempStr[1] = '=';
        tempStr[2] = '\0';
        snprintfloat(tempStr+2, 24, c[i].y);
        printfstr(STDOUT, tempStr);
        printfstr(STDOUT, "\n");
      }
    }
  } while ( (temp[0] == 'c') || (temp[0] == 'p') );
}