Hi,
I am trying to communicate with a speed drive (proxidrive 5,5T leroy somer) connected with an SM-ethernet card, at this point I am able to ping the card from my computer wich will be the host, the card adress is 192.168.1.100, and the host computer has the following address 192.168.1.1, the code bellow is what I have started to do to program this speed drive.
unfortunatetly when I run it i get an error non connection established on the TCPErrorString = GetTCPErrorString (GetTCPPeerAddr(ConnectionHandle, PeerAddr, 256)); line, I thought that whenever I have started the registertcpserver function without any error the connection must be established but apparently not.
I am not sure I am doing it the right way, could somebody explain me how to handle this?
Does anybody know if someone had already wrote some similar code , or maybe used leroy somer previously mentionned products?
Thanks all
Olivier
#include <utility.h>
#include <formatio.h>
#include <ansi_c.h>
#include "toolbox.h"
#include <analysis.h>
#include <tcpsupp.h>
#include <cvirte.h>
#include <userint.h>
#include "Ethernet.h"
int TCPCallBackFunction (unsigned handle, int xType, int errCode, void *callbackData);
static int panelHandle;
char ** addresses;
int numAddresses;
int index;
unsigned int TCPConversationHandle;
void *DataPtr;
int DataSize;
char *TCPErrorString;
char HostAddr[256];
char PeerAddr[256];
unsigned int ConnectionHandle;
#define NB_MAX_DATA 100
#define REQUEST_BUFF_SIZE 50
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1;
if ((panelHandle = LoadPanel (0, "Ethernet.uir", PANEL)) < 0)
return -1;
DisplayPanel (panelHandle);
TCPErrorString = GetTCPErrorString( RegisterTCPServer (502, TCPCallBackFunction, 0000));
GetTCPHostAddr(HostAddr, 256);
TCPErrorString = GetTCPErrorString (GetTCPPeerAddr(ConnectionHandle, PeerAddr, 256));
//ServerTCPWrite(TCPConversationHandle, DataPtr, DataSize , 1 );
//int (*TCPCallBackFunction) (unsigned handle, int xType, int errCode, void *callbackData);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}
int TCPCallBackFunction (unsigned handle, int xType, int errCode, void *callbackData)
{
switch(xType)
{
case TCP_CONNECT :
printf("Connect\n");
break;
}
return 0;
}
int CVICALLBACK Send_CB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
ServerTCPWrite(TCPConversationHandle, DataPtr, DataSize , 1 );
break;
}
return 0;
}
int CVICALLBACK QuitCallback (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
QuitUserInterface(panelHandle);
break;
}
return 0;
}