d/p/0001-fix_spelling_and_typo.patch: Update and refresh
This commit is contained in:
parent
8aa07bb6f9
commit
facb367831
3
debian/changelog
vendored
3
debian/changelog
vendored
|
@ -1,8 +1,9 @@
|
||||||
nut (2.6.0-2) UNRELEASED; urgency=low
|
nut (2.6.0-2) UNRELEASED; urgency=low
|
||||||
|
|
||||||
* debian/nut-snmp.docs: Distribute snmp.txt doc file (Closes: #548295)
|
* debian/nut-snmp.docs: Distribute snmp.txt doc file (Closes: #548295)
|
||||||
|
* d/p/0001-fix_spelling_and_typo.patch: Update and refresh
|
||||||
|
|
||||||
-- Laurent Bigonville <bigon@debian.org> Wed, 02 Mar 2011 14:51:38 +0100
|
-- Laurent Bigonville <bigon@debian.org> Wed, 02 Mar 2011 15:23:18 +0100
|
||||||
|
|
||||||
nut (2.6.0-1) unstable; urgency=low
|
nut (2.6.0-1) unstable; urgency=low
|
||||||
|
|
||||||
|
|
567
debian/patches/0001-fix_spelling_and_typo.patch
vendored
567
debian/patches/0001-fix_spelling_and_typo.patch
vendored
|
@ -1,250 +1,317 @@
|
||||||
--- a/docs/man/dummy-ups.txt (revision 2722)
|
--- a/docs/man/bcmxcp.8
|
||||||
+++ b/docs/man/dummy-ups.txt (revision 2882)
|
+++ b/docs/man/bcmxcp.8
|
||||||
@@ -56,5 +56,5 @@
|
@@ -103,7 +103,7 @@
|
||||||
This file is generally named "something.dev". It contains a list of all
|
.RE
|
||||||
valid data and associated values, and has the same format as an linkman:upsc[8]
|
.SH "TODO LIST"
|
||||||
-dump (<varname>: <value>). So you can easilly create definition
|
.PP
|
||||||
+dump (<varname>: <value>). So you can easily create definition
|
-Report UPS statistics informations
|
||||||
files from an existing UPS using "upsc > file.dev".
|
+Report UPS statistics information
|
||||||
It can also be empty, in which case only a basic set of data is available:
|
.RS 4
|
||||||
--- a/docs/man/metasys.txt (revision 2722)
|
BCM/XCP supports reporting of UPS statistics data\&.
|
||||||
+++ b/docs/man/metasys.txt (revision 2882)
|
.RE
|
||||||
@@ -45,5 +45,5 @@
|
--- a/docs/man/dummy-ups.8
|
||||||
ally HF 1000 only.
|
+++ b/docs/man/dummy-ups.8
|
||||||
|
@@ -63,7 +63,7 @@
|
||||||
-Any informations about the use of the driver with the other listed
|
.RE
|
||||||
+Any information about the use of the driver with the other listed
|
.\}
|
||||||
UPS are really welcome.
|
.sp
|
||||||
|
-This file is generally named "something\&.dev"\&. It contains a list of all valid data and associated values, and has the same format as an \fBupsc\fR(8) dump (<varname>: <value>)\&. So you can easilly create definition files from an existing UPS using "upsc > file\&.dev"\&. It can also be empty, in which case only a basic set of data is available: device\&.\fB, driver\&.\fR, ups\&.mfr, ups\&.model, ups\&.status
|
||||||
--- a/drivers/apcsmart.c (revision 2596)
|
+This file is generally named "something\&.dev"\&. It contains a list of all valid data and associated values, and has the same format as an \fBupsc\fR(8) dump (<varname>: <value>)\&. So you can easily create definition files from an existing UPS using "upsc > file\&.dev"\&. It can also be empty, in which case only a basic set of data is available: device\&.\fB, driver\&.\fR, ups\&.mfr, ups\&.model, ups\&.status
|
||||||
+++ b/drivers/apcsmart.c (revision 2882)
|
.sp
|
||||||
@@ -325,5 +325,5 @@
|
Samples definition files are available in the "data" directory of the nut source tree, and generally in the sysconfig directory of your system distribution\&.
|
||||||
this if the REQ_CAPABILITIES command is supported
|
.sp
|
||||||
*/
|
--- a/docs/man/dummy-ups.txt
|
||||||
- upslogx(LOG_ERR, "ERROR: APC cannot do capabilites but said it could!");
|
+++ b/docs/man/dummy-ups.txt
|
||||||
+ upslogx(LOG_ERR, "ERROR: APC cannot do capabilities but said it could!");
|
@@ -55,7 +55,7 @@
|
||||||
return;
|
|
||||||
}
|
This file is generally named "something.dev". It contains a list of all
|
||||||
--- a/drivers/dummy-ups.c (revision 2699)
|
valid data and associated values, and has the same format as an linkman:upsc[8]
|
||||||
+++ b/drivers/dummy-ups.c (revision 2882)
|
-dump (<varname>: <value>). So you can easilly create definition
|
||||||
@@ -376,5 +376,5 @@
|
+dump (<varname>: <value>). So you can easily create definition
|
||||||
* the update / sync process (with cmdvartab?!) */
|
files from an existing UPS using "upsc > file.dev".
|
||||||
|
It can also be empty, in which case only a basic set of data is available:
|
||||||
- upsdebugx(1, "Unknown data. Commiting anyway...");
|
device.*, driver.*, ups.mfr, ups.model, ups.status
|
||||||
+ upsdebugx(1, "Unknown data. Committing anyway...");
|
--- a/docs/man/metasys.8
|
||||||
return 1;
|
+++ b/docs/man/metasys.8
|
||||||
/* return 0;*/
|
@@ -124,7 +124,7 @@
|
||||||
@@ -396,5 +396,5 @@
|
.sp
|
||||||
* the update / sync process (with cmdvartab?) */
|
This driver has been tested on Meta System HF Millennium 820 and ally HF 1000 only\&.
|
||||||
|
.sp
|
||||||
- upsdebugx(1, "Unknown data. Commiting value anyway...");
|
-Any informations about the use of the driver with the other listed UPS are really welcome\&.
|
||||||
+ upsdebugx(1, "Unknown data. Committing value anyway...");
|
+Any information about the use of the driver with the other listed UPS are really welcome\&.
|
||||||
return 1;
|
.SH "AUTHOR"
|
||||||
/* return 0;*/
|
.sp
|
||||||
--- a/drivers/snmp-ups.c (revision 2757)
|
Fabio Di Niro <blaxwan@users\&.sourceforge\&.net>
|
||||||
+++ b/drivers/snmp-ups.c (revision 2882)
|
--- a/docs/man/metasys.txt
|
||||||
@@ -485,5 +485,5 @@
|
+++ b/docs/man/metasys.txt
|
||||||
break;
|
@@ -44,7 +44,7 @@
|
||||||
default:
|
This driver has been tested on Meta System HF Millennium 820 and
|
||||||
- upslogx(LOG_ERR, "[%s] unhandled ASN 0x%x recieved from %s",
|
ally HF 1000 only.
|
||||||
+ upslogx(LOG_ERR, "[%s] unhandled ASN 0x%x received from %s",
|
|
||||||
upsname?upsname:device_name, pdu->variables->type, OID);
|
-Any informations about the use of the driver with the other listed
|
||||||
return FALSE;
|
+Any information about the use of the driver with the other listed
|
||||||
@@ -525,5 +525,5 @@
|
UPS are really welcome.
|
||||||
break;
|
|
||||||
default:
|
AUTHOR
|
||||||
- upslogx(LOG_ERR, "[%s] unhandled ASN 0x%x recieved from %s",
|
--- a/drivers/apcsmart.c
|
||||||
+ upslogx(LOG_ERR, "[%s] unhandled ASN 0x%x received from %s",
|
+++ b/drivers/apcsmart.c
|
||||||
upsname?upsname:device_name, pdu->variables->type, OID);
|
@@ -324,7 +324,7 @@
|
||||||
return FALSE;
|
/* This should never happen since we only call
|
||||||
@@ -1460,5 +1460,5 @@
|
this if the REQ_CAPABILITIES command is supported
|
||||||
upslogx(LOG_ERR, "su_setvar: cannot set value %s for %s", arg[4], arg[3]);
|
*/
|
||||||
else
|
- upslogx(LOG_ERR, "ERROR: APC cannot do capabilites but said it could!");
|
||||||
- upsdebugx(1, "su_setvar: sucessfully set %s to \"%s\"", arg[0], arg[4]);
|
+ upslogx(LOG_ERR, "ERROR: APC cannot do capabilities but said it could!");
|
||||||
+ upsdebugx(1, "su_setvar: successfully set %s to \"%s\"", arg[0], arg[4]);
|
return;
|
||||||
|
}
|
||||||
return 1;
|
|
||||||
--- a/drivers/genericups.c (revision 2336)
|
--- a/drivers/dummy-ups.c
|
||||||
+++ b/drivers/genericups.c (revision 2882)
|
+++ b/drivers/dummy-ups.c
|
||||||
@@ -143,10 +143,10 @@
|
@@ -375,7 +375,7 @@
|
||||||
if ((v = getval("OL")) != NULL) {
|
* enforcing controls! We also need a way to automate
|
||||||
parse_input_signals(v, &upstab[upstype].line_ol, &upstab[upstype].val_ol);
|
* the update / sync process (with cmdvartab?!) */
|
||||||
- upsdebugx(2, "parse_input_signals: OL overriden with %s\n", v);
|
|
||||||
+ upsdebugx(2, "parse_input_signals: OL overridden with %s\n", v);
|
- upsdebugx(1, "Unknown data. Commiting anyway...");
|
||||||
}
|
+ upsdebugx(1, "Unknown data. Committing anyway...");
|
||||||
|
return 1;
|
||||||
if ((v = getval("LB")) != NULL) {
|
/* return 0;*/
|
||||||
parse_input_signals(v, &upstab[upstype].line_bl, &upstab[upstype].val_bl);
|
}
|
||||||
- upsdebugx(2, "parse_input_signals: LB overriden with %s\n", v);
|
@@ -395,7 +395,7 @@
|
||||||
+ upsdebugx(2, "parse_input_signals: LB overridden with %s\n", v);
|
* enforcing controls! We also need a way to automate
|
||||||
}
|
* the update / sync process (with cmdvartab?) */
|
||||||
}
|
|
||||||
@@ -319,10 +319,10 @@
|
- upsdebugx(1, "Unknown data. Commiting value anyway...");
|
||||||
if ((v = getval("CP")) != NULL) {
|
+ upsdebugx(1, "Unknown data. Committing value anyway...");
|
||||||
parse_output_signals(v, &upstab[upstype].line_norm);
|
return 1;
|
||||||
- upsdebugx(2, "parse_output_signals: CP overriden with %s\n", v);
|
/* return 0;*/
|
||||||
+ upsdebugx(2, "parse_output_signals: CP overridden with %s\n", v);
|
}
|
||||||
}
|
--- a/drivers/genericups.c
|
||||||
|
+++ b/drivers/genericups.c
|
||||||
if ((v = getval("SD")) != NULL) {
|
@@ -142,12 +142,12 @@
|
||||||
parse_output_signals(v, &upstab[upstype].line_sd);
|
*/
|
||||||
- upsdebugx(2, "parse_output_signals: SD overriden with %s\n", v);
|
if ((v = getval("OL")) != NULL) {
|
||||||
+ upsdebugx(2, "parse_output_signals: SD overridden with %s\n", v);
|
parse_input_signals(v, &upstab[upstype].line_ol, &upstab[upstype].val_ol);
|
||||||
}
|
- upsdebugx(2, "parse_input_signals: OL overriden with %s\n", v);
|
||||||
|
+ upsdebugx(2, "parse_input_signals: OL overridden with %s\n", v);
|
||||||
--- a/drivers/metasys.c (revision 2601)
|
}
|
||||||
+++ b/drivers/metasys.c (revision 2882)
|
|
||||||
@@ -63,10 +63,10 @@
|
if ((v = getval("LB")) != NULL) {
|
||||||
/*
|
parse_input_signals(v, &upstab[upstype].line_bl, &upstab[upstype].val_bl);
|
||||||
Metasystem UPS data transfer are made with packet of the format:
|
- upsdebugx(2, "parse_input_signals: LB overriden with %s\n", v);
|
||||||
- STX DATA_LENGHT DATA CHECKSUM
|
+ upsdebugx(2, "parse_input_signals: LB overridden with %s\n", v);
|
||||||
+ STX DATA_LENGTH DATA CHECKSUM
|
}
|
||||||
where:
|
}
|
||||||
STX is 0x02 and is the start of transmission byte
|
|
||||||
- DATA_LENGHT is number of data bytes + the checksum byte
|
@@ -318,12 +318,12 @@
|
||||||
+ DATA_LENGTH is number of data bytes + the checksum byte
|
*/
|
||||||
DATA ......
|
if ((v = getval("CP")) != NULL) {
|
||||||
- CHECKSUM is the sum modulus 256 of all DATA bytes + DATA_LENGHT
|
parse_output_signals(v, &upstab[upstype].line_norm);
|
||||||
+ CHECKSUM is the sum modulus 256 of all DATA bytes + DATA_LENGTH
|
- upsdebugx(2, "parse_output_signals: CP overriden with %s\n", v);
|
||||||
|
+ upsdebugx(2, "parse_output_signals: CP overridden with %s\n", v);
|
||||||
The answer from the UPS have the same packet format and the first
|
}
|
||||||
@@ -115,5 +115,5 @@
|
|
||||||
|
if ((v = getval("SD")) != NULL) {
|
||||||
/* send a read command to the UPS, it retries 5 times before give up
|
parse_output_signals(v, &upstab[upstype].line_sd);
|
||||||
- it's a 4 byte request (STX, LENGHT, COMMAND and CHECKSUM) */
|
- upsdebugx(2, "parse_output_signals: SD overriden with %s\n", v);
|
||||||
+ it's a 4 byte request (STX, LENGTH, COMMAND and CHECKSUM) */
|
+ upsdebugx(2, "parse_output_signals: SD overridden with %s\n", v);
|
||||||
void send_read_command(char command) {
|
}
|
||||||
int retry, sent;
|
|
||||||
@@ -123,7 +123,7 @@
|
if (ioctl(upsfd, TIOCMSET, &upstab[upstype].line_norm)) {
|
||||||
while ((sent != 4) && (retry < 5)) {
|
--- a/drivers/metasys.c
|
||||||
buf[0]=0x02; /* STX Start of Transmission */
|
+++ b/drivers/metasys.c
|
||||||
- buf[1]=0x02; /* data lenght(data + checksum byte) */
|
@@ -62,12 +62,12 @@
|
||||||
+ buf[1]=0x02; /* data length(data + checksum byte) */
|
|
||||||
buf[2]=command; /* command to send */
|
/*
|
||||||
- buf[3]=buf[1] + buf[2]; /* checksum (sum modulus 256 of data bytes + lenght) */
|
Metasystem UPS data transfer are made with packet of the format:
|
||||||
+ buf[3]=buf[1] + buf[2]; /* checksum (sum modulus 256 of data bytes + length) */
|
- STX DATA_LENGHT DATA CHECKSUM
|
||||||
if (retry == 4) send_zeros(); /* last retry is preceded by a serial reset...*/
|
+ STX DATA_LENGTH DATA CHECKSUM
|
||||||
sent = ser_send_buf(upsfd, buf, 4);
|
where:
|
||||||
@@ -135,5 +135,5 @@
|
STX is 0x02 and is the start of transmission byte
|
||||||
with a char* buffer
|
- DATA_LENGHT is number of data bytes + the checksum byte
|
||||||
it retries 5 times before give up */
|
+ DATA_LENGTH is number of data bytes + the checksum byte
|
||||||
-void send_write_command(unsigned char *command, int command_lenght) {
|
DATA ......
|
||||||
+void send_write_command(unsigned char *command, int command_length) {
|
- CHECKSUM is the sum modulus 256 of all DATA bytes + DATA_LENGHT
|
||||||
int i, retry, sent, checksum;
|
+ CHECKSUM is the sum modulus 256 of all DATA bytes + DATA_LENGTH
|
||||||
unsigned char raw_buf[255];
|
|
||||||
@@ -141,21 +141,21 @@
|
The answer from the UPS have the same packet format and the first
|
||||||
/* prepares the raw data */
|
data byte is equal to the command that the ups is answering to
|
||||||
raw_buf[0] = 0x02; /* STX byte */
|
@@ -114,7 +114,7 @@
|
||||||
- raw_buf[1] = (unsigned char)(command_lenght + 1); /* data lenght + checksum */
|
}
|
||||||
- memcpy(raw_buf+2, command, command_lenght);
|
|
||||||
- command_lenght += 2;
|
/* send a read command to the UPS, it retries 5 times before give up
|
||||||
+ raw_buf[1] = (unsigned char)(command_length + 1); /* data length + checksum */
|
- it's a 4 byte request (STX, LENGHT, COMMAND and CHECKSUM) */
|
||||||
+ memcpy(raw_buf+2, command, command_length);
|
+ it's a 4 byte request (STX, LENGTH, COMMAND and CHECKSUM) */
|
||||||
+ command_length += 2;
|
void send_read_command(char command) {
|
||||||
|
int retry, sent;
|
||||||
/* calculate checksum */
|
unsigned char buf[4];
|
||||||
checksum = 0;
|
@@ -122,9 +122,9 @@
|
||||||
- for (i = 1; i < command_lenght; i++) checksum += raw_buf[i];
|
sent = 0;
|
||||||
+ for (i = 1; i < command_length; i++) checksum += raw_buf[i];
|
while ((sent != 4) && (retry < 5)) {
|
||||||
checksum = checksum % 256;
|
buf[0]=0x02; /* STX Start of Transmission */
|
||||||
- raw_buf[command_lenght] = (unsigned char)checksum;
|
- buf[1]=0x02; /* data lenght(data + checksum byte) */
|
||||||
- command_lenght +=1;
|
+ buf[1]=0x02; /* data length(data + checksum byte) */
|
||||||
+ raw_buf[command_length] = (unsigned char)checksum;
|
buf[2]=command; /* command to send */
|
||||||
+ command_length +=1;
|
- buf[3]=buf[1] + buf[2]; /* checksum (sum modulus 256 of data bytes + lenght) */
|
||||||
|
+ buf[3]=buf[1] + buf[2]; /* checksum (sum modulus 256 of data bytes + length) */
|
||||||
retry = 0;
|
if (retry == 4) send_zeros(); /* last retry is preceded by a serial reset...*/
|
||||||
sent = 0;
|
sent = ser_send_buf(upsfd, buf, 4);
|
||||||
- while ((sent != (command_lenght)) && (retry < 5)) {
|
retry += 1;
|
||||||
+ while ((sent != (command_length)) && (retry < 5)) {
|
@@ -134,29 +134,29 @@
|
||||||
if (retry == 4) send_zeros(); /* last retry is preceded by a serial reset... */
|
/* send a write command to the UPS, the write command and the value to be written are passed
|
||||||
- sent = ser_send_buf(upsfd, raw_buf, (command_lenght));
|
with a char* buffer
|
||||||
- if (sent != (command_lenght)) printf("Error sending command %d\n", raw_buf[2]);
|
it retries 5 times before give up */
|
||||||
+ sent = ser_send_buf(upsfd, raw_buf, (command_length));
|
-void send_write_command(unsigned char *command, int command_lenght) {
|
||||||
+ if (sent != (command_length)) printf("Error sending command %d\n", raw_buf[2]);
|
+void send_write_command(unsigned char *command, int command_length) {
|
||||||
retry += 1;
|
int i, retry, sent, checksum;
|
||||||
}
|
unsigned char raw_buf[255];
|
||||||
@@ -165,6 +165,6 @@
|
|
||||||
/* get the answer of a command from the ups */
|
/* prepares the raw data */
|
||||||
int get_answer(unsigned char *data) {
|
raw_buf[0] = 0x02; /* STX byte */
|
||||||
- unsigned char my_buf[255]; /* packet has a maximum lenght of 256 bytes */
|
- raw_buf[1] = (unsigned char)(command_lenght + 1); /* data lenght + checksum */
|
||||||
- int packet_lenght, checksum, i, res;
|
- memcpy(raw_buf+2, command, command_lenght);
|
||||||
+ unsigned char my_buf[255]; /* packet has a maximum length of 256 bytes */
|
- command_lenght += 2;
|
||||||
+ int packet_length, checksum, i, res;
|
+ raw_buf[1] = (unsigned char)(command_length + 1); /* data length + checksum */
|
||||||
/* Read STX byte */
|
+ memcpy(raw_buf+2, command, command_length);
|
||||||
res = ser_get_char(upsfd, my_buf, 1, 0);
|
+ command_length += 2;
|
||||||
@@ -177,41 +177,41 @@
|
|
||||||
return -1;
|
/* calculate checksum */
|
||||||
}
|
checksum = 0;
|
||||||
- /* Read data lenght byte */
|
- for (i = 1; i < command_lenght; i++) checksum += raw_buf[i];
|
||||||
+ /* Read data length byte */
|
+ for (i = 1; i < command_length; i++) checksum += raw_buf[i];
|
||||||
res = ser_get_char(upsfd, my_buf, 1, 0);
|
checksum = checksum % 256;
|
||||||
if (res < 1) {
|
- raw_buf[command_lenght] = (unsigned char)checksum;
|
||||||
- ser_comm_fail("Receive error (lenght): %d!!!\n", res);
|
- command_lenght +=1;
|
||||||
+ ser_comm_fail("Receive error (length): %d!!!\n", res);
|
+ raw_buf[command_length] = (unsigned char)checksum;
|
||||||
return -1;
|
+ command_length +=1;
|
||||||
}
|
|
||||||
- packet_lenght = my_buf[0];
|
retry = 0;
|
||||||
- if (packet_lenght < 2) {
|
sent = 0;
|
||||||
- ser_comm_fail("Receive error (lenght): packet lenght %d!!!\n", packet_lenght);
|
- while ((sent != (command_lenght)) && (retry < 5)) {
|
||||||
+ packet_length = my_buf[0];
|
+ while ((sent != (command_length)) && (retry < 5)) {
|
||||||
+ if (packet_length < 2) {
|
if (retry == 4) send_zeros(); /* last retry is preceded by a serial reset... */
|
||||||
+ ser_comm_fail("Receive error (length): packet length %d!!!\n", packet_length);
|
- sent = ser_send_buf(upsfd, raw_buf, (command_lenght));
|
||||||
return -1;
|
- if (sent != (command_lenght)) printf("Error sending command %d\n", raw_buf[2]);
|
||||||
}
|
+ sent = ser_send_buf(upsfd, raw_buf, (command_length));
|
||||||
- /* Try to read all the remainig bytes (packet_lenght) */
|
+ if (sent != (command_length)) printf("Error sending command %d\n", raw_buf[2]);
|
||||||
- res = ser_get_buf_len(upsfd, my_buf, packet_lenght, 1, 0);
|
retry += 1;
|
||||||
- if (res != packet_lenght) {
|
}
|
||||||
- ser_comm_fail("Receive error (data): got %d bytes instead of %d!!!\n", res, packet_lenght);
|
}
|
||||||
+ /* Try to read all the remainig bytes (packet_length) */
|
@@ -164,8 +164,8 @@
|
||||||
+ res = ser_get_buf_len(upsfd, my_buf, packet_length, 1, 0);
|
|
||||||
+ if (res != packet_length) {
|
/* get the answer of a command from the ups */
|
||||||
+ ser_comm_fail("Receive error (data): got %d bytes instead of %d!!!\n", res, packet_length);
|
int get_answer(unsigned char *data) {
|
||||||
return -1;
|
- unsigned char my_buf[255]; /* packet has a maximum lenght of 256 bytes */
|
||||||
}
|
- int packet_lenght, checksum, i, res;
|
||||||
|
+ unsigned char my_buf[255]; /* packet has a maximum length of 256 bytes */
|
||||||
/* now we have the whole answer from the ups, we can checksum it
|
+ int packet_length, checksum, i, res;
|
||||||
- checksum byte is equal to the sum modulus 256 of all the data bytes + packet_lenght
|
/* Read STX byte */
|
||||||
+ checksum byte is equal to the sum modulus 256 of all the data bytes + packet_length
|
res = ser_get_char(upsfd, my_buf, 1, 0);
|
||||||
(no STX no checksum byte itself) */
|
if (res < 1) {
|
||||||
- checksum = packet_lenght;
|
@@ -176,43 +176,43 @@
|
||||||
- for (i = 0; i < (packet_lenght - 1); i++) checksum += my_buf[i];
|
ser_comm_fail("Receive error (STX): packet not on start!!\n");
|
||||||
+ checksum = packet_length;
|
return -1;
|
||||||
+ for (i = 0; i < (packet_length - 1); i++) checksum += my_buf[i];
|
}
|
||||||
checksum = checksum % 256;
|
- /* Read data lenght byte */
|
||||||
- if (my_buf[packet_lenght-1] != checksum) {
|
+ /* Read data length byte */
|
||||||
- ser_comm_fail("checksum error! got %x instad of %x, received %d bytes \n", my_buf[packet_lenght - 1], checksum, packet_lenght);
|
res = ser_get_char(upsfd, my_buf, 1, 0);
|
||||||
- dump_buffer(my_buf, packet_lenght);
|
if (res < 1) {
|
||||||
+ if (my_buf[packet_length-1] != checksum) {
|
- ser_comm_fail("Receive error (lenght): %d!!!\n", res);
|
||||||
+ ser_comm_fail("checksum error! got %x instad of %x, received %d bytes \n", my_buf[packet_length - 1], checksum, packet_length);
|
+ ser_comm_fail("Receive error (length): %d!!!\n", res);
|
||||||
+ dump_buffer(my_buf, packet_length);
|
return -1;
|
||||||
return -1;
|
}
|
||||||
}
|
- packet_lenght = my_buf[0];
|
||||||
- packet_lenght-=1; /* get rid of the checksum byte */
|
- if (packet_lenght < 2) {
|
||||||
- memcpy(data, my_buf, packet_lenght);
|
- ser_comm_fail("Receive error (lenght): packet lenght %d!!!\n", packet_lenght);
|
||||||
- return packet_lenght;
|
+ packet_length = my_buf[0];
|
||||||
+ packet_length-=1; /* get rid of the checksum byte */
|
+ if (packet_length < 2) {
|
||||||
+ memcpy(data, my_buf, packet_length);
|
+ ser_comm_fail("Receive error (length): packet length %d!!!\n", packet_length);
|
||||||
+ return packet_length;
|
return -1;
|
||||||
}
|
}
|
||||||
|
- /* Try to read all the remainig bytes (packet_lenght) */
|
||||||
/* send a read command and try get the answer, if something fails, it retries (5 times max)
|
- res = ser_get_buf_len(upsfd, my_buf, packet_lenght, 1, 0);
|
||||||
if it is on the 4th or 5th retry, it will flush the serial before sending commands
|
- if (res != packet_lenght) {
|
||||||
- it returns the lenght of the received answer or -1 in case of failure */
|
- ser_comm_fail("Receive error (data): got %d bytes instead of %d!!!\n", res, packet_lenght);
|
||||||
+ it returns the length of the received answer or -1 in case of failure */
|
+ /* Try to read all the remainig bytes (packet_length) */
|
||||||
int command_read_sequence(unsigned char command, unsigned char *data) {
|
+ res = ser_get_buf_len(upsfd, my_buf, packet_length, 1, 0);
|
||||||
int bytes_read = 0;
|
+ if (res != packet_length) {
|
||||||
@@ -235,11 +235,11 @@
|
+ ser_comm_fail("Receive error (data): got %d bytes instead of %d!!!\n", res, packet_length);
|
||||||
/* send a write command and try get the answer, if something fails, it retries (5 times max)
|
return -1;
|
||||||
if it is on the 4th or 5th retry, it will flush the serial before sending commands
|
}
|
||||||
- it returns the lenght of the received answer or -1 in case of failure */
|
|
||||||
-int command_write_sequence(unsigned char *command, int command_lenght, unsigned char *answer) {
|
/* now we have the whole answer from the ups, we can checksum it
|
||||||
+ it returns the length of the received answer or -1 in case of failure */
|
- checksum byte is equal to the sum modulus 256 of all the data bytes + packet_lenght
|
||||||
+int command_write_sequence(unsigned char *command, int command_length, unsigned char *answer) {
|
+ checksum byte is equal to the sum modulus 256 of all the data bytes + packet_length
|
||||||
int bytes_read = 0;
|
(no STX no checksum byte itself) */
|
||||||
int retry = 0;
|
- checksum = packet_lenght;
|
||||||
|
- for (i = 0; i < (packet_lenght - 1); i++) checksum += my_buf[i];
|
||||||
while ((bytes_read < 1) && (retry < 5)) {
|
+ checksum = packet_length;
|
||||||
- send_write_command(command, command_lenght);
|
+ for (i = 0; i < (packet_length - 1); i++) checksum += my_buf[i];
|
||||||
+ send_write_command(command, command_length);
|
checksum = checksum % 256;
|
||||||
bytes_read = get_answer(answer);
|
- if (my_buf[packet_lenght-1] != checksum) {
|
||||||
if (retry > 2) ser_flush_in(upsfd, "", 0);
|
- ser_comm_fail("checksum error! got %x instad of %x, received %d bytes \n", my_buf[packet_lenght - 1], checksum, packet_lenght);
|
||||||
|
- dump_buffer(my_buf, packet_lenght);
|
||||||
|
+ if (my_buf[packet_length-1] != checksum) {
|
||||||
|
+ ser_comm_fail("checksum error! got %x instad of %x, received %d bytes \n", my_buf[packet_length - 1], checksum, packet_length);
|
||||||
|
+ dump_buffer(my_buf, packet_length);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
- packet_lenght-=1; /* get rid of the checksum byte */
|
||||||
|
- memcpy(data, my_buf, packet_lenght);
|
||||||
|
- return packet_lenght;
|
||||||
|
+ packet_length-=1; /* get rid of the checksum byte */
|
||||||
|
+ memcpy(data, my_buf, packet_length);
|
||||||
|
+ return packet_length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* send a read command and try get the answer, if something fails, it retries (5 times max)
|
||||||
|
if it is on the 4th or 5th retry, it will flush the serial before sending commands
|
||||||
|
- it returns the lenght of the received answer or -1 in case of failure */
|
||||||
|
+ it returns the length of the received answer or -1 in case of failure */
|
||||||
|
int command_read_sequence(unsigned char command, unsigned char *data) {
|
||||||
|
int bytes_read = 0;
|
||||||
|
int retry = 0;
|
||||||
|
@@ -234,13 +234,13 @@
|
||||||
|
|
||||||
|
/* send a write command and try get the answer, if something fails, it retries (5 times max)
|
||||||
|
if it is on the 4th or 5th retry, it will flush the serial before sending commands
|
||||||
|
- it returns the lenght of the received answer or -1 in case of failure */
|
||||||
|
-int command_write_sequence(unsigned char *command, int command_lenght, unsigned char *answer) {
|
||||||
|
+ it returns the length of the received answer or -1 in case of failure */
|
||||||
|
+int command_write_sequence(unsigned char *command, int command_length, unsigned char *answer) {
|
||||||
|
int bytes_read = 0;
|
||||||
|
int retry = 0;
|
||||||
|
|
||||||
|
while ((bytes_read < 1) && (retry < 5)) {
|
||||||
|
- send_write_command(command, command_lenght);
|
||||||
|
+ send_write_command(command, command_length);
|
||||||
|
bytes_read = get_answer(answer);
|
||||||
|
if (retry > 2) ser_flush_in(upsfd, "", 0);
|
||||||
|
retry += 1;
|
||||||
|
--- a/drivers/snmp-ups.c
|
||||||
|
+++ b/drivers/snmp-ups.c
|
||||||
|
@@ -484,7 +484,7 @@
|
||||||
|
len = snprintf(buf, buf_len, "%ld", *pdu->variables->val.integer / 100);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
- upslogx(LOG_ERR, "[%s] unhandled ASN 0x%x recieved from %s",
|
||||||
|
+ upslogx(LOG_ERR, "[%s] unhandled ASN 0x%x received from %s",
|
||||||
|
upsname?upsname:device_name, pdu->variables->type, OID);
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
@@ -524,7 +524,7 @@
|
||||||
|
value = *pdu->variables->val.integer / 100;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
- upslogx(LOG_ERR, "[%s] unhandled ASN 0x%x recieved from %s",
|
||||||
|
+ upslogx(LOG_ERR, "[%s] unhandled ASN 0x%x received from %s",
|
||||||
|
upsname?upsname:device_name, pdu->variables->type, OID);
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
@@ -1459,7 +1459,7 @@
|
||||||
|
if (ret == FALSE)
|
||||||
|
upslogx(LOG_ERR, "su_setvar: cannot set value %s for %s", arg[4], arg[3]);
|
||||||
|
else
|
||||||
|
- upsdebugx(1, "su_setvar: sucessfully set %s to \"%s\"", arg[0], arg[4]);
|
||||||
|
+ upsdebugx(1, "su_setvar: successfully set %s to \"%s\"", arg[0], arg[4]);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user