Author: Paul_R
Date: 2008-09-16 17:10:59 +0200 (Tue, 16 Sep 2008)
New Revision: 1854
Modified:
firmware/tuxup/trunk/error.h
firmware/tuxup/trunk/main.c
firmware/tuxup/trunk/tux-api.h
Log:
* Now check the version of fuxusb, and display an error message if the version
is less than 0.5.2.
Modified: firmware/tuxup/trunk/error.h
===================================================================
--- firmware/tuxup/trunk/error.h 2008-09-16 15:02:46 UTC (rev 1853)
+++ firmware/tuxup/trunk/error.h 2008-09-16 15:10:59 UTC (rev 1854)
@@ -31,7 +31,8 @@
E_TUXUP_BOOTLOADINGFAILED = 6,
E_TUXUP_USBERROR = 7,
E_TUXUP_DFUPROGNOTFOUND = 8,
- E_TUXUP_PROGRAMMINGFAILED = 9
+ E_TUXUP_PROGRAMMINGFAILED = 9,
+ E_FUXUSB_VER_ERROR =10
} tuxup_error_t;
#endif /* _ERROR_ */
Modified: firmware/tuxup/trunk/main.c
===================================================================
--- firmware/tuxup/trunk/main.c 2008-09-16 15:02:46 UTC (rev 1853)
+++ firmware/tuxup/trunk/main.c 2008-09-16 15:10:59 UTC (rev 1854)
@@ -48,6 +48,12 @@
/* Messages. */
#ifndef WIN32
+static char const *msg_old_fuxusb =
+ "\nERROR: Your dongle firmware is too old to use this version of Tuxup"
+ "\n Please update your dongle firmware with a version of fuxusb.hex"
+ "\n 0.5.2 or higher.\n"
+ "\n Check http://wiki.tuxisalive.com for more details\n";
+
static char const *msg_old_firmware =
"\nERROR: Your dongle firmware is too old to support switching to
bootloader"
"\nmode automatically.\n"
@@ -118,6 +124,43 @@
exit(exit_code);
}
+static bool verify_version(void)
+{
+ unsigned char data_buffer[64];
+ uint8_t i;
+ uint8_t ver_minor, ver_update;
+ data_buffer[0] = DONGLE_CMD_HDR;
+ data_buffer[1] = INFO_FUXUSB;
+ if (HID)
+ {
+ tux_hid_write(64, data_buffer);
+ tux_hid_read(64, data_buffer);
+ }
+ else
+ {
+ usb_send_commands(dev_h, data_buffer, 64);
+ usb_get_commands(dev_h, data_buffer, 64);
+ }
+ for (i = 0; i < 64; i++)
+ {
+ /* Parse the frame header */
+ if (!((i) % 4))
+ {
+ if (data_buffer[i] == FUXUSB_VERSION_CMD)
+ {
+ ver_minor = data_buffer[i+2];
+ ver_update = data_buffer[i+3];
+ break;
+ }
+ }
+ }
+ if (ver_minor <= MIN_VER_MINOR)
+ if (ver_update < MIN_VER_UPDATE)
+ return false;
+
+ return true;
+}
+
static void fux_connect(void)
{
#ifndef WIN32
@@ -149,7 +192,6 @@
}
else
{
- printf("Dongle found, using LibUSB \n");
/* The dongle is a libusb device */
HID = 0;
}
@@ -160,9 +202,15 @@
}
else
{
- printf("HID Dongle found \n");
/* The dongle is a HID device */
HID = 1;
+
+ if (! verify_version())
+ {
+ fprintf(stderr, msg_old_fuxusb);
+ exit(E_FUXUSB_VER_ERROR);
+ }
+
}
if (verbose)
@@ -186,6 +234,12 @@
fprintf(stderr, "USB DEVICE INIT ERROR \n");
exit(E_TUXUP_USBERROR);
}
+ if (! verify_version())
+ {
+ fprintf(stderr, msg_old_fuxusb);
+ exit(E_FUXUSB_VER_ERROR);
+ }
+
}
#endif
if (verbose)
@@ -193,6 +247,7 @@
usb_connected = 1;
}
+
static void fux_disconnect(void)
{
if (!usb_connected)
Modified: firmware/tuxup/trunk/tux-api.h
===================================================================
--- firmware/tuxup/trunk/tux-api.h 2008-09-16 15:02:46 UTC (rev 1853)
+++ firmware/tuxup/trunk/tux-api.h 2008-09-16 15:10:59 UTC (rev 1854)
@@ -27,8 +27,13 @@
* This is the first byte of the USB packet
*/
#define LIBUSB_RF_HEADER 0
+#define DONGLE_CMD_HDR 1
#define HID_I2C_HEADER 3
+#define INFO_FUXUSB 6
+#define FUXUSB_VERSION_CMD 200
+#define MIN_VER_MINOR 5
+#define MIN_VER_UPDATE 2
enum mem_type_t
{ FLASH, EEPROM };
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn