Imported Upstream version 2.6.1

This commit is contained in:
Arnaud Quette 2011-06-01 22:31:49 +02:00
parent 459aaf9392
commit a367d9bc54
178 changed files with 4651 additions and 3279 deletions

View file

@ -282,23 +282,12 @@ static unsigned char revertdays( unsigned char dweek )
static int IsHour( char *strx, int qual )
{
char shora[3], smin[3], sep[2];
int hora=0, min = 0, len = 0;
int hora=0, min = 0;
len = strlen( strx );
if ( len != 5 )
return -1;
sscanf( strx, "%2s%1s%2s", shora, sep, smin);
if( sep[0] != ':' )
return -1;
if( (!isdigit( shora[0] )) || (!isdigit( shora[1] )) )
return -1;
if( (!isdigit( smin[0] )) || (!isdigit( smin[1] )) )
if ((strlen(strx) != 5) || (sscanf(strx, "%d:%d", &hora, &min) != 2)) {
return -1;
}
hora = atoi( shora );
min = atoi( smin );
if( qual ) {
dhour = hora;
dmin = min;
@ -408,7 +397,7 @@ static int IsToday( unsigned char dweek, int nweek)
switch ( nweek )
{
case 0: // sunday
case 0: /* sunday */
return ( ( ( dweek & 0x40 ) == 0x40 ) );
case 1:
return ( ( ( dweek & 0x20 ) == 0x20 ) );
@ -420,7 +409,7 @@ static int IsToday( unsigned char dweek, int nweek)
return ( ( ( dweek & 0x04 ) == 0x04 ) );
case 5:
return ( ( ( dweek & 0x02 ) == 0x02 ) );
case 6: // saturday
case 6: /* saturday */
return ( ( ( dweek & 0x01 ) == 0x01 ) );
}
@ -802,7 +791,7 @@ static void getbaseinfo(void)
#else
char DaysOfWeek[7][4]={"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
#endif
char mycmd[8]; // , ch;
char mycmd[8];
char *str1, *str2, *str3, *str4, *strx;
unsigned char Pacote[25];
int i, i1=0, i2=0, j=0, tam, tpac=25;
@ -871,7 +860,7 @@ static void getbaseinfo(void)
}
}
} // end prgups 1 - 2
} /* end prgups 1 - 2 */
/* dummy read attempt to sync - throw it out */
snprintf(mycmd, sizeof(mycmd), "%c%c",CMD_UPSCONT, ENDCHAR);
@ -879,7 +868,7 @@ static void getbaseinfo(void)
/* trying detect solis model */
while ( ( !detected ) && ( j < 20 ) ) {
temp[0] = 0; // flush temp buffer
temp[0] = 0; /* flush temp buffer */
tam = ser_get_buf_len(upsfd, temp, tpac, 3, 0);
if( tam == 25 ) {
for( i = 0 ; i < tam ; i++ ) {
@ -1011,17 +1000,17 @@ static int instcmd(const char *cmdname, const char *extra)
{
if (!strcasecmp(cmdname, "shutdown.return")) {
// shutdown and restart
ser_send_char(upsfd, CMD_SHUTRET); // 0xDE
// ser_send_char(upsfd, ENDCHAR);
/* shutdown and restart */
ser_send_char(upsfd, CMD_SHUTRET); /* 0xDE */
/* ser_send_char(upsfd, ENDCHAR); */
return STAT_INSTCMD_HANDLED;
}
if (!strcasecmp(cmdname, "shutdown.stayoff"))
{
// shutdown now (one way)
ser_send_char(upsfd, CMD_SHUT); // 0xDD
// ser_send_char(upsfd, ENDCHAR);
/* shutdown now (one way) */
ser_send_char(upsfd, CMD_SHUT); /* 0xDD */
/* ser_send_char(upsfd, ENDCHAR); */
return STAT_INSTCMD_HANDLED;
}
@ -1082,7 +1071,7 @@ void upsdrv_shutdown(void)
/* on battery: send normal shutdown, ups will return by itself on utility */
/* on line: send shutdown+return, ups will cycle and return soon */
if (!SourceFail) { // on line
if (!SourceFail) { /* on line */
printf("On line, sending shutdown+return command...\n");
ser_send_char(upsfd, CMD_SHUTRET );