~ubuntu-branches/ubuntu/gutsy/nut/gutsy

« back to all changes in this revision

Viewing changes to drivers/bcmxcp_ser.c

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Quette
  • Date: 2007-01-16 10:42:36 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070116104236-il549l8x1wmogl3b
Tags: 2.0.5-1
* New upstream release (Closes: #406045, #380304, #399741)
* debian/rules:
  - replaces CHANGES by ChangeLog
  - replace the dummycons installation by dummy-ups
  - integrate the --with-htmlpath option
* debian/nut-cgi.docs: created to install data/html/README
* debian/nut.init: LSB compliance update
* debian/control: add lsb-base (>= 3.0-6) to Depends for LSB compliance

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
                buf[3]=calc_checksum(buf);      /* checksum */
32
32
                
33
33
                if (retry == 4) ser_send_char(upsfd, 0x1d);     /* last retry is preceded by a ESC.*/
34
 
                        sent = ser_send_buf(upsfd, (char*)buf, 4);
 
34
                        sent = ser_send_buf(upsfd, buf, 4);
35
35
                retry += 1;
36
36
        }
37
37
}
57
57
        sent = 0;
58
58
 
59
59
        while ((sent != (command_length)) && (retry < PW_MAX_TRY)) {
60
 
                sent = ser_send_buf(upsfd, (char*)sbuf, (command_length));
 
60
                sent = ser_send_buf(upsfd, sbuf, (command_length));
61
61
                if (sent != (command_length)) printf("Error sending command %x\n", (unsigned char)sbuf[2]);
62
62
                        retry += 1;
63
63
        }
79
79
 
80
80
                do {
81
81
                        /* Read PW_COMMAND_START_BYTE byte */
82
 
                        res = ser_get_char(upsfd, (char*)my_buf, 1, 0);
 
82
                        res = ser_get_char(upsfd, my_buf, 1, 0);
83
83
                        if (res != 1) {
84
84
                                upsdebugx(1,"Receive error (PW_COMMAND_START_BYTE): %d!!!\n", res);
85
85
                                return -1;
94
94
                }
95
95
 
96
96
                /* Read block number byte */
97
 
                res = ser_get_char(upsfd, (char*)(my_buf+1), 1, 0);
 
97
                res = ser_get_char(upsfd, my_buf+1, 1, 0);
98
98
                if (res != 1) {
99
99
                        ser_comm_fail("Receive error (Block number): %d!!!\n", res);
100
100
                        return -1;
120
120
                }
121
121
 
122
122
                /* Read data length byte */
123
 
                res = ser_get_char(upsfd, (char*)(my_buf+2), 1, 0);
 
123
                res = ser_get_char(upsfd, my_buf+2, 1, 0);
124
124
                if (res != 1) {
125
125
                        ser_comm_fail("Receive error (length): %d!!!\n", res);
126
126
                        return -1;
133
133
                }
134
134
 
135
135
                /* Read sequence byte */
136
 
                res = ser_get_char(upsfd, (char*)(my_buf+3), 1, 0);
 
136
                res = ser_get_char(upsfd, my_buf+3, 1, 0);
137
137
                if (res != 1) {
138
138
                        ser_comm_fail("Receive error (sequence): %d!!!\n", res);
139
139
                        return -1;
152
152
                pre_sequence = sequence;
153
153
 
154
154
                /* Try to read all the remainig bytes */
155
 
                res = ser_get_buf_len(upsfd, (char*)(my_buf+4), length, 1, 0);
 
155
                res = ser_get_buf_len(upsfd, my_buf+4, length, 1, 0);
156
156
                if (res != length) {
157
157
                        ser_comm_fail("Receive error (data): got %d bytes instead of %d!!!\n", res, length);
158
158
                        return -1;
159
159
                }
160
160
 
161
161
                /* Get the checksum byte */
162
 
                res = ser_get_char(upsfd, (char*)(my_buf+(4+length)), 1, 0);
 
162
                res = ser_get_char(upsfd, my_buf+(4+length), 1, 0);
163
163
 
164
164
                if (res != 1) {
165
165
                        ser_comm_fail("Receive error (checksum): %x!!!\n", res);
238
238
 
239
239
void pw_comm_setup(const char *port)
240
240
{
241
 
    char answer[256];
 
241
    unsigned char answer[256];
242
242
    int i = 0, baud, mybaud = 0, ret = -1 ;
243
243
 
244
244
        if (getval("baud_rate") != NULL)