LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

When

How much of a difference is there going from the call library function to the code interface node? I don't want to switch unless it is really necessary.
0 Kudos
Message 21 of 27
(1,735 Views)

I think I kind of figured out the problem with with returning a string. I found a similar code to return a string that uses string handle, but the .c file includes "extcode.h" When I try to use it, I get a bunch of errors. Mainly I need:

TH_REENTRANT MgErr  DSSetHandleSize(void *h, int32);

but I don't know what "TH_REENTRANT" means and I can't find the function on DSSetHandleSize(void *h, int32)

0 Kudos
Message 22 of 27
(1,721 Views)
How do I add the labview library file into my C program
0 Kudos
Message 23 of 27
(1,720 Views)

I used the example on passing strings in .dll but it still doesn't work.

_declspec(dllexport) int32 CRCMode(unsigned char *start_addr,unsigned char *end_addr)
{
DWORD iBytesWritten;
DWORD iBytesRead;
uChar ch;
uChar putin[15];
int32 i;

  count0 = 0;
  i = 0;
  putin[0]='C';
  putin[1]= ' ';
  memcpy(&putin[2],start_addr,4);
  putin[6]= ' ';
  memcpy(&putin[7],end_addr,4);
  putin[11]='\0';
  putin[12]='\r';
     WriteFile(hCom,putin,13,&iBytesWritten,NULL);

  while(ch != '>'){

  ReadFile(hCom,&ch,1,&iBytesRead,NULL);
  sh[i] = ch;
  i++;
  count0++;
  }
     ReadFile(hCom,&ch,1,&iBytesRead,NULL);
  sh[i] = ch;
  sh[++i]= '\0';
  return (count0+1);
}

_declspec(dllexport) int32 transfer(LStrHandle in_string,int32 size)
{
  MgErr error;
  int32 i;    
 
  // The first 32 bits are used for size information, and then the array comes after the size
  error = DSSetHandleSize(in_string, sizeof(int32) + size*sizeof(uChar) );
  if (error != mFullErr && error != mZoneErr)
  {
 (*in_string)->cnt=size;
    for (i=0; i<size; i++)
  (*in_string)->str[i]=sh[i];
 return 0;
  }
  return -1;
}

0 Kudos
Message 24 of 27
(1,715 Views)
Nvm, I figured it out. Thanks

Message Edited by Newguy100 on 08-25-2005 04:05 PM

0 Kudos
Message 25 of 27
(1,706 Views)

Newguy100,

Ref your "... Nvm, I figured it out.  ..."

I'm new2...  Could you tell me (us)  WHAT  it was ??

Thanks

0 Kudos
Message 26 of 27
(1,660 Views)
When passing strings from C to labiew, you need to include some files. Labview provides you with those files.
0 Kudos
Message 27 of 27
(1,649 Views)