Пример #1
0
void redraw(int signal)
{
	pthread_mutex_lock(&display_lock);

	clear();
	
	displayLog();
	displayDownloads();

	if(state == DISCONNECTED)
		displayDisconnected();
	else if(state == REGISTER)
		displayServers();
	else if(state == SERVER)
		displayPeers();/*
	else if(state == PEER)
		displayPeerScreen();*/
	
	if(message)
		mvprintw(++p, 5, message);
	
	refresh();
	
	if(signal)
		pthread_cond_signal(&condition);
	
	pthread_mutex_unlock(&display_lock);
}
Пример #2
0
static void
exitCallback (void)
{
	if (showBox)
		displayLog (errorBox);

	log_exit (0);
}
Пример #3
0
int logADC()
{
   static int rc;

   costate{

      // -EBUSY means the serial flash is busy writing or erasing a sector.
      //  sbfWriteFlash will return this value many times before any write
      //  is completed because these operations take several milliseconds.
      //  We don't want to busy wait while this happens because an application
      //  will normally have lots of other work to do. So if  sbfWriteFlash
      //  returns -EBUSY, execution jumps to the end of the costate and we
      //  exit the function so that other tasks can run.
  	   waitfor(-EBUSY !=
      	        (rc = sbfWriteFlash(logAddr, ad_inputsRaw,
                                sizeof(int)*(1+ENDCHAN-STARTCHAN)))
        	    );

      if(rc == -1){
          printf("Illegal serial flash write attempt");
          exit(rc);
      }
      else if(!rc)   // 0 = success,
      {              //  rc > means SPI in use by another device, so we just
      					//  fall through and exit the function.

  		   sampleComplete = 0;

         // rc > 0 means SPI in use by another device
         //  if rc > 0, execution jumps to the end of the costate
         //  the function exits.
	  		waitfor((rc=displayLog(logAddr)) <= 0);

         // rc=0 (success) is the only other possibility at this point.

	      logAddr += sizeof(int)*(1+ENDCHAN-STARTCHAN);

      	// Reset to bottom of top half if needed.
         // Additonal handling of the wrap-around would be needed to track the
         // wrap-around if another task were to need the log data - but
         // wrap-around would take about 49 days, and this is just a sample!
		   if(logAddr > MAXFLASHADDR)
		  	{
  			   logAddr = MINFLASHADDR;
		   }
	      sampleComplete = 0;     // reset flag
     	}

	}   // End costate
   return rc;
}