Interfacing VBNet programs to Pico ADC controllers

 
Post new topic   Reply to topic    Pico Technology Forum Index -> .Net Languages (C#, VB.Net, .)
Author Message
Dave Cowles
User
User


Joined: 16 Nov 2007
Posts: 3

PostPosted: Fri Nov 16, 2007 7:55 pm    Post subject: Interfacing VBNet programs to Pico ADC controllers Reply with quote

I am a fairly new programmer in Visual Basic 2005 and totally new to communicating with Pico Technology Data Loggers via Visual Basic.
I have a new Pico Technologies ADC-24 Data Logger that I wish to program an interface for.
I downloaded and ran Pico Technologies HRDL program for Visual Basic. The program was written for an earlier version of Visual Basic but VB 2005 successfully upgraded it and it ran properly, communicating with the ADC-24. In the HRDL program all the calls to the ADC-24 are referenced as functions which call the PicoHRDL.dll library. All the functions are defined in a module so that they can be referenced anywhere in the program. The functions are then called (successfully) from the main module.

Here is my problem: Following HRDL's example, I created a new program. I created a module that defines all the function calls identically to what HRDL did (I simply copied all the function definitions in the HRDL module). I copied the PicoHRDL.dll file into the program's folder. I then tried to make a function call (with identical syntax as used in HRDL) in the main module. However, the program will not run--it crashes with an unhandled overflow exception (implying division by zero) at the line where I call the function.

I can't seem to find any way to avoid this. If I do not call the function the program runs perfectly. Can anyone give me an idea of what I am not doing right?

Thanks!

Dave Cowles
Back to top
ziko
Site Admin
Site Admin


Joined: 01 Dec 2006
Posts: 600
Location: St Neots

PostPosted: Thu Nov 29, 2007 2:26 pm    Post subject: Reply with quote

Hi Dave, thank you for your post.

Have you tried to debug it to see where the problem is? If so could you be more specific as to where the problem occurs, i.e. what function call , what parameters are you passing and so on.

Kind regards
Back to top
Dave Cowles
User
User


Joined: 16 Nov 2007
Posts: 3

PostPosted: Thu Nov 29, 2007 6:39 pm    Post subject: Specific program code Reply with quote

Thank you for your reply, Ziko.

I have discovered the reason for my trouble. It seems to be a very simple and emrarassing one of not having a match in the variable types. I thought I had checked and rechecked that but sure enough, after leaving the code and coming back to it I noticed a mismatch. After the mismatch was corrected the code was able to function.

By the way--I have encountered a problem with the HRDLGetUnitInfo function. That seems to be the only one that uses a fixed-length string as one of the parameters passed (at lease I assume that the notation char * string for one parameter and stringlength for the next parameter denotes a fixed-length string). It turns out that Visual Basic 2005 no longer directly supports fixed-length strings. Since VB 2005 is so closely integrated with the Microsoft .NET framework I am guessing that none of the other languages associated with .NET framework, such as Microsoft C, will support them either. So the result is that I cannot call HRDLGetInfo to learn what kind of card is present, any error codes, etc. I tried using a non-fixed length string for the parameter but it didn't work.

Do you or anyone else know how to work around this issue?

Dave
Back to top
markB
Site Admin
Site Admin


Joined: 27 Mar 2007
Posts: 80
Location: Cambridgeshire,UK

PostPosted: Fri Nov 30, 2007 4:29 pm    Post subject: Reply with quote

I'm not a VB expert but the following syntax should work for C#. I guess it wouldnt take too much to get this working for VB.

Code:
    [DllImport("PicoHRDL.dll")]
    public static extern short HRDLGetUnitInfo (
      short handle,
      StringBuilder info,
      short infoLength,
      short infoType);
Back to top
Dave Cowles
User
User


Joined: 16 Nov 2007
Posts: 3

PostPosted: Fri Nov 30, 2007 5:17 pm    Post subject: Reply with quote

Thanks, Mark--I'll check into that. VB has no Stringbuilder variable type but I will check to see if it might have an equivalent.

Dave
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Pico Technology Forum Index -> .Net Languages (C#, VB.Net, .)
All times are GMT
Page 1 of 1

 


Pico Technology topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group