CVS: jtag/python _parjtag.c,1.5,1.6

Chris Liechti <[email protected]>
Newsgroups gmane.comp.hardware.texas-instruments.msp430.gcc.cvs
Message-ID <[email protected]>
Update of /cvsroot/mspgcc/jtag/python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19465/jtag/python

Modified Files:
	_parjtag.c 
Log Message:
update to recent API changes

Index: _parjtag.c
===================================================================
RCS file: /cvsroot/mspgcc/jtag/python/_parjtag.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -d -r1.5 -r1.6
--- _parjtag.c	16 Feb 2004 18:48:33 -0000	1.5
+++ _parjtag.c	27 Dec 2005 16:29:37 -0000	1.6
@@ -9,11 +9,9 @@
 
 //JTAG functions
 #define  __doc__connect "connect()\n"\
-"Enable JTAG and connect to target. This stops it.\n"\
-"This function must be called before using any other JTAG function,\n"\
-"or the other functions will yield unpredictable data."
+"initialize backend and open port"
 static PyObject*
-py_connect(PyObject *self, PyObject *args)
+py_open(PyObject *self, PyObject *args)
 {
     char *port;
     STATUS_T status;
@@ -32,6 +30,22 @@
         return NULL;
     }
 
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+
+#define  __doc__open "connect()\n"\
+"Enable JTAG and connect to target. This stops it.\n"\
+"This function must be called before using any other JTAG function,\n"\
+"or the other functions will yield unpredictable data."
+static PyObject*
+py_connect(PyObject *self, PyObject *args)
+{
+    char *port;
+    STATUS_T status;
+    if (!PyArg_ParseTuple(args, "", &port))
+        return 0;
+
     MSP430_VCC(3);
     
     status = MSP430_Open();
@@ -215,22 +229,28 @@
 static PyObject*
 py_funclet(PyObject *self, PyObject *args) {
     STATUS_T status;
+    ULONG timeout = 1000;
+    ULONG runtime;
     char * code;
     int size;
-    if (!PyArg_ParseTuple(args, "s#", &code, &size))
+    if (!PyArg_ParseTuple(args, "s#|i", &code, &size, &timeout))
         return 0;
     if (size & 1) {
         PyErr_Format(PyExc_ValueError, "data must be of even size");
         return NULL;
     }
     
-    status = MSP430_Funclet(code, size, 1, 1);
+    status = MSP430_FuncletWait(code, size, 1, timeout, &runtime);
     if (status != STATUS_OK) {
         PyErr_Format(PyExc_IOError, "Could not execute code");
         return NULL;
     }
-    Py_INCREF(Py_None);
-    return Py_None;
+    //~ if runtime >= timeout:
+        //~ sys.stderr.write("Funclet stopped on timeout\n")
+        //~ sys.stderr.flush()
+    //~ if self.verbose:
+        //~ sys.stderr.write("Funclet OK (%.2fs).\n" % (runtime,))
+    return Py_BuildValue("i", runtime);
 }
 
 #define  __doc__configure "configure(mode, value)\n"\
@@ -344,6 +364,7 @@
 
 static PyMethodDef parjtag_methods[] = {
     //JTAG functions exposed to python
+    {"open",            py_open,        METH_VARARGS, __doc__open},
     {"connect",         py_connect,     METH_VARARGS, __doc__connect},
     {"release",         py_release,     METH_VARARGS, __doc__release},
     {"reset",           py_reset,       METH_VARARGS, __doc__reset},



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.