NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
ADLMB
Posts: 2
0 Kudos

python nican.dll function call error

Based on the example in http://zone.ni.com/devzone/cda/tut/p/id/8911 I am trying

to access the LIN functions of the NI USB-8476 in the following python script:

 

#!/usr/bin/env python
from ctypes import *
dll = cdll.LoadLibrary("nican.dll")
linName = c_char_p("LIN0")
linPtr = c_void_p()
dll.ncOpenObject.argtypes = [POINTER(c_char_p), POINTER(c_void_p)]
returnValue = dll.ncOpenObject(linName, linPtr)

 

resulting in the following error message:

 

Traceback (most recent call last):
  File "./demo.py", line 15, in <module>
    returnValue = dll.ncOpenObject(byref(linName), linPtr)
ValueError: Procedure called with not enough arguments (8 bytes missing) or wrong calling convention

 

Thanks for any help.
Member
ADLMB
Posts: 2
0 Kudos

Re: python nican.dll function call error

Noticing that I had skipped over the ncConfig function call, thinking this may be a prior

error I tried to set up the ncConfig call according to the ctypes tutorial at

http://python.net/crew/theller/ctypes/tutorial.html.  I have been unable

to make the ncConfig function recognize the parameter arrays:

 

#!/usr/bin/env python
from ctypes import *
dll = cdll.LoadLibrary("nican.dll")
linName = c_char_p("LIN0")
linNumAttr = c_ulong(2)
NC_ATTR_START_ON_OPEN = c_ulong(0x80000006)
NC_ATTR_BAUD_RATE = c_ulong(0x80000007)
class linAttrIdList(Structure):
   _fields_ = [("ncAttrStartOnOpenID", c_ulong),("ncAttrBaudRateID", c_ulong)]
linAttrIdList.ncAttrStartOnOpenID = NC_ATTR_START_ON_OPEN
linAttrIdList.ncAttrBaudRateID = NC_ATTR_BAUD_RATE
class linAttrValueList(Structure):
   _fields_ = [("ncAttrStartOnOpen", c_ulong),("ncAttrBaudRate", c_ulong)]
linAttrIdList.ncAttrStartOnOpen = 0
linAttrIdList.ncAttrBaudRate = 9600
linPtr = c_void_p(0)
returnValue = dll.ncConfig(linName, linNumAttr, linAttrIdList, linAttrValueList)

 

this causes python output:

 

Traceback (most recent call last):
  File "./demo.py", line 23, in <module>
    returnValue = dll.ncConfig(linName, linNumAttr, linAttrIdList, linAttrValueList)
ctypes.ArgumentError: argument 3: <class 'TypeError'>: Don't know how to convert parameter 3

 

Again, any help is appreciated, especially any examples of correct python usage of nican.dll.

Active Participant
Mr.F
Posts: 332
0 Kudos

Re: python nican.dll function call error

Hi ADLMB,

Unfortunately the second link you posted is broken. Also, Python is not one of the languages that R&D tests with when designing the NI-CAN driver so there may be more issues like this moving forward with Python. I would encourage you to consider using a more widely adopted language. Looking at the NI-CAN readme, you can use LabWindows/CVI, Visual Basic 6.0, Microsoft C/C++ 6.0 or Borland C/C++. There may be someone of the forums with the specialized knowledge you need, good luck.

Matt
Applications Engineer
National Instruments
Member
w.persyn@televic.com
Posts: 1
0 Kudos

Re: python nican.dll function call error

Dear,

 

  About the access of the nican.dll driver from 'Python'

 

  Is there already a solution for it.

 

  We plan to use the NI USB-8473s as hardware interface an drive from a Python program ?

  I also suffer with the same issue like described above here

 

Thank you for an update,

Wouter

 

 

Active Participant
JordanG
Posts: 289
0 Kudos

Re: python nican.dll function call error

Hello,

As mentioned above, Python is not one of the languages R&D tests when they design the CAN driver. Again, any language listed in the readme can be used. I've also attached a few other documents you might find useful as well as the documents linked above.

 

Introduction to Scripting in Perl, Python and Tcl

http://zone.ni.com/devzone/cda/tut/p/id/8910

 

Advanced Scripting in Perl, Python and Tcl

http://zone.ni.com/devzone/cda/tut/p/id/8911

 

Call Perl and Python Scripts from LabVIEW

http://zone.ni.com/devzone/cda/tut/p/id/8493

 

I hope this helps! Good luck programming!

 

Jordan

Member
medendoc
Posts: 10
0 Kudos

Re: python nican.dll function call error

Hello all,

 

Have you had any luck with this?  I am attempting to use the USB-8473 for monitoring CAN traffic, and would be greatful for any help.

 

Thank you

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page