ValueError: Procedure probably called with not enough arguments (8 bytes missing)

2009-08-07 Thread LabJack Support
Hello! I am chasing around a problem that I am having with ctypes and
I am hoping someone can help out. Here is the Python code:

def asynch(self, baudrate, data, idNum=None, demo=0, portB=0,
enableTE=0, enableTO=0, enableDel=0, numWrite=0, numRead=0):
"""
Name: U12.asynchConfig(fullA, fullB, fullC, halfA, halfB,
halfC, idNum=None, demo=None, timeoutMult=1, configA=0, configB=0,
configTE=0)
Args: See section 4.12 of the User's Guide
Desc: Requires firmware V1.1 or higher. This function writes
to the asynch registers and sets the direction of the D lines (input/
output) as needed.

>>> dev = U12()
>>> dev.asynchConfig(96,1,1,22,2,1)
>>> {'idNum': 1}
"""

#Check id number
if idNum is None:
idNum = self.id
idNum = ctypes.c_long(idNum)

# Check size of data
if len(data) > 18: raise ValueError("data can not be larger
than 18 elements")

# Make data 18 elements large
dataArray = [0] * 18
for i in range(0, len(data)):
dataArray[i] = data[i]
print dataArray
dataArray = listToCArray(dataArray, ctypes.c_long)

ecode = staticLib.AsynchConfig(ctypes.byref(idNum), demo,
portB, enableTE, enableTO, enableDel, baudrate, numWrite, numRead,
ctypes.byref(dataArray))

if ecode != 0:print ecode # TODO: Switch this out for
exception

return {"idnum":long, "data":dataArray}

Here is the method signature of the c function:

long Asynch(long *idnum,
long demo,
long portB,
long enableTE,
long enableTO,
long enableDel,
long baudrate,
long numWrite,
long numRead,
long *data)

Thank you in advance,
Sam
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: Procedure probably called with not enough arguments (8 bytes missing)

2009-08-07 Thread LabJack Support
On Aug 7, 4:16 pm, LabJack Support  wrote:
> Hello! I am chasing around a problem that I am having with ctypes and
> I am hoping someone can help out. Here is the Python code:
>
>     def asynch(self, baudrate, data, idNum=None, demo=0, portB=0,
> enableTE=0, enableTO=0, enableDel=0, numWrite=0, numRead=0):
>         """
>         Name: U12.asynchConfig(fullA, fullB, fullC, halfA, halfB,
> halfC, idNum=None, demo=None, timeoutMult=1, configA=0, configB=0,
> configTE=0)
>         Args: See section 4.12 of the User's Guide
>         Desc: Requires firmware V1.1 or higher. This function writes
> to the asynch registers and sets the direction of the D lines (input/
> output) as needed.
>
>         >>> dev = U12()
>         >>> dev.asynchConfig(96,1,1,22,2,1)
>         >>> {'idNum': 1}
>         """
>
>         #Check id number
>         if idNum is None:
>             idNum = self.id
>         idNum = ctypes.c_long(idNum)
>
>         # Check size of data
>         if len(data) > 18: raise ValueError("data can not be larger
> than 18 elements")
>
>         # Make data 18 elements large
>         dataArray = [0] * 18
>         for i in range(0, len(data)):
>             dataArray[i] = data[i]
>         print dataArray
>         dataArray = listToCArray(dataArray, ctypes.c_long)
>
>         ecode = staticLib.AsynchConfig(ctypes.byref(idNum), demo,
> portB, enableTE, enableTO, enableDel, baudrate, numWrite, numRead,
> ctypes.byref(dataArray))
>
>         if ecode != 0:print ecode # TODO: Switch this out for
> exception
>
>         return {"idnum":long, "data":dataArray}
>
> Here is the method signature of the c function:
>
> long Asynch(    long *idnum,
>                                 long demo,
>                                 long portB,
>                                 long enableTE,
>                                 long enableTO,
>                                 long enableDel,
>                                 long baudrate,
>                                 long numWrite,
>                                 long numRead,
>                                 long *data)
>
> Thank you in advance,
> Sam

Whoops I am sorry. The problem was due to a typo.
-- 
http://mail.python.org/mailman/listinfo/python-list