CVS: python/mspgcc jtag.py,1.10,1.11

Chris Liechti <[email protected]> Mon, 27 Nov 2006 19:12:16 -0800
Newsgroups gmane.comp.hardware.texas-instruments.msp430.gcc.cvs
Message-ID <[email protected]>
Update of /cvsroot/mspgcc/python/mspgcc
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv20133/mspgcc

Modified Files:
	jtag.py 
Log Message:
ti backend support for linux

Index: jtag.py
===================================================================
RCS file: /cvsroot/mspgcc/python/mspgcc/jtag.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -w -d -r1.10 -r1.11
--- jtag.py	6 Oct 2006 13:31:37 -0000	1.10
+++ jtag.py	28 Nov 2006 03:12:14 -0000	1.11
@@ -129,7 +129,6 @@
         READ         = 1
         if sys.platform == 'win32':
             #the library is found on the PATH, respectively in the executables directory
-            
             if force == CTYPES_MSPGCC:
                 MSP430mspgcc, backend_info = locate_library('MSP430mspgcc.dll', search_path)
                 backend = CTYPES_MSPGCC
@@ -150,12 +149,29 @@
             else:
                 raise ValueError("no such backend: %r" % force)
         else:
-            #now try to locate library
+            #the library is found on the PATH, respectively in the executables directory
             try:
+                if force == CTYPES_MSPGCC:
+                    MSP430mspgcc, backend_info = locate_library('libMSP430mspgcc.so', search_path, ctypes.cdll)
+                    backend = CTYPES_MSPGCC
+                elif force == CTYPES_TI:
+                    #~ MSP430mspgcc = ctypes.windll.MSP430
+                    MSP430mspgcc, backend_info = locate_library('libMSP430.so', search_path, ctypes.cdll)
+                    backend = CTYPES_TI
+                elif force is None:
+                    #autodetect
+                    try:
+                        #try to use the TI or third party library
+                        MSP430mspgcc, backend_info = locate_library('libMSP430.so', search_path, ctypes.cdll)
+                        backend = CTYPES_TI
+                    except IOError:
+                        #when that fails, use the mspgcc implementation
                 MSP430mspgcc, backend_info = locate_library('libMSP430mspgcc.so', search_path, ctypes.cdll)
-            except IOError, e:
-                raise IOError('The environment variable "LIBMSPGCC_PATH" must point to the folder that contains "libMSP430mspgcc.so": %s' % e)
             backend = CTYPES_MSPGCC
+                else:
+                    raise ValueError("no such backend: %r" % force)
+            except IOError, e:
+                raise IOError('The environment variable "LIBMSPGCC_PATH" must point to the folder that contains "libMSP430mspgcc.so" or "libMSP430.so": %s' % e)
         
         global MSP430_Initialize, MSP430_Open, MSP430_Identify, MSP430_Close
         global MSP430_Configure, MSP430_VCC, MSP430_Reset, MSP430_Erase
@@ -271,7 +287,7 @@
                         port = "1"
                     else:
                         port = "/dev/parport0"
-                if backend == CTYPES_TI:
+                if backend == CTYPES_TI and sys.platform == 'win32':
                     port = port.upper()
                 status = MSP430_Initialize(port, ctypes.byref(version))
                 if status != STATUS_OK:


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV