[tuxdroid-svn] r672 - daemon/trunk/libs
Status: Beta
Brought to you by:
ks156
From: jaguarondi <c2m...@c2...> - 2007-11-09 15:39:54
|
Author: jaguarondi Date: 2007-11-09 15:39:27 +0100 (Fri, 09 Nov 2007) New Revision: 672 Modified: daemon/trunk/libs/USBDaemon_status_table.c daemon/trunk/libs/USBDaemon_usb.c Log: * Check that the CPU number returned by the INFO command is valid. Modified: daemon/trunk/libs/USBDaemon_status_table.c =================================================================== --- daemon/trunk/libs/USBDaemon_status_table.c 2007-11-09 14:33:01 UTC (rev 671) +++ daemon/trunk/libs/USBDaemon_status_table.c 2007-11-09 14:39:27 UTC (rev 672) @@ -41,7 +41,7 @@ unsigned char CMD_status = 0; unsigned char pong_received; unsigned char cmd_status_flag; -static unsigned char current_cpu; +static int current_cpu = INVALID_CPU_NUM; static unsigned char last_remote_key = 0xFF; static unsigned char last_toggle_key = 0xFF; unsigned char sound_flash_count = 0; @@ -66,13 +66,22 @@ { struct firmware_version_t *firmware; - /* Select the corresponding CPU entry in the status table. */ - firmware = &tux_status.firmware[current_cpu]; /* When returning 'information', the firmware starts by sending this - * version information which includes the cpu number (id). This number is + * version information which includes the CPU number. This number is * used to determine which CPU is sending the upcoming information data * like revision and author. So we should save that number. */ current_cpu = CPU_VER_CPU(data[1]); + /* Check if the value received is a valid CPU number. */ + if ((current_cpu < 0) || (current_cpu > 4)) + { + log_error("received an INVALID CPU number: %d", current_cpu); + /* Mark current_cpu as invalid to discard any new information data + * until a valid CPU number is received. */ + current_cpu = INVALID_CPU_NUM; + return; + } + /* Select the corresponding CPU entry in the status table. */ + firmware = &tux_status.firmware[current_cpu]; /* Save major, minor and update numbers. */ firmware->version_major = CPU_VER_MAJ(data[1]); firmware->version_minor = data[2]; @@ -83,12 +92,15 @@ firmware->version_update); } -/** +/** * Update tux_status with the given firmware revision data. */ static void update_firmware_revision(const unsigned char *data) { struct firmware_version_t *firmware; + /* Check that a valid CPU number has been received. */ + if (current_cpu == INVALID_CPU_NUM) + return; /* Select the corresponding CPU entry in the status table. */ firmware = &tux_status.firmware[current_cpu]; /* Save revision number. */ @@ -103,6 +115,9 @@ static void update_firmware_author(const unsigned char *data) { struct firmware_version_t *firmware; + /* Check that a valid CPU number has been received. */ + if (current_cpu == INVALID_CPU_NUM) + return; /* Select the corresponding CPU entry in the status table. */ firmware = &tux_status.firmware[current_cpu]; /* Save author. */ @@ -719,7 +734,19 @@ tcp_frame[2] = DATA_TP_RSP; tcp_frame[3] = SUBDATA_TP_STATUS; - DONGLE_status = new_status[0]; + /* RF connection change. */ + if (new_status[0] != DONGLE_status) + { + DONGLE_status = new_status[0]; + if (DONGLE_status == 1) + /* RF connected */ + { + } + else + /* RF disconnected */ + { + } + } /*RF status change */ if (RF_status != new_status[1]) Modified: daemon/trunk/libs/USBDaemon_usb.c =================================================================== --- daemon/trunk/libs/USBDaemon_usb.c 2007-11-09 14:33:01 UTC (rev 671) +++ daemon/trunk/libs/USBDaemon_usb.c 2007-11-09 14:39:27 UTC (rev 672) @@ -140,7 +140,7 @@ while (!tux_device); /* Old firmware should be discarded here */ - if (tux_device->descriptor.bcdDevice < 0x100) + if (tux_device->descriptor.bcdDevice < 0x030) { log_error("Your dongle firmware is too old.\n" "This version is not compatible with this daemon, please \ |