From 4749bbcde88e5967751b80992f5bc758aeab2b44 Mon Sep 17 00:00:00 2001 From: MarkRivers Date: Tue, 19 Dec 2006 18:24:45 +0000 Subject: [PATCH] V2.0.1 from Newport --- motorApp/NewportSrc/XPS_C8_drivers.cpp | 1691 +++++++++++++++--------- 1 file changed, 1098 insertions(+), 593 deletions(-) diff --git a/motorApp/NewportSrc/XPS_C8_drivers.cpp b/motorApp/NewportSrc/XPS_C8_drivers.cpp index a900e739..f291df16 100644 --- a/motorApp/NewportSrc/XPS_C8_drivers.cpp +++ b/motorApp/NewportSrc/XPS_C8_drivers.cpp @@ -1,23 +1,27 @@ -//////////////////////////////////////////////////////////////////// -// Created source file XPS_C8_drivers.cpp for API description -// - +/*//////////////////////////////////////////////////////////////////// +* Created source file xps_c8_drivers.cpp for API description +*/ #include #include #include -#include +#include #include "Socket.h" -#ifdef _WIN -#define DLL _declspec(dllexport) + +#ifdef _WIN32 + #define DLL _declspec(dllexport) #else -#define DLL + #define DLL #endif -#include "XPS_C8_drivers.h" + +#include "xps_c8_drivers.h" -#define SIZE_BUFFER 1024 +#define SIZE_SMALL 256 +#define SIZE_NOMINAL 512 +#define SIZE_BIG 2048 +#define SIZE_HUGE 32768 #define SIZE_NAME 100 @@ -28,7 +32,7 @@ extern "C" #endif -#define DLL_VERSION "Library version for XPS-C8 Firmware V2.0.0" +#define DLL_VERSION "Library version for XPS-C8 Firmware V2.0.1" /***********************************************************************/ int __stdcall TCP_ConnectToServer(char *Ip_Address, int Ip_Port, double TimeOut) @@ -59,15 +63,15 @@ char * __stdcall GetLibraryVersion(void) int __stdcall ElapsedTimeGet (int SocketIndex, double * ElapsedTime) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "ElapsedTimeGet (double *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -83,6 +87,9 @@ int __stdcall ElapsedTimeGet (int SocketIndex, double * ElapsedTime) if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", ElapsedTime); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -91,15 +98,15 @@ int __stdcall ElapsedTimeGet (int SocketIndex, double * ElapsedTime) int __stdcall ErrorStringGet (int SocketIndex, int ErrorCode, char * ErrorString) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "ErrorStringGet (%d,char *)", ErrorCode); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -117,6 +124,9 @@ int __stdcall ErrorStringGet (int SocketIndex, int ErrorCode, char * ErrorString ptNext = strchr (ErrorString, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -125,15 +135,15 @@ int __stdcall ErrorStringGet (int SocketIndex, int ErrorCode, char * ErrorString int __stdcall FirmwareVersionGet (int SocketIndex, char * Version) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "FirmwareVersionGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -151,6 +161,9 @@ int __stdcall FirmwareVersionGet (int SocketIndex, char * Version) ptNext = strchr (Version, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -159,19 +172,22 @@ int __stdcall FirmwareVersionGet (int SocketIndex, char * Version) int __stdcall TCLScriptExecute (int SocketIndex, char * TCLFileName, char * TaskName, char * ParametersList) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "TCLScriptExecute (%s,%s,%s)", TCLFileName, TaskName, ParametersList); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -180,15 +196,15 @@ int __stdcall TCLScriptExecute (int SocketIndex, char * TCLFileName, char * Task int __stdcall TCLScriptExecuteAndWait (int SocketIndex, char * TCLFileName, char * TaskName, char * InputParametersList, char * OutputParametersList) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "TCLScriptExecuteAndWait (%s,%s,%s,char *)", TCLFileName, TaskName, InputParametersList); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -206,6 +222,9 @@ int __stdcall TCLScriptExecuteAndWait (int SocketIndex, char * TCLFileName, char ptNext = strchr (OutputParametersList, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -214,19 +233,22 @@ int __stdcall TCLScriptExecuteAndWait (int SocketIndex, char * TCLFileName, char int __stdcall TCLScriptKill (int SocketIndex, char * TaskName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "TCLScriptKill (%s)", TaskName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -235,15 +257,15 @@ int __stdcall TCLScriptKill (int SocketIndex, char * TaskName) int __stdcall TimerGet (int SocketIndex, char * TimerName, int * FrequencyTicks) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "TimerGet (%s,int *)", TimerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -259,6 +281,9 @@ int __stdcall TimerGet (int SocketIndex, char * TimerName, int * FrequencyTicks) if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%d", FrequencyTicks); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -267,19 +292,22 @@ int __stdcall TimerGet (int SocketIndex, char * TimerName, int * FrequencyTicks) int __stdcall TimerSet (int SocketIndex, char * TimerName, int FrequencyTicks) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "TimerSet (%s,%d)", TimerName, FrequencyTicks); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -288,19 +316,22 @@ int __stdcall TimerSet (int SocketIndex, char * TimerName, int FrequencyTicks) int __stdcall Reboot (int SocketIndex) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "Reboot ()"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -309,19 +340,22 @@ int __stdcall Reboot (int SocketIndex) int __stdcall EventAdd (int SocketIndex, char * PositionerName, char * EventName, char * EventParameter, char * ActionName, char * ActionParameter1, char * ActionParameter2, char * ActionParameter3) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "EventAdd (%s,%s,%s,%s,%s,%s,%s)", PositionerName, EventName, EventParameter, ActionName, ActionParameter1, ActionParameter2, ActionParameter3); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -330,15 +364,15 @@ int __stdcall EventAdd (int SocketIndex, char * PositionerName, char * EventName int __stdcall EventGet (int SocketIndex, char * PositionerName, char * EventsAndActionsList) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_BIG); /* Convert to string */ sprintf (ExecuteMethod, "EventGet (%s,char *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BIG); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -356,6 +390,9 @@ int __stdcall EventGet (int SocketIndex, char * PositionerName, char * EventsAnd ptNext = strchr (EventsAndActionsList, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -364,19 +401,22 @@ int __stdcall EventGet (int SocketIndex, char * PositionerName, char * EventsAnd int __stdcall EventRemove (int SocketIndex, char * PositionerName, char * EventName, char * EventParameter) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "EventRemove (%s,%s,%s)", PositionerName, EventName, EventParameter); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -385,19 +425,22 @@ int __stdcall EventRemove (int SocketIndex, char * PositionerName, char * EventN int __stdcall EventWait (int SocketIndex, char * PositionerName, char * EventName, char * EventParameter) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "EventWait (%s,%s,%s)", PositionerName, EventName, EventParameter); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -406,20 +449,20 @@ int __stdcall EventWait (int SocketIndex, char * PositionerName, char * EventNam int __stdcall EventExtendedConfigurationTriggerSet (int SocketIndex, int NbElements, char * ExtendedEventNameList, char * EventParameter1List, char * EventParameter2List, char * EventParameter3List, char * EventParameter4List) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; - char temp[SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); + char temp[SIZE_NOMINAL]; /* Split list */ char *token; char seps[] = " \t;"; int indice; - char list [SIZE_BUFFER]; + char list [SIZE_NOMINAL]; char (*stringArray0)[SIZE_NAME]; stringArray0 = new char [NbElements][SIZE_NAME]; indice = 0; - strncpyWithEOS (list, ExtendedEventNameList, SIZE_BUFFER, SIZE_BUFFER); + strncpyWithEOS (list, ExtendedEventNameList, SIZE_NOMINAL, SIZE_NOMINAL); token = strtok( list, seps ); while (( token != NULL ) && ( indice < NbElements )) { @@ -431,7 +474,7 @@ int __stdcall EventExtendedConfigurationTriggerSet (int SocketIndex, int NbEleme char (*stringArray1)[SIZE_NAME]; stringArray1 = new char [NbElements][SIZE_NAME]; indice = 0; - strncpyWithEOS (list, EventParameter1List, SIZE_BUFFER, SIZE_BUFFER); + strncpyWithEOS (list, EventParameter1List, SIZE_NOMINAL, SIZE_NOMINAL); token = strtok( list, seps ); while (( token != NULL ) && ( indice < NbElements )) { @@ -443,7 +486,7 @@ int __stdcall EventExtendedConfigurationTriggerSet (int SocketIndex, int NbEleme char (*stringArray2)[SIZE_NAME]; stringArray2 = new char [NbElements][SIZE_NAME]; indice = 0; - strncpyWithEOS (list, EventParameter2List, SIZE_BUFFER, SIZE_BUFFER); + strncpyWithEOS (list, EventParameter2List, SIZE_NOMINAL, SIZE_NOMINAL); token = strtok( list, seps ); while (( token != NULL ) && ( indice < NbElements )) { @@ -455,7 +498,7 @@ int __stdcall EventExtendedConfigurationTriggerSet (int SocketIndex, int NbEleme char (*stringArray3)[SIZE_NAME]; stringArray3 = new char [NbElements][SIZE_NAME]; indice = 0; - strncpyWithEOS (list, EventParameter3List, SIZE_BUFFER, SIZE_BUFFER); + strncpyWithEOS (list, EventParameter3List, SIZE_NOMINAL, SIZE_NOMINAL); token = strtok( list, seps ); while (( token != NULL ) && ( indice < NbElements )) { @@ -467,7 +510,7 @@ int __stdcall EventExtendedConfigurationTriggerSet (int SocketIndex, int NbEleme char (*stringArray4)[SIZE_NAME]; stringArray4 = new char [NbElements][SIZE_NAME]; indice = 0; - strncpyWithEOS (list, EventParameter4List, SIZE_BUFFER, SIZE_BUFFER); + strncpyWithEOS (list, EventParameter4List, SIZE_NOMINAL, SIZE_NOMINAL); token = strtok( list, seps ); while (( token != NULL ) && ( indice < NbElements )) { @@ -482,10 +525,10 @@ int __stdcall EventExtendedConfigurationTriggerSet (int SocketIndex, int NbEleme for (int i = 0; i < NbElements; i++) { sprintf (temp, "%s,%s,%s,%s,%s", stringArray0[i], stringArray1[i], stringArray2[i], stringArray3[i], stringArray4[i]); - strcat (ExecuteMethod, temp); + strncat (ExecuteMethod, temp, SIZE_SMALL); if ((i + 1) < NbElements) { - strcat (ExecuteMethod, ","); + strncat (ExecuteMethod, ",", SIZE_SMALL); } } strcat (ExecuteMethod, ")"); @@ -499,11 +542,14 @@ int __stdcall EventExtendedConfigurationTriggerSet (int SocketIndex, int NbEleme /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -512,15 +558,15 @@ int __stdcall EventExtendedConfigurationTriggerSet (int SocketIndex, int NbEleme int __stdcall EventExtendedConfigurationTriggerGet (int SocketIndex, char * EventTriggerConfiguration) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_BIG); /* Convert to string */ sprintf (ExecuteMethod, "EventExtendedConfigurationTriggerGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BIG); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -538,6 +584,9 @@ int __stdcall EventExtendedConfigurationTriggerGet (int SocketIndex, char * Even ptNext = strchr (EventTriggerConfiguration, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -546,20 +595,20 @@ int __stdcall EventExtendedConfigurationTriggerGet (int SocketIndex, char * Even int __stdcall EventExtendedConfigurationActionSet (int SocketIndex, int NbElements, char * ExtendedActionNameList, char * ActionParameter1List, char * ActionParameter2List, char * ActionParameter3List, char * ActionParameter4List) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; - char temp[SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); + char temp[SIZE_NOMINAL]; /* Split list */ char *token; char seps[] = " \t;"; int indice; - char list [SIZE_BUFFER]; + char list [SIZE_NOMINAL]; char (*stringArray0)[SIZE_NAME]; stringArray0 = new char [NbElements][SIZE_NAME]; indice = 0; - strncpyWithEOS (list, ExtendedActionNameList, SIZE_BUFFER, SIZE_BUFFER); + strncpyWithEOS (list, ExtendedActionNameList, SIZE_NOMINAL, SIZE_NOMINAL); token = strtok( list, seps ); while (( token != NULL ) && ( indice < NbElements )) { @@ -571,7 +620,7 @@ int __stdcall EventExtendedConfigurationActionSet (int SocketIndex, int NbElemen char (*stringArray1)[SIZE_NAME]; stringArray1 = new char [NbElements][SIZE_NAME]; indice = 0; - strncpyWithEOS (list, ActionParameter1List, SIZE_BUFFER, SIZE_BUFFER); + strncpyWithEOS (list, ActionParameter1List, SIZE_NOMINAL, SIZE_NOMINAL); token = strtok( list, seps ); while (( token != NULL ) && ( indice < NbElements )) { @@ -583,7 +632,7 @@ int __stdcall EventExtendedConfigurationActionSet (int SocketIndex, int NbElemen char (*stringArray2)[SIZE_NAME]; stringArray2 = new char [NbElements][SIZE_NAME]; indice = 0; - strncpyWithEOS (list, ActionParameter2List, SIZE_BUFFER, SIZE_BUFFER); + strncpyWithEOS (list, ActionParameter2List, SIZE_NOMINAL, SIZE_NOMINAL); token = strtok( list, seps ); while (( token != NULL ) && ( indice < NbElements )) { @@ -595,7 +644,7 @@ int __stdcall EventExtendedConfigurationActionSet (int SocketIndex, int NbElemen char (*stringArray3)[SIZE_NAME]; stringArray3 = new char [NbElements][SIZE_NAME]; indice = 0; - strncpyWithEOS (list, ActionParameter3List, SIZE_BUFFER, SIZE_BUFFER); + strncpyWithEOS (list, ActionParameter3List, SIZE_NOMINAL, SIZE_NOMINAL); token = strtok( list, seps ); while (( token != NULL ) && ( indice < NbElements )) { @@ -607,7 +656,7 @@ int __stdcall EventExtendedConfigurationActionSet (int SocketIndex, int NbElemen char (*stringArray4)[SIZE_NAME]; stringArray4 = new char [NbElements][SIZE_NAME]; indice = 0; - strncpyWithEOS (list, ActionParameter4List, SIZE_BUFFER, SIZE_BUFFER); + strncpyWithEOS (list, ActionParameter4List, SIZE_NOMINAL, SIZE_NOMINAL); token = strtok( list, seps ); while (( token != NULL ) && ( indice < NbElements )) { @@ -622,10 +671,10 @@ int __stdcall EventExtendedConfigurationActionSet (int SocketIndex, int NbElemen for (int i = 0; i < NbElements; i++) { sprintf (temp, "%s,%s,%s,%s,%s", stringArray0[i], stringArray1[i], stringArray2[i], stringArray3[i], stringArray4[i]); - strcat (ExecuteMethod, temp); + strncat (ExecuteMethod, temp, SIZE_SMALL); if ((i + 1) < NbElements) { - strcat (ExecuteMethod, ","); + strncat (ExecuteMethod, ",", SIZE_SMALL); } } strcat (ExecuteMethod, ")"); @@ -639,11 +688,14 @@ int __stdcall EventExtendedConfigurationActionSet (int SocketIndex, int NbElemen /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -652,15 +704,15 @@ int __stdcall EventExtendedConfigurationActionSet (int SocketIndex, int NbElemen int __stdcall EventExtendedConfigurationActionGet (int SocketIndex, char * ActionConfiguration) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_BIG); /* Convert to string */ sprintf (ExecuteMethod, "EventExtendedConfigurationActionGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BIG); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -678,6 +730,9 @@ int __stdcall EventExtendedConfigurationActionGet (int SocketIndex, char * Actio ptNext = strchr (ActionConfiguration, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -686,15 +741,15 @@ int __stdcall EventExtendedConfigurationActionGet (int SocketIndex, char * Actio int __stdcall EventExtendedStart (int SocketIndex, int * ID) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "EventExtendedStart (int *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -710,6 +765,9 @@ int __stdcall EventExtendedStart (int SocketIndex, int * ID) if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%d", ID); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -718,15 +776,15 @@ int __stdcall EventExtendedStart (int SocketIndex, int * ID) int __stdcall EventExtendedAllGet (int SocketIndex, char * EventActionConfigurations) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_NOMINAL); /* Convert to string */ sprintf (ExecuteMethod, "EventExtendedAllGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_NOMINAL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -744,6 +802,9 @@ int __stdcall EventExtendedAllGet (int SocketIndex, char * EventActionConfigurat ptNext = strchr (EventActionConfigurations, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -752,15 +813,15 @@ int __stdcall EventExtendedAllGet (int SocketIndex, char * EventActionConfigurat int __stdcall EventExtendedGet (int SocketIndex, int ID, char * EventTriggerConfiguration, char * ActionConfiguration) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_BIG); /* Convert to string */ sprintf (ExecuteMethod, "EventExtendedGet (%d,char *,char *)", ID); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BIG); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -783,6 +844,9 @@ int __stdcall EventExtendedGet (int SocketIndex, int ID, char * EventTriggerConf ptNext = strchr (ActionConfiguration, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -791,19 +855,22 @@ int __stdcall EventExtendedGet (int SocketIndex, int ID, char * EventTriggerConf int __stdcall EventExtendedRemove (int SocketIndex, int ID) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "EventExtendedRemove (%d)", ID); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -812,19 +879,22 @@ int __stdcall EventExtendedRemove (int SocketIndex, int ID) int __stdcall EventExtendedWait (int SocketIndex) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "EventExtendedWait ()"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -833,15 +903,15 @@ int __stdcall EventExtendedWait (int SocketIndex) int __stdcall GatheringConfigurationGet (int SocketIndex, char * Type) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_HUGE); /* Convert to string */ sprintf (ExecuteMethod, "GatheringConfigurationGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_HUGE); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -859,6 +929,9 @@ int __stdcall GatheringConfigurationGet (int SocketIndex, char * Type) ptNext = strchr (Type, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -867,20 +940,20 @@ int __stdcall GatheringConfigurationGet (int SocketIndex, char * Type) int __stdcall GatheringConfigurationSet (int SocketIndex, int NbElements, char * TypeList) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; - char temp[SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); + char temp[SIZE_NOMINAL]; /* Split list */ char *token; char seps[] = " \t;"; int indice; - char list [SIZE_BUFFER]; + char list [SIZE_NOMINAL]; char (*stringArray0)[SIZE_NAME]; stringArray0 = new char [NbElements][SIZE_NAME]; indice = 0; - strncpyWithEOS (list, TypeList, SIZE_BUFFER, SIZE_BUFFER); + strncpyWithEOS (list, TypeList, SIZE_NOMINAL, SIZE_NOMINAL); token = strtok( list, seps ); while (( token != NULL ) && ( indice < NbElements )) { @@ -895,10 +968,10 @@ int __stdcall GatheringConfigurationSet (int SocketIndex, int NbElements, char * for (int i = 0; i < NbElements; i++) { sprintf (temp, "%s", stringArray0[i]); - strcat (ExecuteMethod, temp); + strncat (ExecuteMethod, temp, SIZE_SMALL); if ((i + 1) < NbElements) { - strcat (ExecuteMethod, ","); + strncat (ExecuteMethod, ",", SIZE_SMALL); } } strcat (ExecuteMethod, ")"); @@ -908,11 +981,14 @@ int __stdcall GatheringConfigurationSet (int SocketIndex, int NbElements, char * /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -921,15 +997,15 @@ int __stdcall GatheringConfigurationSet (int SocketIndex, int NbElements, char * int __stdcall GatheringCurrentNumberGet (int SocketIndex, int * CurrentNumber, int * MaximumSamplesNumber) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GatheringCurrentNumberGet (int *,int *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -948,6 +1024,9 @@ int __stdcall GatheringCurrentNumberGet (int SocketIndex, int * CurrentNumber, i if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%d", MaximumSamplesNumber); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -956,19 +1035,22 @@ int __stdcall GatheringCurrentNumberGet (int SocketIndex, int * CurrentNumber, i int __stdcall GatheringStopAndSave (int SocketIndex) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GatheringStopAndSave ()"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -977,19 +1059,22 @@ int __stdcall GatheringStopAndSave (int SocketIndex) int __stdcall GatheringDataAcquire (int SocketIndex) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GatheringDataAcquire ()"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -998,19 +1083,22 @@ int __stdcall GatheringDataAcquire (int SocketIndex) int __stdcall GatheringReset (int SocketIndex) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GatheringReset ()"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1019,20 +1107,20 @@ int __stdcall GatheringReset (int SocketIndex) int __stdcall GatheringExternalConfigurationSet (int SocketIndex, int NbElements, char * TypeList) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; - char temp[SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); + char temp[SIZE_NOMINAL]; /* Split list */ char *token; char seps[] = " \t;"; int indice; - char list [SIZE_BUFFER]; + char list [SIZE_NOMINAL]; char (*stringArray0)[SIZE_NAME]; stringArray0 = new char [NbElements][SIZE_NAME]; indice = 0; - strncpyWithEOS (list, TypeList, SIZE_BUFFER, SIZE_BUFFER); + strncpyWithEOS (list, TypeList, SIZE_NOMINAL, SIZE_NOMINAL); token = strtok( list, seps ); while (( token != NULL ) && ( indice < NbElements )) { @@ -1047,10 +1135,10 @@ int __stdcall GatheringExternalConfigurationSet (int SocketIndex, int NbElements for (int i = 0; i < NbElements; i++) { sprintf (temp, "%s", stringArray0[i]); - strcat (ExecuteMethod, temp); + strncat (ExecuteMethod, temp, SIZE_SMALL); if ((i + 1) < NbElements) { - strcat (ExecuteMethod, ","); + strncat (ExecuteMethod, ",", SIZE_SMALL); } } strcat (ExecuteMethod, ")"); @@ -1060,11 +1148,14 @@ int __stdcall GatheringExternalConfigurationSet (int SocketIndex, int NbElements /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1073,15 +1164,15 @@ int __stdcall GatheringExternalConfigurationSet (int SocketIndex, int NbElements int __stdcall GatheringExternalConfigurationGet (int SocketIndex, char * Type) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_HUGE); /* Convert to string */ sprintf (ExecuteMethod, "GatheringExternalConfigurationGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_HUGE); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -1099,6 +1190,9 @@ int __stdcall GatheringExternalConfigurationGet (int SocketIndex, char * Type) ptNext = strchr (Type, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1107,15 +1201,15 @@ int __stdcall GatheringExternalConfigurationGet (int SocketIndex, char * Type) int __stdcall GatheringExternalCurrentNumberGet (int SocketIndex, int * CurrentNumber, int * MaximumSamplesNumber) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GatheringExternalCurrentNumberGet (int *,int *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -1134,6 +1228,9 @@ int __stdcall GatheringExternalCurrentNumberGet (int SocketIndex, int * CurrentN if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%d", MaximumSamplesNumber); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1142,19 +1239,22 @@ int __stdcall GatheringExternalCurrentNumberGet (int SocketIndex, int * CurrentN int __stdcall GatheringExternalStopAndSave (int SocketIndex) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GatheringExternalStopAndSave ()"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1163,15 +1263,15 @@ int __stdcall GatheringExternalStopAndSave (int SocketIndex) int __stdcall GlobalArrayGet (int SocketIndex, int Number, char * ValueString) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GlobalArrayGet (%d,char *)", Number); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -1189,6 +1289,9 @@ int __stdcall GlobalArrayGet (int SocketIndex, int Number, char * ValueString) ptNext = strchr (ValueString, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1197,19 +1300,22 @@ int __stdcall GlobalArrayGet (int SocketIndex, int Number, char * ValueString) int __stdcall GlobalArraySet (int SocketIndex, int Number, char * ValueString) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GlobalArraySet (%d,%s)", Number, ValueString); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1218,20 +1324,20 @@ int __stdcall GlobalArraySet (int SocketIndex, int Number, char * ValueString) int __stdcall GPIOAnalogGet (int SocketIndex, int NbElements, char * GPIONameList, double AnalogValue[]) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; - char temp[SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); + char temp[SIZE_NOMINAL]; /* Split list */ char *token; char seps[] = " \t;"; int indice; - char list [SIZE_BUFFER]; + char list [SIZE_NOMINAL]; char (*stringArray0)[SIZE_NAME]; stringArray0 = new char [NbElements][SIZE_NAME]; indice = 0; - strncpyWithEOS (list, GPIONameList, SIZE_BUFFER, SIZE_BUFFER); + strncpyWithEOS (list, GPIONameList, SIZE_NOMINAL, SIZE_NOMINAL); token = strtok( list, seps ); while (( token != NULL ) && ( indice < NbElements )) { @@ -1246,10 +1352,10 @@ int __stdcall GPIOAnalogGet (int SocketIndex, int NbElements, char * GPIONameLis for (int i = 0; i < NbElements; i++) { sprintf (temp, "%s,double *", stringArray0[i]); - strcat (ExecuteMethod, temp); + strncat (ExecuteMethod, temp, SIZE_SMALL); if ((i + 1) < NbElements) { - strcat (ExecuteMethod, ","); + strncat (ExecuteMethod, ",", SIZE_SMALL); } } strcat (ExecuteMethod, ")"); @@ -1259,7 +1365,7 @@ int __stdcall GPIOAnalogGet (int SocketIndex, int NbElements, char * GPIONameLis /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -1279,6 +1385,9 @@ int __stdcall GPIOAnalogGet (int SocketIndex, int NbElements, char * GPIONameLis if (pt != NULL) sscanf (pt, "%lf", &AnalogValue[i]); } } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1287,20 +1396,20 @@ int __stdcall GPIOAnalogGet (int SocketIndex, int NbElements, char * GPIONameLis int __stdcall GPIOAnalogSet (int SocketIndex, int NbElements, char * GPIONameList, double AnalogOutputValue[]) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; - char temp[SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); + char temp[SIZE_NOMINAL]; /* Split list */ char *token; char seps[] = " \t;"; int indice; - char list [SIZE_BUFFER]; + char list [SIZE_NOMINAL]; char (*stringArray0)[SIZE_NAME]; stringArray0 = new char [NbElements][SIZE_NAME]; indice = 0; - strncpyWithEOS (list, GPIONameList, SIZE_BUFFER, SIZE_BUFFER); + strncpyWithEOS (list, GPIONameList, SIZE_NOMINAL, SIZE_NOMINAL); token = strtok( list, seps ); while (( token != NULL ) && ( indice < NbElements )) { @@ -1315,10 +1424,10 @@ int __stdcall GPIOAnalogSet (int SocketIndex, int NbElements, char * GPIONameLis for (int i = 0; i < NbElements; i++) { sprintf (temp, "%s,%.13g", stringArray0[i], AnalogOutputValue[i]); - strcat (ExecuteMethod, temp); + strncat (ExecuteMethod, temp, SIZE_SMALL); if ((i + 1) < NbElements) { - strcat (ExecuteMethod, ","); + strncat (ExecuteMethod, ",", SIZE_SMALL); } } strcat (ExecuteMethod, ")"); @@ -1328,11 +1437,14 @@ int __stdcall GPIOAnalogSet (int SocketIndex, int NbElements, char * GPIONameLis /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1341,20 +1453,20 @@ int __stdcall GPIOAnalogSet (int SocketIndex, int NbElements, char * GPIONameLis int __stdcall GPIOAnalogGainGet (int SocketIndex, int NbElements, char * GPIONameList, int AnalogInputGainValue[]) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; - char temp[SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); + char temp[SIZE_NOMINAL]; /* Split list */ char *token; char seps[] = " \t;"; int indice; - char list [SIZE_BUFFER]; + char list [SIZE_NOMINAL]; char (*stringArray0)[SIZE_NAME]; stringArray0 = new char [NbElements][SIZE_NAME]; indice = 0; - strncpyWithEOS (list, GPIONameList, SIZE_BUFFER, SIZE_BUFFER); + strncpyWithEOS (list, GPIONameList, SIZE_NOMINAL, SIZE_NOMINAL); token = strtok( list, seps ); while (( token != NULL ) && ( indice < NbElements )) { @@ -1369,10 +1481,10 @@ int __stdcall GPIOAnalogGainGet (int SocketIndex, int NbElements, char * GPIONam for (int i = 0; i < NbElements; i++) { sprintf (temp, "%s,int *", stringArray0[i]); - strcat (ExecuteMethod, temp); + strncat (ExecuteMethod, temp, SIZE_SMALL); if ((i + 1) < NbElements) { - strcat (ExecuteMethod, ","); + strncat (ExecuteMethod, ",", SIZE_SMALL); } } strcat (ExecuteMethod, ")"); @@ -1382,7 +1494,7 @@ int __stdcall GPIOAnalogGainGet (int SocketIndex, int NbElements, char * GPIONam /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -1402,6 +1514,9 @@ int __stdcall GPIOAnalogGainGet (int SocketIndex, int NbElements, char * GPIONam if (pt != NULL) sscanf (pt, "%d", &AnalogInputGainValue[i]); } } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1410,20 +1525,20 @@ int __stdcall GPIOAnalogGainGet (int SocketIndex, int NbElements, char * GPIONam int __stdcall GPIOAnalogGainSet (int SocketIndex, int NbElements, char * GPIONameList, int AnalogInputGainValue[]) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; - char temp[SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); + char temp[SIZE_NOMINAL]; /* Split list */ char *token; char seps[] = " \t;"; int indice; - char list [SIZE_BUFFER]; + char list [SIZE_NOMINAL]; char (*stringArray0)[SIZE_NAME]; stringArray0 = new char [NbElements][SIZE_NAME]; indice = 0; - strncpyWithEOS (list, GPIONameList, SIZE_BUFFER, SIZE_BUFFER); + strncpyWithEOS (list, GPIONameList, SIZE_NOMINAL, SIZE_NOMINAL); token = strtok( list, seps ); while (( token != NULL ) && ( indice < NbElements )) { @@ -1438,10 +1553,10 @@ int __stdcall GPIOAnalogGainSet (int SocketIndex, int NbElements, char * GPIONam for (int i = 0; i < NbElements; i++) { sprintf (temp, "%s,%d", stringArray0[i], AnalogInputGainValue[i]); - strcat (ExecuteMethod, temp); + strncat (ExecuteMethod, temp, SIZE_SMALL); if ((i + 1) < NbElements) { - strcat (ExecuteMethod, ","); + strncat (ExecuteMethod, ",", SIZE_SMALL); } } strcat (ExecuteMethod, ")"); @@ -1451,11 +1566,14 @@ int __stdcall GPIOAnalogGainSet (int SocketIndex, int NbElements, char * GPIONam /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1464,15 +1582,15 @@ int __stdcall GPIOAnalogGainSet (int SocketIndex, int NbElements, char * GPIONam int __stdcall GPIODigitalGet (int SocketIndex, char * GPIOName, unsigned short * DigitalValue) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GPIODigitalGet (%s,unsigned short *)", GPIOName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -1488,6 +1606,9 @@ int __stdcall GPIODigitalGet (int SocketIndex, char * GPIOName, unsigned short * if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%hu", DigitalValue); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1496,19 +1617,22 @@ int __stdcall GPIODigitalGet (int SocketIndex, char * GPIOName, unsigned short * int __stdcall GPIODigitalSet (int SocketIndex, char * GPIOName, unsigned short Mask, unsigned short DigitalOutputValue) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GPIODigitalSet (%s,%hu,%hu)", GPIOName, Mask, DigitalOutputValue); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1517,19 +1641,22 @@ int __stdcall GPIODigitalSet (int SocketIndex, char * GPIOName, unsigned short M int __stdcall GroupAnalogTrackingModeEnable (int SocketIndex, char * GroupName, char * Type) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GroupAnalogTrackingModeEnable (%s,%s)", GroupName, Type); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1538,19 +1665,22 @@ int __stdcall GroupAnalogTrackingModeEnable (int SocketIndex, char * GroupName, int __stdcall GroupAnalogTrackingModeDisable (int SocketIndex, char * GroupName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GroupAnalogTrackingModeDisable (%s)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1559,26 +1689,26 @@ int __stdcall GroupAnalogTrackingModeDisable (int SocketIndex, char * GroupName) int __stdcall GroupCorrectorOutputGet (int SocketIndex, char * GroupName, int NbElements, double CorrectorOutput[]) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; - char temp[SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); + char temp[SIZE_NOMINAL]; /* Convert to string */ sprintf (ExecuteMethod, "GroupCorrectorOutputGet (%s,", GroupName); for (int i = 0; i < NbElements; i++) { sprintf (temp, "double *"); - strcat (ExecuteMethod, temp); + strncat (ExecuteMethod, temp, SIZE_SMALL); if ((i + 1) < NbElements) { - strcat (ExecuteMethod, ","); + strncat (ExecuteMethod, ",", SIZE_SMALL); } } strcat (ExecuteMethod, ")"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -1598,6 +1728,9 @@ int __stdcall GroupCorrectorOutputGet (int SocketIndex, char * GroupName, int Nb if (pt != NULL) sscanf (pt, "%lf", &CorrectorOutput[i]); } } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1606,19 +1739,22 @@ int __stdcall GroupCorrectorOutputGet (int SocketIndex, char * GroupName, int Nb int __stdcall GroupHomeSearch (int SocketIndex, char * GroupName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GroupHomeSearch (%s)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1627,30 +1763,33 @@ int __stdcall GroupHomeSearch (int SocketIndex, char * GroupName) int __stdcall GroupHomeSearchAndRelativeMove (int SocketIndex, char * GroupName, int NbElements, double TargetDisplacement[]) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; - char temp[SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); + char temp[SIZE_NOMINAL]; /* Convert to string */ sprintf (ExecuteMethod, "GroupHomeSearchAndRelativeMove (%s,", GroupName); for (int i = 0; i < NbElements; i++) { sprintf (temp, "%.13g", TargetDisplacement[i]); - strcat (ExecuteMethod, temp); + strncat (ExecuteMethod, temp, SIZE_SMALL); if ((i + 1) < NbElements) { - strcat (ExecuteMethod, ","); + strncat (ExecuteMethod, ",", SIZE_SMALL); } } strcat (ExecuteMethod, ")"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1659,19 +1798,22 @@ int __stdcall GroupHomeSearchAndRelativeMove (int SocketIndex, char * GroupName, int __stdcall GroupInitialize (int SocketIndex, char * GroupName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GroupInitialize (%s)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1680,19 +1822,22 @@ int __stdcall GroupInitialize (int SocketIndex, char * GroupName) int __stdcall GroupInitializeWithEncoderCalibration (int SocketIndex, char * GroupName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GroupInitializeWithEncoderCalibration (%s)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1701,30 +1846,33 @@ int __stdcall GroupInitializeWithEncoderCalibration (int SocketIndex, char * Gro int __stdcall GroupJogParametersSet (int SocketIndex, char * GroupName, int NbElements, double Velocity[], double Acceleration[]) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; - char temp[SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); + char temp[SIZE_NOMINAL]; /* Convert to string */ sprintf (ExecuteMethod, "GroupJogParametersSet (%s,", GroupName); for (int i = 0; i < NbElements; i++) { sprintf (temp, "%.13g,%.13g", Velocity[i], Acceleration[i]); - strcat (ExecuteMethod, temp); + strncat (ExecuteMethod, temp, SIZE_SMALL); if ((i + 1) < NbElements) { - strcat (ExecuteMethod, ","); + strncat (ExecuteMethod, ",", SIZE_SMALL); } } strcat (ExecuteMethod, ")"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1733,26 +1881,26 @@ int __stdcall GroupJogParametersSet (int SocketIndex, char * GroupName, int NbEl int __stdcall GroupJogParametersGet (int SocketIndex, char * GroupName, int NbElements, double Velocity[], double Acceleration[]) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; - char temp[SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); + char temp[SIZE_NOMINAL]; /* Convert to string */ sprintf (ExecuteMethod, "GroupJogParametersGet (%s,", GroupName); for (int i = 0; i < NbElements; i++) { sprintf (temp, "double *,double *"); - strcat (ExecuteMethod, temp); + strncat (ExecuteMethod, temp, SIZE_SMALL); if ((i + 1) < NbElements) { - strcat (ExecuteMethod, ","); + strncat (ExecuteMethod, ",", SIZE_SMALL); } } strcat (ExecuteMethod, ")"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -1775,6 +1923,9 @@ int __stdcall GroupJogParametersGet (int SocketIndex, char * GroupName, int NbEl if (pt != NULL) sscanf (pt, "%lf", &Acceleration[i]); } } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1783,26 +1934,26 @@ int __stdcall GroupJogParametersGet (int SocketIndex, char * GroupName, int NbEl int __stdcall GroupJogCurrentGet (int SocketIndex, char * GroupName, int NbElements, double Velocity[], double Acceleration[]) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; - char temp[SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); + char temp[SIZE_NOMINAL]; /* Convert to string */ sprintf (ExecuteMethod, "GroupJogCurrentGet (%s,", GroupName); for (int i = 0; i < NbElements; i++) { sprintf (temp, "double *,double *"); - strcat (ExecuteMethod, temp); + strncat (ExecuteMethod, temp, SIZE_SMALL); if ((i + 1) < NbElements) { - strcat (ExecuteMethod, ","); + strncat (ExecuteMethod, ",", SIZE_SMALL); } } strcat (ExecuteMethod, ")"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -1825,6 +1976,9 @@ int __stdcall GroupJogCurrentGet (int SocketIndex, char * GroupName, int NbEleme if (pt != NULL) sscanf (pt, "%lf", &Acceleration[i]); } } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1833,19 +1987,22 @@ int __stdcall GroupJogCurrentGet (int SocketIndex, char * GroupName, int NbEleme int __stdcall GroupJogModeEnable (int SocketIndex, char * GroupName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GroupJogModeEnable (%s)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1854,19 +2011,22 @@ int __stdcall GroupJogModeEnable (int SocketIndex, char * GroupName) int __stdcall GroupJogModeDisable (int SocketIndex, char * GroupName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GroupJogModeDisable (%s)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1875,19 +2035,22 @@ int __stdcall GroupJogModeDisable (int SocketIndex, char * GroupName) int __stdcall GroupKill (int SocketIndex, char * GroupName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GroupKill (%s)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1896,19 +2059,22 @@ int __stdcall GroupKill (int SocketIndex, char * GroupName) int __stdcall GroupMoveAbort (int SocketIndex, char * GroupName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GroupMoveAbort (%s)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1917,30 +2083,33 @@ int __stdcall GroupMoveAbort (int SocketIndex, char * GroupName) int __stdcall GroupMoveAbsolute (int SocketIndex, char * GroupName, int NbElements, double TargetPosition[]) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; - char temp[SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); + char temp[SIZE_NOMINAL]; /* Convert to string */ sprintf (ExecuteMethod, "GroupMoveAbsolute (%s,", GroupName); for (int i = 0; i < NbElements; i++) { sprintf (temp, "%.13g", TargetPosition[i]); - strcat (ExecuteMethod, temp); + strncat (ExecuteMethod, temp, SIZE_SMALL); if ((i + 1) < NbElements) { - strcat (ExecuteMethod, ","); + strncat (ExecuteMethod, ",", SIZE_SMALL); } } strcat (ExecuteMethod, ")"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1949,30 +2118,33 @@ int __stdcall GroupMoveAbsolute (int SocketIndex, char * GroupName, int NbElemen int __stdcall GroupMoveRelative (int SocketIndex, char * GroupName, int NbElements, double TargetDisplacement[]) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; - char temp[SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); + char temp[SIZE_NOMINAL]; /* Convert to string */ sprintf (ExecuteMethod, "GroupMoveRelative (%s,", GroupName); for (int i = 0; i < NbElements; i++) { sprintf (temp, "%.13g", TargetDisplacement[i]); - strcat (ExecuteMethod, temp); + strncat (ExecuteMethod, temp, SIZE_SMALL); if ((i + 1) < NbElements) { - strcat (ExecuteMethod, ","); + strncat (ExecuteMethod, ",", SIZE_SMALL); } } strcat (ExecuteMethod, ")"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -1981,19 +2153,22 @@ int __stdcall GroupMoveRelative (int SocketIndex, char * GroupName, int NbElemen int __stdcall GroupMotionDisable (int SocketIndex, char * GroupName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GroupMotionDisable (%s)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2002,19 +2177,22 @@ int __stdcall GroupMotionDisable (int SocketIndex, char * GroupName) int __stdcall GroupMotionEnable (int SocketIndex, char * GroupName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GroupMotionEnable (%s)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2023,26 +2201,26 @@ int __stdcall GroupMotionEnable (int SocketIndex, char * GroupName) int __stdcall GroupPositionCurrentGet (int SocketIndex, char * GroupName, int NbElements, double CurrentEncoderPosition[]) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; - char temp[SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); + char temp[SIZE_NOMINAL]; /* Convert to string */ sprintf (ExecuteMethod, "GroupPositionCurrentGet (%s,", GroupName); for (int i = 0; i < NbElements; i++) { sprintf (temp, "double *"); - strcat (ExecuteMethod, temp); + strncat (ExecuteMethod, temp, SIZE_SMALL); if ((i + 1) < NbElements) { - strcat (ExecuteMethod, ","); + strncat (ExecuteMethod, ",", SIZE_SMALL); } } strcat (ExecuteMethod, ")"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -2062,6 +2240,9 @@ int __stdcall GroupPositionCurrentGet (int SocketIndex, char * GroupName, int Nb if (pt != NULL) sscanf (pt, "%lf", &CurrentEncoderPosition[i]); } } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2070,26 +2251,26 @@ int __stdcall GroupPositionCurrentGet (int SocketIndex, char * GroupName, int Nb int __stdcall GroupPositionSetpointGet (int SocketIndex, char * GroupName, int NbElements, double SetPointPosition[]) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; - char temp[SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); + char temp[SIZE_NOMINAL]; /* Convert to string */ sprintf (ExecuteMethod, "GroupPositionSetpointGet (%s,", GroupName); for (int i = 0; i < NbElements; i++) { sprintf (temp, "double *"); - strcat (ExecuteMethod, temp); + strncat (ExecuteMethod, temp, SIZE_SMALL); if ((i + 1) < NbElements) { - strcat (ExecuteMethod, ","); + strncat (ExecuteMethod, ",", SIZE_SMALL); } } strcat (ExecuteMethod, ")"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -2109,6 +2290,9 @@ int __stdcall GroupPositionSetpointGet (int SocketIndex, char * GroupName, int N if (pt != NULL) sscanf (pt, "%lf", &SetPointPosition[i]); } } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2117,26 +2301,26 @@ int __stdcall GroupPositionSetpointGet (int SocketIndex, char * GroupName, int N int __stdcall GroupPositionTargetGet (int SocketIndex, char * GroupName, int NbElements, double TargetPosition[]) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; - char temp[SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); + char temp[SIZE_NOMINAL]; /* Convert to string */ sprintf (ExecuteMethod, "GroupPositionTargetGet (%s,", GroupName); for (int i = 0; i < NbElements; i++) { sprintf (temp, "double *"); - strcat (ExecuteMethod, temp); + strncat (ExecuteMethod, temp, SIZE_SMALL); if ((i + 1) < NbElements) { - strcat (ExecuteMethod, ","); + strncat (ExecuteMethod, ",", SIZE_SMALL); } } strcat (ExecuteMethod, ")"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -2156,6 +2340,9 @@ int __stdcall GroupPositionTargetGet (int SocketIndex, char * GroupName, int NbE if (pt != NULL) sscanf (pt, "%lf", &TargetPosition[i]); } } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2164,19 +2351,22 @@ int __stdcall GroupPositionTargetGet (int SocketIndex, char * GroupName, int NbE int __stdcall GroupReferencingActionExecute (int SocketIndex, char * PositionerName, char * ReferencingAction, char * ReferencingSensor, double ReferencingParameter) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GroupReferencingActionExecute (%s,%s,%s,%.13g)", PositionerName, ReferencingAction, ReferencingSensor, ReferencingParameter); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2185,19 +2375,22 @@ int __stdcall GroupReferencingActionExecute (int SocketIndex, char * PositionerN int __stdcall GroupReferencingStart (int SocketIndex, char * GroupName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GroupReferencingStart (%s)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2206,19 +2399,22 @@ int __stdcall GroupReferencingStart (int SocketIndex, char * GroupName) int __stdcall GroupReferencingStop (int SocketIndex, char * GroupName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GroupReferencingStop (%s)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2227,15 +2423,15 @@ int __stdcall GroupReferencingStop (int SocketIndex, char * GroupName) int __stdcall GroupStatusGet (int SocketIndex, char * GroupName, int * Status) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GroupStatusGet (%s,int *)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -2251,6 +2447,9 @@ int __stdcall GroupStatusGet (int SocketIndex, char * GroupName, int * Status) if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%d", Status); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2259,15 +2458,15 @@ int __stdcall GroupStatusGet (int SocketIndex, char * GroupName, int * Status) int __stdcall GroupStatusStringGet (int SocketIndex, int GroupStatusCode, char * GroupStatusString) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_NOMINAL); /* Convert to string */ sprintf (ExecuteMethod, "GroupStatusStringGet (%d,char *)", GroupStatusCode); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_NOMINAL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -2285,6 +2484,9 @@ int __stdcall GroupStatusStringGet (int SocketIndex, int GroupStatusCode, char * ptNext = strchr (GroupStatusString, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2293,26 +2495,26 @@ int __stdcall GroupStatusStringGet (int SocketIndex, int GroupStatusCode, char * int __stdcall GroupVelocityCurrentGet (int SocketIndex, char * GroupName, int NbElements, double CurrentVelocity[]) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; - char temp[SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); + char temp[SIZE_NOMINAL]; /* Convert to string */ sprintf (ExecuteMethod, "GroupVelocityCurrentGet (%s,", GroupName); for (int i = 0; i < NbElements; i++) { sprintf (temp, "double *"); - strcat (ExecuteMethod, temp); + strncat (ExecuteMethod, temp, SIZE_SMALL); if ((i + 1) < NbElements) { - strcat (ExecuteMethod, ","); + strncat (ExecuteMethod, ",", SIZE_SMALL); } } strcat (ExecuteMethod, ")"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -2332,6 +2534,9 @@ int __stdcall GroupVelocityCurrentGet (int SocketIndex, char * GroupName, int Nb if (pt != NULL) sscanf (pt, "%lf", &CurrentVelocity[i]); } } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2340,19 +2545,22 @@ int __stdcall GroupVelocityCurrentGet (int SocketIndex, char * GroupName, int Nb int __stdcall KillAll (int SocketIndex) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "KillAll ()"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2361,15 +2569,15 @@ int __stdcall KillAll (int SocketIndex) int __stdcall PositionerAnalogTrackingPositionParametersGet (int SocketIndex, char * PositionerName, char * GPIOName, double * Offset, double * Scale, double * Velocity, double * Acceleration) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerAnalogTrackingPositionParametersGet (%s,char *,double *,double *,double *,double *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -2399,6 +2607,9 @@ int __stdcall PositionerAnalogTrackingPositionParametersGet (int SocketIndex, ch if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", Acceleration); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2407,19 +2618,22 @@ int __stdcall PositionerAnalogTrackingPositionParametersGet (int SocketIndex, ch int __stdcall PositionerAnalogTrackingPositionParametersSet (int SocketIndex, char * PositionerName, char * GPIOName, double Offset, double Scale, double Velocity, double Acceleration) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerAnalogTrackingPositionParametersSet (%s,%s,%.13g,%.13g,%.13g,%.13g)", PositionerName, GPIOName, Offset, Scale, Velocity, Acceleration); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2428,15 +2642,15 @@ int __stdcall PositionerAnalogTrackingPositionParametersSet (int SocketIndex, ch int __stdcall PositionerAnalogTrackingVelocityParametersGet (int SocketIndex, char * PositionerName, char * GPIOName, double * Offset, double * Scale, double * DeadBandThreshold, int * Order, double * Velocity, double * Acceleration) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerAnalogTrackingVelocityParametersGet (%s,char *,double *,double *,double *,int *,double *,double *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -2472,6 +2686,9 @@ int __stdcall PositionerAnalogTrackingVelocityParametersGet (int SocketIndex, ch if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", Acceleration); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2480,19 +2697,22 @@ int __stdcall PositionerAnalogTrackingVelocityParametersGet (int SocketIndex, ch int __stdcall PositionerAnalogTrackingVelocityParametersSet (int SocketIndex, char * PositionerName, char * GPIOName, double Offset, double Scale, double DeadBandThreshold, int Order, double Velocity, double Acceleration) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerAnalogTrackingVelocityParametersSet (%s,%s,%.13g,%.13g,%.13g,%d,%.13g,%.13g)", PositionerName, GPIOName, Offset, Scale, DeadBandThreshold, Order, Velocity, Acceleration); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2501,15 +2721,15 @@ int __stdcall PositionerAnalogTrackingVelocityParametersSet (int SocketIndex, ch int __stdcall PositionerBacklashGet (int SocketIndex, char * PositionerName, double * BacklashValue, char * BacklaskStatus) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerBacklashGet (%s,double *,char *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -2530,6 +2750,9 @@ int __stdcall PositionerBacklashGet (int SocketIndex, char * PositionerName, dou ptNext = strchr (BacklaskStatus, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2538,19 +2761,22 @@ int __stdcall PositionerBacklashGet (int SocketIndex, char * PositionerName, dou int __stdcall PositionerBacklashSet (int SocketIndex, char * PositionerName, double BacklashValue) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerBacklashSet (%s,%.13g)", PositionerName, BacklashValue); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2559,19 +2785,22 @@ int __stdcall PositionerBacklashSet (int SocketIndex, char * PositionerName, dou int __stdcall PositionerBacklashEnable (int SocketIndex, char * PositionerName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerBacklashEnable (%s)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2580,19 +2809,22 @@ int __stdcall PositionerBacklashEnable (int SocketIndex, char * PositionerName) int __stdcall PositionerBacklashDisable (int SocketIndex, char * PositionerName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerBacklashDisable (%s)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2601,19 +2833,22 @@ int __stdcall PositionerBacklashDisable (int SocketIndex, char * PositionerName) int __stdcall PositionerCorrectorNotchFiltersSet (int SocketIndex, char * PositionerName, double NotchFrequency1, double NotchBandwith1, double NotchGain1, double NotchFrequency2, double NotchBandwith2, double NotchGain2) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerCorrectorNotchFiltersSet (%s,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g)", PositionerName, NotchFrequency1, NotchBandwith1, NotchGain1, NotchFrequency2, NotchBandwith2, NotchGain2); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2622,15 +2857,15 @@ int __stdcall PositionerCorrectorNotchFiltersSet (int SocketIndex, char * Positi int __stdcall PositionerCorrectorNotchFiltersGet (int SocketIndex, char * PositionerName, double * NotchFrequency1, double * NotchBandwith1, double * NotchGain1, double * NotchFrequency2, double * NotchBandwith2, double * NotchGain2) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerCorrectorNotchFiltersGet (%s,double *,double *,double *,double *,double *,double *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -2661,6 +2896,9 @@ int __stdcall PositionerCorrectorNotchFiltersGet (int SocketIndex, char * Positi if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", NotchGain2); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2669,19 +2907,22 @@ int __stdcall PositionerCorrectorNotchFiltersGet (int SocketIndex, char * Positi int __stdcall PositionerCorrectorPIDFFAccelerationSet (int SocketIndex, char * PositionerName, bool ClosedLoopStatus, double KP, double KI, double KD, double KS, double IntegrationTime, double DerivativeFilterCutOffFrequency, double GKP, double GKI, double GKD, double KForm, double FeedForwardGainAcceleration) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerCorrectorPIDFFAccelerationSet (%s,%d,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g)", PositionerName, ClosedLoopStatus, KP, KI, KD, KS, IntegrationTime, DerivativeFilterCutOffFrequency, GKP, GKI, GKD, KForm, FeedForwardGainAcceleration); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2690,15 +2931,15 @@ int __stdcall PositionerCorrectorPIDFFAccelerationSet (int SocketIndex, char * P int __stdcall PositionerCorrectorPIDFFAccelerationGet (int SocketIndex, char * PositionerName, bool * ClosedLoopStatus, double * KP, double * KI, double * KD, double * KS, double * IntegrationTime, double * DerivativeFilterCutOffFrequency, double * GKP, double * GKI, double * GKD, double * KForm, double * FeedForwardGainAcceleration) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerCorrectorPIDFFAccelerationGet (%s,bool *,double *,double *,double *,double *,double *,double *,double *,double *,double *,double *,double *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -2747,6 +2988,9 @@ int __stdcall PositionerCorrectorPIDFFAccelerationGet (int SocketIndex, char * P if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", FeedForwardGainAcceleration); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2755,19 +2999,22 @@ int __stdcall PositionerCorrectorPIDFFAccelerationGet (int SocketIndex, char * P int __stdcall PositionerCorrectorPIDFFVelocitySet (int SocketIndex, char * PositionerName, bool ClosedLoopStatus, double KP, double KI, double KD, double KS, double IntegrationTime, double DerivativeFilterCutOffFrequency, double GKP, double GKI, double GKD, double KForm, double FeedForwardGainVelocity) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerCorrectorPIDFFVelocitySet (%s,%d,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g)", PositionerName, ClosedLoopStatus, KP, KI, KD, KS, IntegrationTime, DerivativeFilterCutOffFrequency, GKP, GKI, GKD, KForm, FeedForwardGainVelocity); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2776,15 +3023,15 @@ int __stdcall PositionerCorrectorPIDFFVelocitySet (int SocketIndex, char * Posit int __stdcall PositionerCorrectorPIDFFVelocityGet (int SocketIndex, char * PositionerName, bool * ClosedLoopStatus, double * KP, double * KI, double * KD, double * KS, double * IntegrationTime, double * DerivativeFilterCutOffFrequency, double * GKP, double * GKI, double * GKD, double * KForm, double * FeedForwardGainVelocity) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerCorrectorPIDFFVelocityGet (%s,bool *,double *,double *,double *,double *,double *,double *,double *,double *,double *,double *,double *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -2833,6 +3080,9 @@ int __stdcall PositionerCorrectorPIDFFVelocityGet (int SocketIndex, char * Posit if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", FeedForwardGainVelocity); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2841,19 +3091,22 @@ int __stdcall PositionerCorrectorPIDFFVelocityGet (int SocketIndex, char * Posit int __stdcall PositionerCorrectorPIDDualFFVoltageSet (int SocketIndex, char * PositionerName, bool ClosedLoopStatus, double KP, double KI, double KD, double KS, double IntegrationTime, double DerivativeFilterCutOffFrequency, double GKP, double GKI, double GKD, double KForm, double FeedForwardGainVelocity, double FeedForwardGainAcceleration, double Friction) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerCorrectorPIDDualFFVoltageSet (%s,%d,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g,%.13g)", PositionerName, ClosedLoopStatus, KP, KI, KD, KS, IntegrationTime, DerivativeFilterCutOffFrequency, GKP, GKI, GKD, KForm, FeedForwardGainVelocity, FeedForwardGainAcceleration, Friction); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2862,15 +3115,15 @@ int __stdcall PositionerCorrectorPIDDualFFVoltageSet (int SocketIndex, char * Po int __stdcall PositionerCorrectorPIDDualFFVoltageGet (int SocketIndex, char * PositionerName, bool * ClosedLoopStatus, double * KP, double * KI, double * KD, double * KS, double * IntegrationTime, double * DerivativeFilterCutOffFrequency, double * GKP, double * GKI, double * GKD, double * KForm, double * FeedForwardGainVelocity, double * FeedForwardGainAcceleration, double * Friction) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerCorrectorPIDDualFFVoltageGet (%s,bool *,double *,double *,double *,double *,double *,double *,double *,double *,double *,double *,double *,double *,double *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -2925,6 +3178,9 @@ int __stdcall PositionerCorrectorPIDDualFFVoltageGet (int SocketIndex, char * Po if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", Friction); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2933,19 +3189,22 @@ int __stdcall PositionerCorrectorPIDDualFFVoltageGet (int SocketIndex, char * Po int __stdcall PositionerCorrectorPIPositionSet (int SocketIndex, char * PositionerName, bool ClosedLoopStatus, double KP, double KI, double IntegrationTime) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerCorrectorPIPositionSet (%s,%d,%.13g,%.13g,%.13g)", PositionerName, ClosedLoopStatus, KP, KI, IntegrationTime); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2954,15 +3213,15 @@ int __stdcall PositionerCorrectorPIPositionSet (int SocketIndex, char * Position int __stdcall PositionerCorrectorPIPositionGet (int SocketIndex, char * PositionerName, bool * ClosedLoopStatus, double * KP, double * KI, double * IntegrationTime) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerCorrectorPIPositionGet (%s,bool *,double *,double *,double *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -2987,6 +3246,9 @@ int __stdcall PositionerCorrectorPIPositionGet (int SocketIndex, char * Position if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", IntegrationTime); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -2995,15 +3257,15 @@ int __stdcall PositionerCorrectorPIPositionGet (int SocketIndex, char * Position int __stdcall PositionerCorrectorTypeGet (int SocketIndex, char * PositionerName, char * CorrectorType) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerCorrectorTypeGet (%s,char *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3021,6 +3283,9 @@ int __stdcall PositionerCorrectorTypeGet (int SocketIndex, char * PositionerName ptNext = strchr (CorrectorType, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3029,19 +3294,22 @@ int __stdcall PositionerCorrectorTypeGet (int SocketIndex, char * PositionerName int __stdcall PositionerCurrentVelocityAccelerationFiltersSet (int SocketIndex, char * PositionerName, double CurrentVelocityCutOffFrequency, double CurrentAccelerationCutOffFrequency) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerCurrentVelocityAccelerationFiltersSet (%s,%.13g,%.13g)", PositionerName, CurrentVelocityCutOffFrequency, CurrentAccelerationCutOffFrequency); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3050,15 +3318,15 @@ int __stdcall PositionerCurrentVelocityAccelerationFiltersSet (int SocketIndex, int __stdcall PositionerCurrentVelocityAccelerationFiltersGet (int SocketIndex, char * PositionerName, double * CurrentVelocityCutOffFrequency, double * CurrentAccelerationCutOffFrequency) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerCurrentVelocityAccelerationFiltersGet (%s,double *,double *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3077,6 +3345,9 @@ int __stdcall PositionerCurrentVelocityAccelerationFiltersGet (int SocketIndex, if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", CurrentAccelerationCutOffFrequency); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3085,15 +3356,15 @@ int __stdcall PositionerCurrentVelocityAccelerationFiltersGet (int SocketIndex, int __stdcall PositionerDriverStatusGet (int SocketIndex, char * PositionerName, int * DriverStatus) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerDriverStatusGet (%s,int *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3109,6 +3380,9 @@ int __stdcall PositionerDriverStatusGet (int SocketIndex, char * PositionerName, if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%d", DriverStatus); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3117,15 +3391,15 @@ int __stdcall PositionerDriverStatusGet (int SocketIndex, char * PositionerName, int __stdcall PositionerDriverStatusStringGet (int SocketIndex, int PositionerDriverStatus, char * PositionerDriverStatusString) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_NOMINAL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerDriverStatusStringGet (%d,char *)", PositionerDriverStatus); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_NOMINAL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3143,6 +3417,9 @@ int __stdcall PositionerDriverStatusStringGet (int SocketIndex, int PositionerDr ptNext = strchr (PositionerDriverStatusString, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3151,15 +3428,15 @@ int __stdcall PositionerDriverStatusStringGet (int SocketIndex, int PositionerDr int __stdcall PositionerEncoderAmplitudeValuesGet (int SocketIndex, char * PositionerName, double * MaxSinusAmplitude, double * CurrentSinusAmplitude, double * MaxCosinusAmplitude, double * CurrentCosinusAmplitude) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerEncoderAmplitudeValuesGet (%s,double *,double *,double *,double *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3184,6 +3461,9 @@ int __stdcall PositionerEncoderAmplitudeValuesGet (int SocketIndex, char * Posit if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", CurrentCosinusAmplitude); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3192,15 +3472,15 @@ int __stdcall PositionerEncoderAmplitudeValuesGet (int SocketIndex, char * Posit int __stdcall PositionerEncoderCalibrationParametersGet (int SocketIndex, char * PositionerName, double * SinusOffset, double * CosinusOffset, double * DifferentialGain, double * PhaseCompensation) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerEncoderCalibrationParametersGet (%s,double *,double *,double *,double *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3225,6 +3505,9 @@ int __stdcall PositionerEncoderCalibrationParametersGet (int SocketIndex, char * if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", PhaseCompensation); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3233,15 +3516,15 @@ int __stdcall PositionerEncoderCalibrationParametersGet (int SocketIndex, char * int __stdcall PositionerErrorGet (int SocketIndex, char * PositionerName, int * ErrorCode) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerErrorGet (%s,int *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3257,6 +3540,9 @@ int __stdcall PositionerErrorGet (int SocketIndex, char * PositionerName, int * if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%d", ErrorCode); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3265,15 +3551,15 @@ int __stdcall PositionerErrorGet (int SocketIndex, char * PositionerName, int * int __stdcall PositionerErrorStringGet (int SocketIndex, int PositionerErrorCode, char * PositionerErrorString) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_NOMINAL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerErrorStringGet (%d,char *)", PositionerErrorCode); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_NOMINAL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3291,6 +3577,9 @@ int __stdcall PositionerErrorStringGet (int SocketIndex, int PositionerErrorCode ptNext = strchr (PositionerErrorString, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3299,15 +3588,15 @@ int __stdcall PositionerErrorStringGet (int SocketIndex, int PositionerErrorCode int __stdcall PositionerHardwareStatusGet (int SocketIndex, char * PositionerName, int * HardwareStatus) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerHardwareStatusGet (%s,int *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3323,6 +3612,9 @@ int __stdcall PositionerHardwareStatusGet (int SocketIndex, char * PositionerNam if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%d", HardwareStatus); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3331,15 +3623,15 @@ int __stdcall PositionerHardwareStatusGet (int SocketIndex, char * PositionerNam int __stdcall PositionerHardwareStatusStringGet (int SocketIndex, int PositionerHardwareStatus, char * PositionerHardwareStatusString) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_NOMINAL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerHardwareStatusStringGet (%d,char *)", PositionerHardwareStatus); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_NOMINAL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3357,6 +3649,9 @@ int __stdcall PositionerHardwareStatusStringGet (int SocketIndex, int Positioner ptNext = strchr (PositionerHardwareStatusString, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3365,15 +3660,15 @@ int __stdcall PositionerHardwareStatusStringGet (int SocketIndex, int Positioner int __stdcall PositionerHardInterpolatorFactorGet (int SocketIndex, char * PositionerName, int * InterpolationFactor) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerHardInterpolatorFactorGet (%s,int *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3389,6 +3684,9 @@ int __stdcall PositionerHardInterpolatorFactorGet (int SocketIndex, char * Posit if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%d", InterpolationFactor); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3397,19 +3695,22 @@ int __stdcall PositionerHardInterpolatorFactorGet (int SocketIndex, char * Posit int __stdcall PositionerHardInterpolatorFactorSet (int SocketIndex, char * PositionerName, int InterpolationFactor) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerHardInterpolatorFactorSet (%s,%d)", PositionerName, InterpolationFactor); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3418,15 +3719,15 @@ int __stdcall PositionerHardInterpolatorFactorSet (int SocketIndex, char * Posit int __stdcall PositionerMaximumVelocityAndAccelerationGet (int SocketIndex, char * PositionerName, double * MaximumVelocity, double * MaximumAcceleration) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerMaximumVelocityAndAccelerationGet (%s,double *,double *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3445,6 +3746,9 @@ int __stdcall PositionerMaximumVelocityAndAccelerationGet (int SocketIndex, char if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", MaximumAcceleration); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3453,15 +3757,15 @@ int __stdcall PositionerMaximumVelocityAndAccelerationGet (int SocketIndex, char int __stdcall PositionerMotionDoneGet (int SocketIndex, char * PositionerName, double * PositionWindow, double * VelocityWindow, double * CheckingTime, double * MeanPeriod, double * TimeOut) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerMotionDoneGet (%s,double *,double *,double *,double *,double *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3489,6 +3793,9 @@ int __stdcall PositionerMotionDoneGet (int SocketIndex, char * PositionerName, d if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", TimeOut); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3497,19 +3804,22 @@ int __stdcall PositionerMotionDoneGet (int SocketIndex, char * PositionerName, d int __stdcall PositionerMotionDoneSet (int SocketIndex, char * PositionerName, double PositionWindow, double VelocityWindow, double CheckingTime, double MeanPeriod, double TimeOut) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerMotionDoneSet (%s,%.13g,%.13g,%.13g,%.13g,%.13g)", PositionerName, PositionWindow, VelocityWindow, CheckingTime, MeanPeriod, TimeOut); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3518,15 +3828,15 @@ int __stdcall PositionerMotionDoneSet (int SocketIndex, char * PositionerName, d int __stdcall PositionerPositionCompareGet (int SocketIndex, char * PositionerName, double * MinimumPosition, double * MaximumPosition, double * PositionStep, bool * EnableState) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerPositionCompareGet (%s,double *,double *,double *,bool *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3551,6 +3861,9 @@ int __stdcall PositionerPositionCompareGet (int SocketIndex, char * PositionerNa if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%d", EnableState); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3559,19 +3872,22 @@ int __stdcall PositionerPositionCompareGet (int SocketIndex, char * PositionerNa int __stdcall PositionerPositionCompareSet (int SocketIndex, char * PositionerName, double MinimumPosition, double MaximumPosition, double PositionStep) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerPositionCompareSet (%s,%.13g,%.13g,%.13g)", PositionerName, MinimumPosition, MaximumPosition, PositionStep); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3580,19 +3896,22 @@ int __stdcall PositionerPositionCompareSet (int SocketIndex, char * PositionerNa int __stdcall PositionerPositionCompareEnable (int SocketIndex, char * PositionerName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerPositionCompareEnable (%s)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3601,19 +3920,22 @@ int __stdcall PositionerPositionCompareEnable (int SocketIndex, char * Positione int __stdcall PositionerPositionCompareDisable (int SocketIndex, char * PositionerName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerPositionCompareDisable (%s)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3622,15 +3944,15 @@ int __stdcall PositionerPositionCompareDisable (int SocketIndex, char * Position int __stdcall PositionerSGammaExactVelocityAjustedDisplacementGet (int SocketIndex, char * PositionerName, double DesiredDisplacement, double * AdjustedDisplacement) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerSGammaExactVelocityAjustedDisplacementGet (%s,%.13g,double *)", PositionerName, DesiredDisplacement); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3646,6 +3968,9 @@ int __stdcall PositionerSGammaExactVelocityAjustedDisplacementGet (int SocketInd if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", AdjustedDisplacement); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3654,15 +3979,15 @@ int __stdcall PositionerSGammaExactVelocityAjustedDisplacementGet (int SocketInd int __stdcall PositionerSGammaParametersGet (int SocketIndex, char * PositionerName, double * Velocity, double * Acceleration, double * MinimumTjerkTime, double * MaximumTjerkTime) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerSGammaParametersGet (%s,double *,double *,double *,double *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3687,6 +4012,9 @@ int __stdcall PositionerSGammaParametersGet (int SocketIndex, char * PositionerN if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", MaximumTjerkTime); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3695,19 +4023,22 @@ int __stdcall PositionerSGammaParametersGet (int SocketIndex, char * PositionerN int __stdcall PositionerSGammaParametersSet (int SocketIndex, char * PositionerName, double Velocity, double Acceleration, double MinimumTjerkTime, double MaximumTjerkTime) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerSGammaParametersSet (%s,%.13g,%.13g,%.13g,%.13g)", PositionerName, Velocity, Acceleration, MinimumTjerkTime, MaximumTjerkTime); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3716,15 +4047,15 @@ int __stdcall PositionerSGammaParametersSet (int SocketIndex, char * PositionerN int __stdcall PositionerSGammaPreviousMotionTimesGet (int SocketIndex, char * PositionerName, double * SettingTime, double * SettlingTime) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerSGammaPreviousMotionTimesGet (%s,double *,double *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3743,6 +4074,9 @@ int __stdcall PositionerSGammaPreviousMotionTimesGet (int SocketIndex, char * Po if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", SettlingTime); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3751,15 +4085,15 @@ int __stdcall PositionerSGammaPreviousMotionTimesGet (int SocketIndex, char * Po int __stdcall PositionerStageParameterGet (int SocketIndex, char * PositionerName, char * ParameterName, char * ParameterValue) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerStageParameterGet (%s,%s,char *)", PositionerName, ParameterName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3777,6 +4111,9 @@ int __stdcall PositionerStageParameterGet (int SocketIndex, char * PositionerNam ptNext = strchr (ParameterValue, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3785,15 +4122,15 @@ int __stdcall PositionerStageParameterGet (int SocketIndex, char * PositionerNam int __stdcall PositionerUserTravelLimitsGet (int SocketIndex, char * PositionerName, double * UserMinimumTarget, double * UserMaximumTarget) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerUserTravelLimitsGet (%s,double *,double *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3812,6 +4149,9 @@ int __stdcall PositionerUserTravelLimitsGet (int SocketIndex, char * PositionerN if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", UserMaximumTarget); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3820,19 +4160,22 @@ int __stdcall PositionerUserTravelLimitsGet (int SocketIndex, char * PositionerN int __stdcall PositionerUserTravelLimitsSet (int SocketIndex, char * PositionerName, double UserMinimumTarget, double UserMaximumTarget) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "PositionerUserTravelLimitsSet (%s,%.13g,%.13g)", PositionerName, UserMinimumTarget, UserMaximumTarget); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3841,19 +4184,22 @@ int __stdcall PositionerUserTravelLimitsSet (int SocketIndex, char * PositionerN int __stdcall MultipleAxesPVTVerification (int SocketIndex, char * GroupName, char * TrajectoryFileName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "MultipleAxesPVTVerification (%s,%s)", GroupName, TrajectoryFileName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3862,15 +4208,15 @@ int __stdcall MultipleAxesPVTVerification (int SocketIndex, char * GroupName, ch int __stdcall MultipleAxesPVTVerificationResultGet (int SocketIndex, char * PositionerName, char * FileName, double * MinimumPosition, double * MaximumPosition, double * MaximumVelocity, double * MaximumAcceleration) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "MultipleAxesPVTVerificationResultGet (%s,char *,double *,double *,double *,double *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3900,6 +4246,9 @@ int __stdcall MultipleAxesPVTVerificationResultGet (int SocketIndex, char * Posi if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", MaximumAcceleration); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3908,19 +4257,22 @@ int __stdcall MultipleAxesPVTVerificationResultGet (int SocketIndex, char * Posi int __stdcall MultipleAxesPVTExecution (int SocketIndex, char * GroupName, char * TrajectoryFileName, int ExecutionNumber) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "MultipleAxesPVTExecution (%s,%s,%d)", GroupName, TrajectoryFileName, ExecutionNumber); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3929,15 +4281,15 @@ int __stdcall MultipleAxesPVTExecution (int SocketIndex, char * GroupName, char int __stdcall MultipleAxesPVTParametersGet (int SocketIndex, char * GroupName, char * FileName, int * CurrentElementNumber) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "MultipleAxesPVTParametersGet (%s,char *,int *)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -3958,6 +4310,9 @@ int __stdcall MultipleAxesPVTParametersGet (int SocketIndex, char * GroupName, c if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%d", CurrentElementNumber); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3966,19 +4321,22 @@ int __stdcall MultipleAxesPVTParametersGet (int SocketIndex, char * GroupName, c int __stdcall MultipleAxesPVTPulseOutputSet (int SocketIndex, char * GroupName, int StartElement, int EndElement, double TimeInterval) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "MultipleAxesPVTPulseOutputSet (%s,%d,%d,%.13g)", GroupName, StartElement, EndElement, TimeInterval); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -3987,15 +4345,15 @@ int __stdcall MultipleAxesPVTPulseOutputSet (int SocketIndex, char * GroupName, int __stdcall MultipleAxesPVTPulseOutputGet (int SocketIndex, char * GroupName, int * StartElement, int * EndElement, double * TimeInterval) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "MultipleAxesPVTPulseOutputGet (%s,int *,int *,double *)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -4017,6 +4375,9 @@ int __stdcall MultipleAxesPVTPulseOutputGet (int SocketIndex, char * GroupName, if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", TimeInterval); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4025,19 +4386,22 @@ int __stdcall MultipleAxesPVTPulseOutputGet (int SocketIndex, char * GroupName, int __stdcall SingleAxisSlaveModeEnable (int SocketIndex, char * GroupName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "SingleAxisSlaveModeEnable (%s)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4046,19 +4410,22 @@ int __stdcall SingleAxisSlaveModeEnable (int SocketIndex, char * GroupName) int __stdcall SingleAxisSlaveModeDisable (int SocketIndex, char * GroupName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "SingleAxisSlaveModeDisable (%s)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4067,19 +4434,22 @@ int __stdcall SingleAxisSlaveModeDisable (int SocketIndex, char * GroupName) int __stdcall SingleAxisSlaveParametersSet (int SocketIndex, char * GroupName, char * PositionerName, double Ratio) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "SingleAxisSlaveParametersSet (%s,%s,%.13g)", GroupName, PositionerName, Ratio); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4088,15 +4458,15 @@ int __stdcall SingleAxisSlaveParametersSet (int SocketIndex, char * GroupName, c int __stdcall SingleAxisSlaveParametersGet (int SocketIndex, char * GroupName, char * PositionerName, double * Ratio) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "SingleAxisSlaveParametersGet (%s,char *,double *)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -4117,6 +4487,9 @@ int __stdcall SingleAxisSlaveParametersGet (int SocketIndex, char * GroupName, c if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", Ratio); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4125,19 +4498,22 @@ int __stdcall SingleAxisSlaveParametersGet (int SocketIndex, char * GroupName, c int __stdcall SpindleSlaveModeEnable (int SocketIndex, char * GroupName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "SpindleSlaveModeEnable (%s)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4146,19 +4522,22 @@ int __stdcall SpindleSlaveModeEnable (int SocketIndex, char * GroupName) int __stdcall SpindleSlaveModeDisable (int SocketIndex, char * GroupName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "SpindleSlaveModeDisable (%s)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4167,19 +4546,22 @@ int __stdcall SpindleSlaveModeDisable (int SocketIndex, char * GroupName) int __stdcall SpindleSlaveParametersSet (int SocketIndex, char * GroupName, char * PositionerName, double Ratio) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "SpindleSlaveParametersSet (%s,%s,%.13g)", GroupName, PositionerName, Ratio); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4188,15 +4570,15 @@ int __stdcall SpindleSlaveParametersSet (int SocketIndex, char * GroupName, char int __stdcall SpindleSlaveParametersGet (int SocketIndex, char * GroupName, char * PositionerName, double * Ratio) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "SpindleSlaveParametersGet (%s,char *,double *)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -4217,6 +4599,9 @@ int __stdcall SpindleSlaveParametersGet (int SocketIndex, char * GroupName, char if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", Ratio); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4225,19 +4610,22 @@ int __stdcall SpindleSlaveParametersGet (int SocketIndex, char * GroupName, char int __stdcall GroupSpinParametersSet (int SocketIndex, char * GroupName, double Velocity, double Acceleration) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GroupSpinParametersSet (%s,%.13g,%.13g)", GroupName, Velocity, Acceleration); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4246,15 +4634,15 @@ int __stdcall GroupSpinParametersSet (int SocketIndex, char * GroupName, double int __stdcall GroupSpinParametersGet (int SocketIndex, char * GroupName, double * Velocity, double * Acceleration) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GroupSpinParametersGet (%s,double *,double *)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -4273,6 +4661,9 @@ int __stdcall GroupSpinParametersGet (int SocketIndex, char * GroupName, double if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", Acceleration); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4281,15 +4672,15 @@ int __stdcall GroupSpinParametersGet (int SocketIndex, char * GroupName, double int __stdcall GroupSpinCurrentGet (int SocketIndex, char * GroupName, double * Velocity, double * Acceleration) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GroupSpinCurrentGet (%s,double *,double *)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -4308,6 +4699,9 @@ int __stdcall GroupSpinCurrentGet (int SocketIndex, char * GroupName, double * V if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", Acceleration); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4316,19 +4710,22 @@ int __stdcall GroupSpinCurrentGet (int SocketIndex, char * GroupName, double * V int __stdcall GroupSpinModeStop (int SocketIndex, char * GroupName, double Acceleration) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GroupSpinModeStop (%s,%.13g)", GroupName, Acceleration); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4337,19 +4734,22 @@ int __stdcall GroupSpinModeStop (int SocketIndex, char * GroupName, double Accel int __stdcall XYLineArcVerification (int SocketIndex, char * GroupName, char * TrajectoryFileName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "XYLineArcVerification (%s,%s)", GroupName, TrajectoryFileName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4358,15 +4758,15 @@ int __stdcall XYLineArcVerification (int SocketIndex, char * GroupName, char * T int __stdcall XYLineArcVerificationResultGet (int SocketIndex, char * PositionerName, char * FileName, double * MinimumPosition, double * MaximumPosition, double * MaximumVelocity, double * MaximumAcceleration) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "XYLineArcVerificationResultGet (%s,char *,double *,double *,double *,double *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -4396,6 +4796,9 @@ int __stdcall XYLineArcVerificationResultGet (int SocketIndex, char * Positioner if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", MaximumAcceleration); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4404,19 +4807,22 @@ int __stdcall XYLineArcVerificationResultGet (int SocketIndex, char * Positioner int __stdcall XYLineArcExecution (int SocketIndex, char * GroupName, char * TrajectoryFileName, double Velocity, double Acceleration, int ExecutionNumber) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "XYLineArcExecution (%s,%s,%.13g,%.13g,%d)", GroupName, TrajectoryFileName, Velocity, Acceleration, ExecutionNumber); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4425,15 +4831,15 @@ int __stdcall XYLineArcExecution (int SocketIndex, char * GroupName, char * Traj int __stdcall XYLineArcParametersGet (int SocketIndex, char * GroupName, char * FileName, double * Velocity, double * Acceleration, int * CurrentElementNumber) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "XYLineArcParametersGet (%s,char *,double *,double *,int *)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -4460,6 +4866,9 @@ int __stdcall XYLineArcParametersGet (int SocketIndex, char * GroupName, char * if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%d", CurrentElementNumber); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4468,19 +4877,22 @@ int __stdcall XYLineArcParametersGet (int SocketIndex, char * GroupName, char * int __stdcall XYLineArcPulseOutputSet (int SocketIndex, char * GroupName, double StartLength, double EndLength, double PathLengthInterval) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "XYLineArcPulseOutputSet (%s,%.13g,%.13g,%.13g)", GroupName, StartLength, EndLength, PathLengthInterval); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4489,15 +4901,15 @@ int __stdcall XYLineArcPulseOutputSet (int SocketIndex, char * GroupName, double int __stdcall XYLineArcPulseOutputGet (int SocketIndex, char * GroupName, double * StartLength, double * EndLength, double * PathLengthInterval) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "XYLineArcPulseOutputGet (%s,double *,double *,double *)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -4519,6 +4931,9 @@ int __stdcall XYLineArcPulseOutputGet (int SocketIndex, char * GroupName, double if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", PathLengthInterval); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4527,19 +4942,22 @@ int __stdcall XYLineArcPulseOutputGet (int SocketIndex, char * GroupName, double int __stdcall XYZSplineVerification (int SocketIndex, char * GroupName, char * TrajectoryFileName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "XYZSplineVerification (%s,%s)", GroupName, TrajectoryFileName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4548,15 +4966,15 @@ int __stdcall XYZSplineVerification (int SocketIndex, char * GroupName, char * T int __stdcall XYZSplineVerificationResultGet (int SocketIndex, char * PositionerName, char * FileName, double * MinimumPosition, double * MaximumPosition, double * MaximumVelocity, double * MaximumAcceleration) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "XYZSplineVerificationResultGet (%s,char *,double *,double *,double *,double *)", PositionerName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -4586,6 +5004,9 @@ int __stdcall XYZSplineVerificationResultGet (int SocketIndex, char * Positioner if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", MaximumAcceleration); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4594,19 +5015,22 @@ int __stdcall XYZSplineVerificationResultGet (int SocketIndex, char * Positioner int __stdcall XYZSplineExecution (int SocketIndex, char * GroupName, char * TrajectoryFileName, double Velocity, double Acceleration) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "XYZSplineExecution (%s,%s,%.13g,%.13g)", GroupName, TrajectoryFileName, Velocity, Acceleration); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4615,15 +5039,15 @@ int __stdcall XYZSplineExecution (int SocketIndex, char * GroupName, char * Traj int __stdcall XYZSplineParametersGet (int SocketIndex, char * GroupName, char * FileName, double * Velocity, double * Acceleration, int * CurrentElementNumber) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "XYZSplineParametersGet (%s,char *,double *,double *,int *)", GroupName); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -4650,6 +5074,9 @@ int __stdcall XYZSplineParametersGet (int SocketIndex, char * GroupName, char * if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%d", CurrentElementNumber); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4658,19 +5085,22 @@ int __stdcall XYZSplineParametersGet (int SocketIndex, char * GroupName, char * int __stdcall EEPROMCIESet (int SocketIndex, int CardNumber, char * ReferenceString) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "EEPROMCIESet (%d,%s)", CardNumber, ReferenceString); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4679,19 +5109,22 @@ int __stdcall EEPROMCIESet (int SocketIndex, int CardNumber, char * ReferenceStr int __stdcall EEPROMDACOffsetCIESet (int SocketIndex, int PlugNumber, double DAC1Offset, double DAC2Offset) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "EEPROMDACOffsetCIESet (%d,%.13g,%.13g)", PlugNumber, DAC1Offset, DAC2Offset); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4700,19 +5133,22 @@ int __stdcall EEPROMDACOffsetCIESet (int SocketIndex, int PlugNumber, double DAC int __stdcall EEPROMDriverSet (int SocketIndex, int PlugNumber, char * ReferenceString) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "EEPROMDriverSet (%d,%s)", PlugNumber, ReferenceString); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4721,19 +5157,22 @@ int __stdcall EEPROMDriverSet (int SocketIndex, int PlugNumber, char * Reference int __stdcall EEPROMINTSet (int SocketIndex, int CardNumber, char * ReferenceString) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "EEPROMINTSet (%d,%s)", CardNumber, ReferenceString); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); /* Get the returned values in the out parameters */ + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4742,15 +5181,15 @@ int __stdcall EEPROMINTSet (int SocketIndex, int CardNumber, char * ReferenceStr int __stdcall CPUCoreAndBoardSupplyVoltagesGet (int SocketIndex, double * VoltageCPUCore, double * SupplyVoltage1P5V, double * SupplyVoltage3P3V, double * SupplyVoltage5V, double * SupplyVoltage12V, double * SupplyVoltageM12V, double * SupplyVoltageM5V, double * SupplyVoltage5VSB) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "CPUCoreAndBoardSupplyVoltagesGet (double *,double *,double *,double *,double *,double *,double *,double *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -4787,6 +5226,9 @@ int __stdcall CPUCoreAndBoardSupplyVoltagesGet (int SocketIndex, double * Voltag if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", SupplyVoltage5VSB); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4795,15 +5237,15 @@ int __stdcall CPUCoreAndBoardSupplyVoltagesGet (int SocketIndex, double * Voltag int __stdcall CPUTemperatureAndFanSpeedGet (int SocketIndex, double * CPUTemperature, double * CPUFanSpeed) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "CPUTemperatureAndFanSpeedGet (double *,double *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -4822,6 +5264,9 @@ int __stdcall CPUTemperatureAndFanSpeedGet (int SocketIndex, double * CPUTempera if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", CPUFanSpeed); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4830,15 +5275,15 @@ int __stdcall CPUTemperatureAndFanSpeedGet (int SocketIndex, double * CPUTempera int __stdcall ActionListGet (int SocketIndex, char * ActionList) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_BIG); /* Convert to string */ sprintf (ExecuteMethod, "ActionListGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BIG); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -4856,6 +5301,9 @@ int __stdcall ActionListGet (int SocketIndex, char * ActionList) ptNext = strchr (ActionList, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4864,15 +5312,15 @@ int __stdcall ActionListGet (int SocketIndex, char * ActionList) int __stdcall ActionExtendedListGet (int SocketIndex, char * ActionList) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_BIG); /* Convert to string */ sprintf (ExecuteMethod, "ActionExtendedListGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BIG); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -4890,6 +5338,9 @@ int __stdcall ActionExtendedListGet (int SocketIndex, char * ActionList) ptNext = strchr (ActionList, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4898,15 +5349,15 @@ int __stdcall ActionExtendedListGet (int SocketIndex, char * ActionList) int __stdcall APIExtendedListGet (int SocketIndex, char * Method) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_HUGE); /* Convert to string */ sprintf (ExecuteMethod, "APIExtendedListGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_HUGE); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -4924,6 +5375,9 @@ int __stdcall APIExtendedListGet (int SocketIndex, char * Method) ptNext = strchr (Method, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4932,15 +5386,15 @@ int __stdcall APIExtendedListGet (int SocketIndex, char * Method) int __stdcall APIListGet (int SocketIndex, char * Method) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_HUGE); /* Convert to string */ sprintf (ExecuteMethod, "APIListGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_HUGE); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -4958,6 +5412,9 @@ int __stdcall APIListGet (int SocketIndex, char * Method) ptNext = strchr (Method, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -4966,15 +5423,15 @@ int __stdcall APIListGet (int SocketIndex, char * Method) int __stdcall ErrorListGet (int SocketIndex, char * ErrorsList) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_HUGE); /* Convert to string */ sprintf (ExecuteMethod, "ErrorListGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_HUGE); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -4992,6 +5449,9 @@ int __stdcall ErrorListGet (int SocketIndex, char * ErrorsList) ptNext = strchr (ErrorsList, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -5000,15 +5460,15 @@ int __stdcall ErrorListGet (int SocketIndex, char * ErrorsList) int __stdcall EventListGet (int SocketIndex, char * EventList) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_BIG); /* Convert to string */ sprintf (ExecuteMethod, "EventListGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BIG); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -5026,6 +5486,9 @@ int __stdcall EventListGet (int SocketIndex, char * EventList) ptNext = strchr (EventList, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -5034,15 +5497,15 @@ int __stdcall EventListGet (int SocketIndex, char * EventList) int __stdcall GatheringListGet (int SocketIndex, char * list) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_BIG); /* Convert to string */ sprintf (ExecuteMethod, "GatheringListGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BIG); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -5060,6 +5523,9 @@ int __stdcall GatheringListGet (int SocketIndex, char * list) ptNext = strchr (list, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -5068,15 +5534,15 @@ int __stdcall GatheringListGet (int SocketIndex, char * list) int __stdcall GatheringExtendedListGet (int SocketIndex, char * list) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_BIG); /* Convert to string */ sprintf (ExecuteMethod, "GatheringExtendedListGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BIG); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -5094,6 +5560,9 @@ int __stdcall GatheringExtendedListGet (int SocketIndex, char * list) ptNext = strchr (list, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -5102,15 +5571,15 @@ int __stdcall GatheringExtendedListGet (int SocketIndex, char * list) int __stdcall GatheringExternalListGet (int SocketIndex, char * list) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_BIG); /* Convert to string */ sprintf (ExecuteMethod, "GatheringExternalListGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BIG); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -5128,6 +5597,9 @@ int __stdcall GatheringExternalListGet (int SocketIndex, char * list) ptNext = strchr (list, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -5136,15 +5608,15 @@ int __stdcall GatheringExternalListGet (int SocketIndex, char * list) int __stdcall GroupStatusListGet (int SocketIndex, char * GroupStatusList) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_HUGE); /* Convert to string */ sprintf (ExecuteMethod, "GroupStatusListGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_HUGE); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -5162,6 +5634,9 @@ int __stdcall GroupStatusListGet (int SocketIndex, char * GroupStatusList) ptNext = strchr (GroupStatusList, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -5170,15 +5645,15 @@ int __stdcall GroupStatusListGet (int SocketIndex, char * GroupStatusList) int __stdcall HardwareInternalListGet (int SocketIndex, char * InternalHardwareList) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_NOMINAL); /* Convert to string */ sprintf (ExecuteMethod, "HardwareInternalListGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_NOMINAL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -5196,6 +5671,9 @@ int __stdcall HardwareInternalListGet (int SocketIndex, char * InternalHardwareL ptNext = strchr (InternalHardwareList, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -5204,15 +5682,15 @@ int __stdcall HardwareInternalListGet (int SocketIndex, char * InternalHardwareL int __stdcall HardwareDriverAndStageGet (int SocketIndex, int PlugNumber, char * DriverName, char * StageName) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_NOMINAL); /* Convert to string */ sprintf (ExecuteMethod, "HardwareDriverAndStageGet (%d,char *,char *)", PlugNumber); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_NOMINAL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -5235,6 +5713,9 @@ int __stdcall HardwareDriverAndStageGet (int SocketIndex, int PlugNumber, char * ptNext = strchr (StageName, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -5243,15 +5724,15 @@ int __stdcall HardwareDriverAndStageGet (int SocketIndex, int PlugNumber, char * int __stdcall ObjectsListGet (int SocketIndex, char * ObjectsList) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_HUGE); /* Convert to string */ sprintf (ExecuteMethod, "ObjectsListGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_HUGE); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -5269,6 +5750,9 @@ int __stdcall ObjectsListGet (int SocketIndex, char * ObjectsList) ptNext = strchr (ObjectsList, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -5277,15 +5761,15 @@ int __stdcall ObjectsListGet (int SocketIndex, char * ObjectsList) int __stdcall PositionerErrorListGet (int SocketIndex, char * PositionerErrorList) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_BIG); /* Convert to string */ sprintf (ExecuteMethod, "PositionerErrorListGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BIG); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -5303,6 +5787,9 @@ int __stdcall PositionerErrorListGet (int SocketIndex, char * PositionerErrorLis ptNext = strchr (PositionerErrorList, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -5311,15 +5798,15 @@ int __stdcall PositionerErrorListGet (int SocketIndex, char * PositionerErrorLis int __stdcall PositionerHardwareStatusListGet (int SocketIndex, char * PositionerHardwareStatusList) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_BIG); /* Convert to string */ sprintf (ExecuteMethod, "PositionerHardwareStatusListGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BIG); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -5337,6 +5824,9 @@ int __stdcall PositionerHardwareStatusListGet (int SocketIndex, char * Positione ptNext = strchr (PositionerHardwareStatusList, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -5345,15 +5835,15 @@ int __stdcall PositionerHardwareStatusListGet (int SocketIndex, char * Positione int __stdcall PositionerDriverStatusListGet (int SocketIndex, char * PositionerDriverStatusList) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_BIG); /* Convert to string */ sprintf (ExecuteMethod, "PositionerDriverStatusListGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BIG); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -5371,6 +5861,9 @@ int __stdcall PositionerDriverStatusListGet (int SocketIndex, char * PositionerD ptNext = strchr (PositionerDriverStatusList, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -5379,15 +5872,15 @@ int __stdcall PositionerDriverStatusListGet (int SocketIndex, char * PositionerD int __stdcall ReferencingActionListGet (int SocketIndex, char * list) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_BIG); /* Convert to string */ sprintf (ExecuteMethod, "ReferencingActionListGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BIG); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -5405,6 +5898,9 @@ int __stdcall ReferencingActionListGet (int SocketIndex, char * list) ptNext = strchr (list, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -5413,15 +5909,15 @@ int __stdcall ReferencingActionListGet (int SocketIndex, char * list) int __stdcall ReferencingSensorListGet (int SocketIndex, char * list) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_BIG); /* Convert to string */ sprintf (ExecuteMethod, "ReferencingSensorListGet (char *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BIG); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -5439,6 +5935,9 @@ int __stdcall ReferencingSensorListGet (int SocketIndex, char * list) ptNext = strchr (list, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -5447,15 +5946,15 @@ int __stdcall ReferencingSensorListGet (int SocketIndex, char * list) int __stdcall GatheringUserDatasGet (int SocketIndex, double * UserData1, double * UserData2, double * UserData3, double * UserData4, double * UserData5, double * UserData6, double * UserData7, double * UserData8) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "GatheringUserDatasGet (double *,double *,double *,double *,double *,double *,double *,double *)"); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -5492,6 +5991,9 @@ int __stdcall GatheringUserDatasGet (int SocketIndex, double * UserData1, double if (pt != NULL) pt++; if (pt != NULL) sscanf (pt, "%lf", UserData8); } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); } @@ -5500,15 +6002,15 @@ int __stdcall GatheringUserDatasGet (int SocketIndex, double * UserData1, double int __stdcall TestTCP (int SocketIndex, char * InputString, char * ReturnString) { int ret = -1; - char ExecuteMethod [SIZE_BUFFER]; - char ReturnedValue [SIZE_BUFFER]; + char ExecuteMethod[SIZE_NOMINAL]; + char *ReturnedValue = (char *) malloc (sizeof(char) * SIZE_SMALL); /* Convert to string */ sprintf (ExecuteMethod, "TestTCP (%s,char *)", InputString); /* Send this string and wait return function from controller */ /* return function : ==0 -> OK ; < 0 -> NOK */ - SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_BUFFER); + SendAndReceive (SocketIndex, ExecuteMethod, ReturnedValue, SIZE_SMALL); if (strlen (ReturnedValue) > 0) sscanf (ReturnedValue, "%i", &ret); @@ -5526,6 +6028,9 @@ int __stdcall TestTCP (int SocketIndex, char * InputString, char * ReturnString) ptNext = strchr (ReturnString, ','); if (ptNext != NULL) *ptNext = '\0'; } + if (NULL != ReturnedValue) + free (ReturnedValue); + return (ret); }