LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CIN access to DLL

I'm trying to write a few routines to interface with a Bosch SCARA robot using a DLL provided by Bosch. The DLL assumes that applications will be written in C and is not complete, requiring extensive use of "includes" which cannot be readily accommodated in LV.

I have begun dabbling in writing CINs to run snippets of code which will pass the required
parameters to the DLL and read the output. To date I haven't had much luck, and I haven't been able to find much assistance in solving this problem.

The code below is the first function that I am trying to set up. It sets up a TCP/IP connection with the robot's controller so that other hardware specific functions can be called.

After having debugged the C code, I am now of the opi
nion that I must be doing something wrong with the variable types so that LV is becomming confused. The lsb file generated from this code runs, but doesn't output a ChannelId number.

Can anybody offer any assistance, please. I may consider sub-contracting this work if anyone is interested, as I am running out of time on this project.



/*
* CIN source file
*/
#include "extcode.h"
#include "hosttype.h"
#include "windows.h"
#include "rimp.h"
#include "rmain.h"
#include "rt.h"

CIN MgErr CINRun(LStrHandle HostName, uInt16 *PortNo, int32 *Timeout, int32 *ChannelId);

CIN MgErr CINRun(LStrHandle HostName, uInt16 *PortNo, int32 *Timeout, int32 *ChannelId)
{
TTClientCon PTClientCon;

memset (&PTClientCon,'\0',sizeof PTClientCon);


memcpy (PTClientCon.HostName, HostName, sizeof HostName);
PTClientCon.PortNo = *PortNo;
PTClientCon.Timeout = *Timeout;
PTClientCon.ChannelId = *ChannelId;

rTClientCon(&PTClientCon);

return noErr;

}
0 Kudos
Message 1 of 3
(2,539 Views)
Try this one. Read CIN manual about Long pascal string and C string differences. To be short 4 bytes string length and then string data itself.
Make sure that hostname is not longer than 29 chars!
Use LabVIEW memory manager routines to do memory manipulations.
Error checking and defence is absent and should be implemented later. Don't forget.

This is a brief glance.

/*
* CIN source file
*/
#include "extcode.h"
#include "hosttype.h"
#include "windows.h"
#include "rimp.h"
#include "rmain.h"
#include "rt.h"

TTClientCon PTClientCon;

CIN MgErr CINRun(LStrHandle HostName, uInt16 *PortNo, int32 *Timeout, int32 *ChannelId);

CIN MgErr CINRun(LStrHandle HostName, uInt16 *PortNo, int32 *Timeout, int32 *ChannelId)
{
StrCpy(PTClientCon.HostName,*LstrBuf(*HostNa
me);
PTClientCon.PortNo = *PortNo;
PTClientCon.Timeout = *Timeout;

rTClientCon(&PTClientCon);

*ChannelId = PTClientCon.ChannelId;

return noErr;
}"

Good luck.
Sergey
0 Kudos
Message 2 of 3
(2,539 Views)
It's a mistake. Should be:
StrCpy(PTClientCon.HostName,LstrBuf(*HostName)
Sorry.
Sergey
0 Kudos
Message 3 of 3
(2,539 Views)