Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

I have c++ code which I wrapped (so it's being used as a dll), and I call the functions in vb.net.

 

The C++ code calls functions (which work, coz I tested it in other programs) from a PCI card hooked up to the CPU.

 

In C++ the function which I call is:

 

 

 

extern "C" __declspec( dllexport ) int _stdcall GPS637Time(float *time, float *week)

{

UCHAR getpacket[80], sendpacket[80]; // Receive buffer

 

GpsPkt receive;

GpsPkt send;

int n;

int s;

 

send.len = 1;

send.id = 0x37;

send.data =sendpacket ;

receive.len = 20;

receive.id = 0x41;

receive.data = getpacket;

 

s = bcGPSMan (&send, &receive);

for (n=0;n!=100;n++){

if (s!=RC_ERROR) break;

s = bcGPSMan (&send, &receive);

}

if (s == RC_OK)

{

*time = (float)(convertf(&getpacket[0]));

*week=(float)(convertf(&getpacket[4]));

return RC_OK;

}

return RC_ERROR;

}

 

 

 

bcGPSMan(..) is from the PCI card.

the helper function is:

 

 

 

float convertf (char *s)

{

union {

float f;

char uc[4];

} fconv;

fconv.uc[3] = *(s++);

fconv.uc[2] = *(s++);

fconv.uc[1] = *(s++);

fconv.uc[0] = *s;

return fconv.f;

}

 

 

In VB.NET, I declare the dll function:

 

Private Declare Function GPS637Time Lib "GPS637Wrapper.dll" (ByRef time As Single, ByRef week As Single) As Long

 

 

And call it:

 

Dim ok As Long

ok = GPS637Time(time, week)

 

Where I get the above error message.

 

Can ANYONE pleaseeeeeee help me? :-\

Thank You!! :)

Posted

Thanks for the reply.

 

I made "ok" be an Integer, and I made the declaration for the function return an Integer.

It still causes the error.

I think it might have something to do with the parameters.

I tested the c++ code using just c++, and sending pointers to the function. I think the way I send variables in vb.net is incorrect. :s I'm not sure wut to do next.. How else can i send the variables in vb.net?? :confused:

Posted

ok = GPS637Time(time, week)

 

time and week. Where did you declare them and how did you declare them?

Live as if you were to die tomorrow. Learn as if you were to live forever.
Gandhi
Posted

I declared them in vb.net right before the GPS637Time(..) function.

 

Dim time, week as Single

 

I even tried to create new objects with time and week but it still created the error:

 

time = new Single

week = new Single

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...