Skip to content

Commit d22a936

Browse files
committed
Fix battery value parsing
1 parent 8793f0a commit d22a936

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/av.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,26 @@ void *BatteryThreadProc(__attribute__((__unused__)) void *args) {
5656
}
5757

5858
memset(buf, 0, sizeof(buf));
59-
if (Recv(buf, sizeof(buf), socket) <= 0) {
59+
if (RecvAll(buf, sizeof(buf), socket) <= 0) {
6060
goto LOOP;
6161
}
6262

6363
for (i = 0; i < (sizeof(buf)-4); i++) {
6464
if (buf[i] == '\r' && buf[i+1] == '\n' && buf[i+2] == '\r' && buf[i+3] == '\n') {
65-
i += 4;
66-
break;
65+
i += 4;
66+
break;
6767
}
6868
}
6969

7070
j = 0;
7171
while (i < sizeof(buf) && j < (sizeof(battery_value)-2) && buf[i] >= '0' && buf[i] <= '9')
72-
battery_value[j++] = buf[i++];
72+
battery_value[j++] = buf[i++];
7373

7474
if (j == 0)
7575
battery_value[j++] = '-';
7676

7777
battery_value[j++] = '%';
78-
battery_value[sizeof(battery_value) - 1] = 0;
78+
battery_value[j++] = 0;
7979
dbgprint("battery_value: %s\n", battery_value);
8080
UpdateBatteryLabel(battery_value);
8181

0 commit comments

Comments
 (0)