I've got an issue with my program, I'm working with Embarcadero XE8 C++ builder for 32 bit.
When I want to use a method to read/write stuff to a PLC (programmable logic controller, mostly used for communicating with machines) I get an object that is NULL
.
I simply have a Main form where I want to create the connection to the PLC.
In my main I have this:
static CEasyPLCHandler *pPLCHandler;
in a method on the same page I have:
long ReadWriteTest(void)
{
unsigned long ulStart;
PlcSymbolDesc *pSymbols;
unsigned long ulNumOfSymbols = 0;
int iNumOfVars = 2;
int i;
char **ppszVars = new char*[iNumOfVars];
for (i=0; i< iNumOfVars; i++)
ppszVars[i] = new char[255];
long lResult = RESULT_FAILED;
lResult = pPLCHandler->GetAllItems(&pSymbols, &ulNumOfSymbols);
if (lResult == RESULT_OK)
When I debug, It shows pPLCHandler = NULL
When I check out where CEasyPLCHandle
comes from, I come to a page (which I included from a library) and see these lines:
class PLCH_DLL_DECL CEasyPLCHandler : public CPLCHandler
{
public:
CEasyPLCHandler(RTS_HANDLE hLogFile = RTS_INVALID_HANDLE);
CEasyPLCHandler(PlcConfig *pPlcConfig, PlcDeviceDesc *pDeviceDesc, RTS_HANDLE hLogFile = RTS_INVALID_HANDLE);
CEasyPLCHandler(unsigned long ulId, char *pszIniFile, RTS_HANDLE hLogFile = RTS_INVALID_HANDLE);
CEasyPLCHandler(char *pszPlcName, char *pszIniFile, RTS_HANDLE hLogFile = RTS_INVALID_HANDLE);
virtual ~CEasyPLCHandler(void);
// See PLCConfig.h for defines of pszProtocol
// e.g. #define PLCC_DN_TCPIP_L2ROUTE "Tcp/Ip (Level 2 Route)"
virtual long ConnectTcpipViaGateway(char *pszGatewayIP, char *pszPlcIP, char *pszProtocol = PLCC_DN_TCPIP_L2ROUTE, int bMotorola = 0, int bLoadSymbols = 1, unsigned long ulTimeout = PLCHANDLER_USE_DEFAULT, unsigned long ulPort = 1200);
virtual long ConnectRs232ViaGateway(char *pszGatewayIP, short sPort, unsigned long ulBaudrate, int bMotorola = 0, int bLoadSymbols = 1, unsigned long ulTimeout = PLCHANDLER_USE_DEFAULT);
virtual long ConnectRs232ViaGatewayEx(char *pszGatewayIP, short sPort, unsigned long ulBaudrate, int bMotorola = 0, int bLoadSymbols = 1, unsigned long ulTimeout = PLCHANDLER_USE_DEFAULT, EXT_RS232_PARAMStyp *pExtParams = NULL);
virtual long ConnectTcpipViaArti(char *pszPlcIP, char *pszProtocol = PLCC_DN_TCPIP_L2ROUTE, int bMotorola = 0, int bLoadSymbols = 1, unsigned long ulTimeout = PLCHANDLER_USE_DEFAULT, unsigned long ulPort = 1200);
virtual long ConnectRs232ViaArti(short sPort, unsigned long ulBaudrate, int bMotorola = 0, int bLoadSymbols = 1, unsigned long ulTimeout = PLCHANDLER_USE_DEFAULT);
virtual long ConnectToSimulation(char *pszSdbFile, int bLoadSymbols = 1, unsigned long ulTimeout = PLCHANDLER_USE_DEFAULT);
virtual long ConnectViaGateway3(char *pszGatewayIP, char *pszAddress, int bLoadSymbols = 1, unsigned long ulTimeout = PLCHANDLER_USE_DEFAULT);
virtual long ConnectViaGateway3Ex(char *pszGatewayIP, unsigned long ulPort, char *pszAddress, int bLoadSymbols = 1, unsigned long ulTimeout = PLCHANDLER_USE_DEFAULT);
virtual long ConnectViaArti3(char *pszAddress, int bLoadSymbols = 1, unsigned long ulTimeout = PLCHANDLER_USE_DEFAULT);
virtual long ConnectToSimulation3(char *pszSdb3XmlFile, int bLoadSymbols = 1, unsigned long ulTimeout = PLCHANDLER_USE_DEFAULT);
// Attention: The structure of the service must be known in detail!
// An erroneous service might cause a crash of the PLC!
// Send own service to plc and receive reply
virtual long SyncSendService(/*[In]*/ unsigned char *pbySend, /*[In]*/ unsigned long ulSendSize, /*[Out]*/ unsigned char **ppbyRecv, /*[Out]*/ unsigned long *pulRecvSize);
// Send own service to plc
virtual long AsyncSendService(/*[Out]*/ int *piInvokeId, /*[In]*/ unsigned char *pbySend, /*[In]*/ unsigned long ulSendSize, /*[In]*/ CPLCHandlerCallback *pAsyncServiceCallback = NULL);
// Get service reply
virtual long AsyncGetServiceReply(/*[In]*/ int *piInvokeId, /*[Out]*/ unsigned char **ppbyRecv, /*[Out]*/ unsigned long *pulRecvSize, long *plServiceResult);
// Get SessionId for Device services (only used for GW3 and ARTI3)
virtual unsigned long GetDeviceSessionId(void);
};
So how can I create this object?
I added the line :
pPLCHandler = new CEasyPLCHandler(RTS_INVALID_HANDLE);
and get some unresolved external errors:
[ilink32 Error] Error: Unresolved external 'CEasyPLCHandler::~CEasyPLCHandler()' referenced from C:\USERS\BART\DOCUMENTS\EMBARCADERO\STUDIO\PROJECTS\REALTEST\WIN32\DEBUG\UNIT1.OBJ
But these are already in the other file? Why can't he use these?