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 opinion 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;
}
This bit shows the syntax and variable types that are used by the DLL function.
---------------------------------------------------------------------*/
/* rho-function : 11000 */
/* Function-name: rTClientCon() */
/* Purpose : Establish a TCP/IP connection to rho4. */
/* Before using any rho4-library-function, you must */
/* build a connection to your prefered server. */
/* Calling this function will establish your connection */
/* and you will get an ident number (ChannelId). */
/* */
/* You must copy this ChannelId to any function */
/* structure you will use, so don�t lose it. */
/* */
/* At the end of your work, after calling a lot of */
/* different functions, you have to close the channel. */
/* For closing (disconnecting) the channel you also need */
/* the channel ident number. See function rTClientDis */
/* */
/* For a decription of TCP/IP, the "hosts" file and the */
/* available rho4 server see documentation "GateWay". */
/*----------------------------------------------------------------------*/
/* Input-parameter: */
/* */
/* - HostName : The ASCII name for your rho4. This must be the same */
/* name as in the "hosts" file from your [WINDOWS] */
/* directory. Normally it is "rho4". */
/* */
/* - PortNo : The number of the desired port. */
/* The previous installed port numbers for the */
/* rho4-library-functions are: */
/* - rho_Funktionen_1 : 6091 */
/* - rho_Funktionen_2 : 6092 */
/* - rho_Funktionen_3 : 6093 */
/* - rho_Funktionen_4 : 6094 */
/* */
/* - Timeout : The timeout in seconds. The time the function will */
/* wait of the rho4-Server to establish a connection. */
/* This effects also the functions rTWrite, rTRead. */
/* Use: - -1 for blocking mode (timeout = infinite) */
/* - 0 no timeout */
/* - 5 a fair value */
/* - any positive number */
/* See also function rTSTimeOut */
/*----------------------------------------------------------------------*/
/* Output-parameter: */
/* */
/* - ChannelId : The number of the required TCP/IP-Connection. */
/* This number will be need for all following function */
/* calls. */
/*----------------------------------------------------------------------*/
/* Return-codes : */
/* -------------- */
/* == 0 : the function ended normal. */
/* -5000 to -5999 : see decription above */
/* > 10000 : see rmain.h */
/*----------------------------------------------------------------------*/
#define CTClientCon 11000
/*-------------------------------------------------------*/
typedef struct TTClientCon
{
char HostName[30];
unsigned short PortNo;
long Timeout;
long ChannelId;
} TTClientCon;
/*--------------------------------------------------------*/
EXTERN long STDCALL rTClientCon( TTClientCon * PTClientCon);
/*--------------------------------------------------------*/