[tuxdroid-svn] r346 - daemon/trunk/libs
Status: Beta
Brought to you by:
ks156
From: neimad <c2m...@c2...> - 2007-06-04 18:32:46
|
Author: neimad Date: 2007-06-04 20:32:44 +0200 (Mon, 04 Jun 2007) New Revision: 346 Modified: daemon/trunk/libs/USBDaemon_usb_readWrite.c Log: * usb_get_status_TuxDroid() now processes data by chunks of 4 bytes instead of the incorrect 5 bytes. Also removed a pointless array copy (albeit small). Modified: daemon/trunk/libs/USBDaemon_usb_readWrite.c =================================================================== --- daemon/trunk/libs/USBDaemon_usb_readWrite.c 2007-06-04 17:21:07 UTC (rev 345) +++ daemon/trunk/libs/USBDaemon_usb_readWrite.c 2007-06-04 18:32:44 UTC (rev 346) @@ -67,15 +67,11 @@ void usb_get_status_TuxDroid(void) { const unsigned char cmd_send[5] = { 0x01, 0x01, 0x00, 0x00, 0x00 }; - unsigned char data[64]; - unsigned char cmd_dispatch[5]; - unsigned char num_frames; + unsigned char data[64] = { [0 ... 63] = 0 }; + unsigned char *d; int idx; - unsigned char i; + int num_frames, i; - for (i = 0; i < 64; i++) - data[i] = 0; - if (TUX_USB_CONNECTED != TUX_USB_STATUS) return; @@ -89,36 +85,26 @@ if (idx <= 0) return; - cmd_dispatch[0] = data[0]; - cmd_dispatch[1] = data[1]; - cmd_dispatch[2] = data[2]; - cmd_dispatch[3] = data[3]; + update_system_status_table(data); - update_system_status_table(cmd_dispatch); + num_frames = data[3]; - num_frames = cmd_dispatch[3]; - if (show_frames) log_debug("RF_st: %.2x CMD_st: %.2x NB_frames : %d idx : %d", RF_status, CMD_status, num_frames, idx); - if (num_frames > 0 && num_frames < 16) + /* XXX Should assert in this case, I guess ? */ + if (num_frames >= 16) + return; + + d = data + 4; + for (i = 0; i < num_frames; i++) { - for (i = 0; i < num_frames; i++) - { - cmd_dispatch[0] = data[(i + 1) * 4 + 0]; - cmd_dispatch[1] = data[(i + 1) * 4 + 1]; - cmd_dispatch[2] = data[(i + 1) * 4 + 2]; - cmd_dispatch[3] = data[(i + 1) * 4 + 3]; - cmd_dispatch[4] = 0; + if (show_raw_status) + log_debug("%.2x %.2x %.2x %.2x", d[0], d[1], d[2], d[3]); - if (show_raw_status) - log_debug("%.2x %.2x %.2x %.2x %.2x", cmd_dispatch[0], - cmd_dispatch[1], cmd_dispatch[2], cmd_dispatch[3], - cmd_dispatch[4]); - - update_raw_status_table(cmd_dispatch); - } + update_raw_status_table(d); + d += 4; } } |