Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-CAN for .NET yet?

Is there now an API for Visual Basic .NET yet?  Perhaps one out in Beta?  I understand I can derive one with the upgrade wizard, but would prefer the more robust solution of a NI-supplied API.
 
 
 
0 Kudos
Message 1 of 8
(6,967 Views)
Sorry to be the bearer of bad news, but there isn't a CAN API for VB.NET yet.  Your best bet is to submit it as a product suggestion at ni.com/contact .  Thanks, and good luck.
Chad B. » National Instruments » ni.com
0 Kudos
Message 2 of 8
(6,957 Views)

Having delved into this for a few days, I now understand why NI has not yet produced an API for .NET.  Microsoft broke much backward compatibility with Visual Studio 2005.  It is extremely difficult to get even a few of the API functions working on an as-needed basis.  This is not a simple job at all, and I suspect that is why NI has not yet done so.

But, I have little choice, as VB6 is not supported anymore.  So, please NI:

"Please make a Visual Studio object that encapsulates the LIN and CAN interfaces.  All of the functionality should be through regular properties and methods-- similar to, for example, the Visual Studio Serial Port object."

 

Best Regards,

Rein Teder
Opto-Electronics Engineer

 

 

 

 

 

0 Kudos
Message 3 of 8
(6,954 Views)
I agree.  I actually just got done submitting a product suggestion, and I'd suggest you do the same.  Every one of these suggestions is reviewed by someone in the R&D department.  You can do so at:

http://digital.ni.com/applications/psc.nsf/default?OpenForm&temp1=&node=


Chad B. » National Instruments » ni.com
0 Kudos
Message 4 of 8
(6,949 Views)
Just for the benefit of anyone else that is searching the NI site with the same problem:
 
I just gotten my NI USB-8476 LIN interface to work successfully read some LIN data in my .NET application.  This was difficult, because many pointers passed to/from the DLL's are of type "As Any", no longer allowed in VB.NET.  
 
VB will not allow you to just call this "As Object".  If you tell VB to return a pointer to structure of type NCTYPE_CAN_STRUCT, it should work, because that is in fact what it is pointing to.  But, alas, it does not.  VB gives you protected memory errors.  Now, perhaps a better programmer than I can come up with a cleaner solution, but this is how I got it to work:
 
ncRead woulds still allow me to get the data out as an array of bytes.    I did so, and parsed the ones I needed into the structure.  Code:
 
Status = ncRead(LINRx, AllottedDataSize, ByteBuffer(0))

If Status <> 0 Then GoTo RecError

'Public Structure NCTYPE_CAN_STRUCT

' Dim Timestamp As NCTYPE_UINT64 (Bytes 0 - 7)

' Dim ArbitrationId As Integer (4 Bytes, so Bytes 8, 9, 10, 11)

' Dim FrameType As Byte (Byte 12)

' Dim DataLength As Byte (Byte 13)

' <VBFixedArray(7)> Dim Data() As Byte (Bytes 14, 15, 16, 17, 18 19, 20, 21)

'End Structure

Dim ReceiveStruct As NCTYPE_CAN_STRUCT

ReceiveStruct.Initialize()

ReceiveStruct.ArbitrationId = ByteBuffer(8) + ByteBuffer(9) * 256 _

+ ByteBuffer(10) * 65536 + ByteBuffer(11) * 256 * 65536

ReceiveStruct.FrameType = ByteBuffer(12)

ReceiveStruct.DataLength = ByteBuffer(13)

For i = 0 To 7

ReceiveStruct.Data(i) = ByteBuffer(14 + i)

Next

 
 
0 Kudos
Message 5 of 8
(6,945 Views)
What about an RS232 to CAN converter?

http://www.easysync-ltd.com/index.html?lang=en-uk&target=d20.html

Suggestion to NI for VB support has been submitted...
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 6 of 8
(6,904 Views)

The above-referenced CAN to USB converter looks just great-- I'll check it out when I need to develop a CAN system. (A need which is likely to arrise soon.)  But, there are relatively few tools out there for the LIN bus, my current need.  (I tried a product called Baby LIN but found the documentation incomprehensible.)

Just confirming, I was able to get my project working using .NET and variations of the above snippet of code.  Essentially, with .NET you can no longer use type "Any" pointers, and the only thing I found that worked with the NI API was to pass to/from arrays of bytes.  The .NET upgrade wizard will NOT get you working code.  It is apparent to me why NI has not yet released a .NET package; if it was easy they would have done it.  I hope they do, as the NI product itself is very good.

 

Rein Teder
Opto-Electronics Engineer

 

 

 

 

0 Kudos
Message 7 of 8
(6,898 Views)

Hi, i'm trying to use usb 8476 with vb.net and i can't find the appropriate API or dll for.net. which library did you use please?

0 Kudos
Message 8 of 8
(264 Views)