Author: remi
Date: 2008-11-30 14:46:43 +0100 (Sun, 30 Nov 2008)
New Revision: 2934

Modified:
   software_suite_v2/tuxware/fuxusbflasher/trunk/flasher/DFUProgrammer.pas
   
software_suite_v2/tuxware/fuxusbflasher/trunk/flasher/DongleBootloadSwitcher.pas
   software_suite_v2/tuxware/fuxusbflasher/trunk/flasher/DongleHIDCheck.pas
   software_suite_v2/tuxware/fuxusbflasher/trunk/flasher/Tuxup.pas
   software_suite_v2/tuxware/fuxusbflasher/trunk/flasher/UninstallHIDDongle.pas
Log:
* updated wrappers

Modified: 
software_suite_v2/tuxware/fuxusbflasher/trunk/flasher/DFUProgrammer.pas
===================================================================
--- software_suite_v2/tuxware/fuxusbflasher/trunk/flasher/DFUProgrammer.pas     
2008-11-30 11:32:54 UTC (rev 2933)
+++ software_suite_v2/tuxware/fuxusbflasher/trunk/flasher/DFUProgrammer.pas     
2008-11-30 13:46:43 UTC (rev 2934)
@@ -4,9 +4,10 @@
 
 uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
-  Dialogs, StdCtrls, ShellApi;
+  Dialogs, StdCtrls, ShellApi, Registry;
 
 const
+  TUXDROID_REGISTRY_PATH = 'SOFTWARE\Tuxdroid\TuxdroidSetup';
   // Error codes enumeration.
   E_TUXUP_NOERROR                 = 0;
   E_TUXUP_CMDNOTFOUND             = 1;
@@ -31,6 +32,9 @@
 
 implementation
 
+var
+  tuxdroidPath : string;
+
 function ShellExecute_AndWait(Operation, FileName, Parameter, Directory: 
string;
   Show: Word; bWait: Boolean): Longint;
 var
@@ -61,6 +65,28 @@
   if not bOK then Result := -1;
 end;
 
+{**
+ * Get the Tuxdroid installation path.
+ *}
+function getTuxdroidPath : string;
+begin
+  result := '';
+  with TRegistry.Create do
+    try
+      RootKey := HKEY_LOCAL_MACHINE;
+
+      // From Tuxdroid setup
+      if OpenKey(TUXDROID_REGISTRY_PATH, False) then
+      begin
+        // Get tuxdroid installation path
+        result := ReadString('Install_Dir');
+        CloseKey;
+      end;
+    finally
+      Free;
+    end;
+end;
+
 constructor TDFUProgrammer.create(AOwner : TComponent);
 begin
   isWorking := false;
@@ -68,16 +94,14 @@
 
 function TDFUProgrammer.check : boolean;
 var
-  filePath, cmd : string;
+  cmd : string;
   ret : integer;
 begin
-  filePath := extractfilepath(application.ExeName);
-
   cmd := 'at89c5130 get bootloader-version';
 
   isWorking := true;
   ret := ShellExecute_AndWait( 'open',
-                          PChar(filePath + 'dfu-programmer.exe'),
+                          PChar(tuxdroidPath + '\bin\dfu-programmer.exe'),
                           PChar(cmd),
                           PChar(''),
                           SW_HIDE,
@@ -95,16 +119,15 @@
 
 function TDFUProgrammer.flash(fuxusbHex : string) : integer;
 var
-  filePath, cmd : string;
+  cmd : string;
   ret : integer;
+  Buffer: Array[0..MAX_PATH] of char;
 begin
-  filePath := extractfilepath(application.ExeName);
-
   // Check that the dongle found and it is in bootloader mode.
   cmd := 'at89c5130 get bootloader-version';
   isWorking := true;
   ret := ShellExecute_AndWait( 'open',
-                          PChar(filePath + 'dfu-programmer.exe'),
+                          PChar(tuxdroidPath + '\bin\dfu-programmer.exe'),
                           PChar(cmd),
                           PChar(''),
                           SW_HIDE,
@@ -134,7 +157,7 @@
   cmd := 'at89c5130 erase';
   isWorking := true;
   ret := ShellExecute_AndWait( 'open',
-                          PChar(filePath + 'dfu-programmer.exe'),
+                          PChar(tuxdroidPath + '\bin\dfu-programmer.exe'),
                           PChar(cmd),
                           PChar(''),
                           SW_HIDE,
@@ -146,11 +169,13 @@
     exit;
   end;
 
+  GetShortPathName(PChar(fuxusbHex), @Buffer, SizeOf(Buffer));
+
   // Transfer the firmware in the usb cpu memory flash
-  cmd := format('at89c5130 flash "%s"', [fuxusbHex]);
+  cmd := format('at89c5130 flash "%s"', [Buffer]);
   isWorking := true;
   ret := ShellExecute_AndWait( 'open',
-                          PChar(filePath + 'dfu-programmer.exe'),
+                          PChar(tuxdroidPath + '\bin\dfu-programmer.exe'),
                           PChar(cmd),
                           PChar(''),
                           SW_HIDE,
@@ -166,7 +191,7 @@
   cmd := 'at89c5130 configure HSB 0x7b';
   isWorking := true;
   ret := ShellExecute_AndWait( 'open',
-                          PChar(filePath + 'dfu-programmer.exe'),
+                          PChar(tuxdroidPath + '\bin\dfu-programmer.exe'),
                           PChar(cmd),
                           PChar(''),
                           SW_HIDE,
@@ -182,7 +207,7 @@
   cmd := 'at89c5130 start';
   isWorking := true;
   ret := ShellExecute_AndWait( 'open',
-                          PChar(filePath + 'dfu-programmer.exe'),
+                          PChar(tuxdroidPath + '\bin\dfu-programmer.exe'),
                           PChar(cmd),
                           PChar(''),
                           SW_HIDE,
@@ -197,4 +222,6 @@
   result := E_TUXUP_NOERROR;
 end;
 
+initialization
+  tuxdroidPath := getTuxdroidPath;
 end.

Modified: 
software_suite_v2/tuxware/fuxusbflasher/trunk/flasher/DongleBootloadSwitcher.pas
===================================================================
--- 
software_suite_v2/tuxware/fuxusbflasher/trunk/flasher/DongleBootloadSwitcher.pas
    2008-11-30 11:32:54 UTC (rev 2933)
+++ 
software_suite_v2/tuxware/fuxusbflasher/trunk/flasher/DongleBootloadSwitcher.pas
    2008-11-30 13:46:43 UTC (rev 2934)
@@ -4,8 +4,11 @@
 
 uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
-  Dialogs, StdCtrls, ShellApi;
+  Dialogs, StdCtrls, ShellApi, Registry;
 
+const
+  TUXDROID_REGISTRY_PATH = 'SOFTWARE\Tuxdroid\TuxdroidSetup';
+
 type
   TDongleBootloadSwitcher = class(TObject)
   public
@@ -16,6 +19,9 @@
 
 implementation
 
+var
+  tuxdroidPath : string;
+
 function ShellExecute_AndWait(Operation, FileName, Parameter, Directory: 
string;
   Show: Word; bWait: Boolean): Longint;
 var
@@ -46,6 +52,28 @@
   if not bOK then Result := -1;
 end;
 
+{**
+ * Get the Tuxdroid installation path.
+ *}
+function getTuxdroidPath : string;
+begin
+  result := '';
+  with TRegistry.Create do
+    try
+      RootKey := HKEY_LOCAL_MACHINE;
+
+      // From Tuxdroid setup
+      if OpenKey(TUXDROID_REGISTRY_PATH, False) then
+      begin
+        // Get tuxdroid installation path
+        result := ReadString('Install_Dir');
+        CloseKey;
+      end;
+    finally
+      Free;
+    end;
+end;
+
 constructor TDongleBootloadSwitcher.create(AOwner : TComponent);
 begin
   isWorking := false;
@@ -53,16 +81,14 @@
 
 function TDongleBootloadSwitcher.switch : boolean;
 var
-  filePath, cmd : string;
+  cmd : string;
   ret : integer;
 begin
-  filePath := extractfilepath(application.ExeName);
-
   cmd := '';
 
   isWorking := true;
   ret := ShellExecute_AndWait( 'open',
-                          PChar(filePath + 'dongle_bootload_switcher.exe'),
+                          PChar(tuxdroidPath + 
'\bin\dongle_bootload_switcher.exe'),
                           PChar(cmd),
                           PChar(''),
                           SW_HIDE,
@@ -78,4 +104,7 @@
   result := true;
 end;
 
+initialization
+  tuxdroidPath := getTuxdroidPath;
+
 end.

Modified: 
software_suite_v2/tuxware/fuxusbflasher/trunk/flasher/DongleHIDCheck.pas
===================================================================
--- software_suite_v2/tuxware/fuxusbflasher/trunk/flasher/DongleHIDCheck.pas    
2008-11-30 11:32:54 UTC (rev 2933)
+++ software_suite_v2/tuxware/fuxusbflasher/trunk/flasher/DongleHIDCheck.pas    
2008-11-30 13:46:43 UTC (rev 2934)
@@ -4,8 +4,11 @@
 
 uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
-  Dialogs, StdCtrls, ShellApi;
+  Dialogs, StdCtrls, ShellApi, Registry;
 
+const
+  TUXDROID_REGISTRY_PATH = 'SOFTWARE\Tuxdroid\TuxdroidSetup';
+
 type
   TDongleHIDCheck = class(TObject)
   public
@@ -16,6 +19,9 @@
 
 implementation
 
+var
+  tuxdroidPath : string;
+
 function ShellExecute_AndWait(Operation, FileName, Parameter, Directory: 
string;
   Show: Word; bWait: Boolean): Longint;
 var
@@ -46,6 +52,28 @@
   if not bOK then Result := -1;
 end;
 
+{**
+ * Get the Tuxdroid installation path.
+ *}
+function getTuxdroidPath : string;
+begin
+  result := '';
+  with TRegistry.Create do
+    try
+      RootKey := HKEY_LOCAL_MACHINE;
+
+      // From Tuxdroid setup
+      if OpenKey(TUXDROID_REGISTRY_PATH, False) then
+      begin
+        // Get tuxdroid installation path
+        result := ReadString('Install_Dir');
+        CloseKey;
+      end;
+    finally
+      Free;
+    end;
+end;
+
 constructor TDongleHIDCheck.create(AOwner : TComponent);
 begin
   isWorking := false;
@@ -53,16 +81,14 @@
 
 function TDongleHIDCheck.check : boolean;
 var
-  filePath, cmd : string;
+  cmd : string;
   ret : integer;
 begin
-  filePath := extractfilepath(application.ExeName);
-
   cmd := '';
 
   isWorking := true;
   ret := ShellExecute_AndWait( 'open',
-                          PChar(filePath + 'dongle_hid_check.exe'),
+                          PChar(tuxdroidPath + '\bin\dongle_hid_check.exe'),
                           PChar(cmd),
                           PChar(''),
                           SW_HIDE,
@@ -78,4 +104,7 @@
   result := true;
 end;
 
+initialization
+  tuxdroidPath := getTuxdroidPath;
+
 end.

Modified: software_suite_v2/tuxware/fuxusbflasher/trunk/flasher/Tuxup.pas
===================================================================
--- software_suite_v2/tuxware/fuxusbflasher/trunk/flasher/Tuxup.pas     
2008-11-30 11:32:54 UTC (rev 2933)
+++ software_suite_v2/tuxware/fuxusbflasher/trunk/flasher/Tuxup.pas     
2008-11-30 13:46:43 UTC (rev 2934)
@@ -4,9 +4,10 @@
 
 uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
-  Dialogs, StdCtrls, ShellApi;
+  Dialogs, StdCtrls, ShellApi, Registry;
 
 const
+  TUXDROID_REGISTRY_PATH = 'SOFTWARE\Tuxdroid\TuxdroidSetup';
   // Error codes enumeration.
   E_TUXUP_NOERROR                 = 0;
   E_TUXUP_CMDNOTFOUND             = 1;
@@ -30,6 +31,9 @@
 
 implementation
 
+var
+  tuxdroidPath : string;
+
 function ShellExecute_AndWait(Operation, FileName, Parameter, Directory: 
string;
   Show: Word; bWait: Boolean): Longint;
 var
@@ -60,6 +64,28 @@
   if not bOK then Result := -1;
 end;
 
+{**
+ * Get the Tuxdroid installation path.
+ *}
+function getTuxdroidPath : string;
+begin
+  result := '';
+  with TRegistry.Create do
+    try
+      RootKey := HKEY_LOCAL_MACHINE;
+
+      // From Tuxdroid setup
+      if OpenKey(TUXDROID_REGISTRY_PATH, False) then
+      begin
+        // Get tuxdroid installation path
+        result := ReadString('Install_Dir');
+        CloseKey;
+      end;
+    finally
+      Free;
+    end;
+end;
+
 constructor TTuxup.create(AOwner : TComponent);
 begin
   isWorking := false;
@@ -67,15 +93,16 @@
 
 function TTuxup.flash(firmware : string) : integer;
 var
-  filePath, cmd : string;
+  cmd : string;
   ret : integer;
+  Buffer: Array[0..MAX_PATH] of char;
 begin
   // Stop the server
   try
-    if fileexists('C:\tuxdroid\bin\tuxhttpserver_stop.exe') then
+    if fileexists(tuxdroidPath + '\bin\tuxhttpserver_stop.exe') then
     begin
       ShellExecute_AndWait( 'open',
-        PChar('C:\tuxdroid\bin\tuxhttpserver_stop.exe'),
+        PChar(tuxdroidPath + '\bin\tuxhttpserver_stop.exe'),
         PChar(''),
         PChar(''),
         SW_HIDE,
@@ -85,16 +112,15 @@
   end;
   sleep(500);
 
-  // Flash the firmware
-  filePath := extractfilepath(application.ExeName);
-
   firmware := StringReplace(firmware, '\', '/',
                           [rfReplaceAll, rfIgnoreCase]);
 
-  cmd := format('"%s"', [firmware]);
+  GetShortPathName(PChar(firmware), @Buffer, SizeOf(Buffer));
+
+  cmd := format('"%s"', [Buffer]);
   isWorking := true;
   ret := ShellExecute_AndWait( 'open',
-                          PChar(filePath + 'tuxup.exe'),
+                          PChar(tuxdroidPath + '\bin\tuxup.exe'),
                           PChar(cmd),
                           PChar(''),
                           SW_HIDE,
@@ -103,10 +129,10 @@
 
   // Start the server
   try
-    if fileexists('C:\tuxdroid\bin\tuxhttpserver_start.exe') then
+    if fileexists(tuxdroidPath + '\bin\tuxhttpserver_start.exe') then
     begin
       ShellExecute_AndWait( 'open',
-        PChar('C:\tuxdroid\bin\tuxhttpserver_start.exe'),
+        PChar(tuxdroidPath + '\bin\tuxhttpserver_start.exe'),
         PChar(''),
         PChar(''),
         SW_HIDE,
@@ -118,4 +144,7 @@
   result := ret;
 end;
 
+initialization
+  tuxdroidPath := getTuxdroidPath;
+
 end.

Modified: 
software_suite_v2/tuxware/fuxusbflasher/trunk/flasher/UninstallHIDDongle.pas
===================================================================
--- 
software_suite_v2/tuxware/fuxusbflasher/trunk/flasher/UninstallHIDDongle.pas    
    2008-11-30 11:32:54 UTC (rev 2933)
+++ 
software_suite_v2/tuxware/fuxusbflasher/trunk/flasher/UninstallHIDDongle.pas    
    2008-11-30 13:46:43 UTC (rev 2934)
@@ -4,8 +4,11 @@
 
 uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
-  Dialogs, StdCtrls, ShellApi;
+  Dialogs, StdCtrls, ShellApi, Registry;
 
+const
+  TUXDROID_REGISTRY_PATH = 'SOFTWARE\Tuxdroid\TuxdroidSetup';
+
 type
   TUninstallHIDDongle = class(TObject)
   public
@@ -16,6 +19,9 @@
 
 implementation
 
+var
+  tuxdroidPath : string;
+
 function ShellExecute_AndWait(Operation, FileName, Parameter, Directory: 
string;
   Show: Word; bWait: Boolean): Longint;
 var
@@ -46,6 +52,28 @@
   if not bOK then Result := -1;
 end;
 
+{**
+ * Get the Tuxdroid installation path.
+ *}
+function getTuxdroidPath : string;
+begin
+  result := '';
+  with TRegistry.Create do
+    try
+      RootKey := HKEY_LOCAL_MACHINE;
+
+      // From Tuxdroid setup
+      if OpenKey(TUXDROID_REGISTRY_PATH, False) then
+      begin
+        // Get tuxdroid installation path
+        result := ReadString('Install_Dir');
+        CloseKey;
+      end;
+    finally
+      Free;
+    end;
+end;
+
 constructor TUninstallHIDDongle.create(AOwner : TComponent);
 begin
   isWorking := false;
@@ -53,16 +81,14 @@
 
 function TUninstallHIDDongle.uninstall : boolean;
 var
-  filePath, cmd : string;
+  cmd : string;
   ret : integer;
 begin
-  filePath := extractfilepath(application.ExeName);
-
   cmd := '';
 
   isWorking := true;
   ret := ShellExecute_AndWait( 'open',
-                          PChar(filePath + 'uninstall_hid_dongle.exe'),
+                          PChar(tuxdroidPath + 
'\bin\uninstall_hid_dongle.exe'),
                           PChar(cmd),
                           PChar(''),
                           SW_HIDE,
@@ -78,4 +104,7 @@
   result := true;
 end;
 
+initialization
+  tuxdroidPath := getTuxdroidPath;
+
 end.


-------------------------------------------------------------------------
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

Reply via email to