Ejemplo n.º 1
0
Archivo: rhino.c Proyecto: AlexLov/nut
static void getupdateinfo(void)
{
	unsigned char  temp[256];
	int tam;

	temp[0] = 0; /* flush temp buffer */
	tam = ser_get_buf_len(upsfd, temp, pacsize, 3, 0);

	CommReceive(temp, tam);

}
Ejemplo n.º 2
0
void CommProcRRQ(PComVar cv)
{
	if ( ! cv->Ready ) {
		return;
	}
	/* disable receive request */
	switch (cv->PortType) {
		case IdTCPIP:
			if (! TCPIPClosed) {
				PWSAAsyncSelect(cv->s,cv->HWin,WM_USER_COMMNOTIFY, FD_OOB | FD_CLOSE);
			}
			break;
		case IdSerial:
			break;
	}
	cv->RRQ = TRUE;
	CommReceive(cv);
}
Ejemplo n.º 3
0
Archivo: rhino.c Proyecto: AlexLov/nut
static void getbaseinfo(void)
{
	unsigned char  temp[256];
	unsigned char Pacote[37];
	int  tam, i, j=0;
	time_t tmt;
	struct tm *now;
	const char *Model;

	time( &tmt );
	now = localtime( &tmt );
	dian = now->tm_mday;
	mesn = now->tm_mon+1;
	anon = now->tm_year+1900;
        weekn = now->tm_wday;

	/* trying detect rhino model */
	while ( ( !detected ) && ( j < 10 ) )
	  {

	    temp[0] = 0; /* flush temp buffer */
	    tam = ser_get_buf_len(upsfd, temp, pacsize, 3, 0);
	    if( tam == 37 )
	      {
		for( i = 0 ; i < tam ; i++ )
		  {
		    Pacote[i] = temp[i];
		  }
	      }

	    j++;
	    if( tam == 37)
	      CommReceive(Pacote, tam);
	     else
	      CommReceive(temp, tam);
	  }

	if( (!detected) )
	  {
	    fatalx(EXIT_FAILURE,  NO_RHINO );
	  }

	switch( RhinoModel )
	  {
	  case 0xC0:
	    {
	      Model =  "Rhino 20.0 kVA";
	      PotenciaNominal = 20000;
	      break;
	    }
	  case 0xC1:
	    {
	      Model = "Rhino 10.0 kVA";
	      PotenciaNominal = 10000;
	      break;
	    }
	  case 0xC2:
	    {
	      Model = "Rhino 6.0 kVA";
	      PotenciaNominal = 6000;
	      break;
	    }
	  case 0xC3:
	    {
	      Model = "Rhino 7.5 kVA";
	      PotenciaNominal = 7500;
	      break;
	    }
	  default:
	    {
	      Model = "Rhino unknown model";
	      PotenciaNominal = 0;
	      break;
	    }
	  }

	/* manufacturer and model */
	dstate_setinfo("ups.mfr", "%s", "Microsol");
	dstate_setinfo("ups.model", "%s", Model);
	/*
	dstate_setinfo("input.transfer.low", "%03.1f", InDownLim); LimInfBattInv ?
	dstate_setinfo("input.transfer.high", "%03.1f", InUpLim); LimSupBattInv ?
	*/

	dstate_addcmd("shutdown.stayoff");	/* CMD_SHUT */
	/* there is no reserved words for CMD_INON and CMD_INOFF yet */
	/* dstate_addcmd("input.on"); */	/* CMD_INON    = 1 */
	/* dstate_addcmd("input.off"); */	/* CMD_INOFF   = 2 */
	dstate_addcmd("load.on");	/* CMD_OUTON   = 3 */
	dstate_addcmd("load.off");	/* CMD_OUTOFF  = 4 */
	dstate_addcmd("bypass.start");	/* CMD_PASSON  = 5 */
	dstate_addcmd("bypass.stop");	/* CMD_PASSOFF = 6 */

	printf("Detected %s on %s\n", dstate_getinfo("ups.model"), device_path);

}