Quellcode durchsuchen

requested changes for pull request #355

micsat vor 4 Jahren
Ursprung
Commit
edd2bfb369

+ 6 - 7
source/src/cip/cipcommon.c

@@ -1289,7 +1289,7 @@ int DecodePaddedEPath(CipEpath *epath,
   return number_of_decoded_elements * 2 + 1; /* number_of_decoded_elements times 2 as every encoding uses 2 bytes */
 }
 
-EipStatus Create(CipInstance *RESTRICT const instance,
+EipStatus CipCreateService(CipInstance *RESTRICT const instance,
                              CipMessageRouterRequest *const message_router_request,
                              CipMessageRouterResponse *const message_router_response,
                              const struct sockaddr *originator_address,
@@ -1322,7 +1322,7 @@ EipStatus Create(CipInstance *RESTRICT const instance,
   return kEipStatusOkSend;
 }
 
-EipStatus Delete(CipInstance *RESTRICT const instance,
+EipStatus CipDeleteService(CipInstance *RESTRICT const instance,
                  CipMessageRouterRequest *const message_router_request,
                  CipMessageRouterResponse *const message_router_response,
                  const struct sockaddr *originator_address,
@@ -1352,8 +1352,7 @@ EipStatus Delete(CipInstance *RESTRICT const instance,
         instance->instance_number) {  // if instance to delete is head
       class->instances = instances->next;
     } else {
-      while (NULL !=
-             instances->next)  // as long as what next points to is not zero
+      while (NULL != instances->next)  // as long as pointer in not NULL
       {
         CipInstance *next_instance = instances->next;
         if (next_instance->instance_number == instance->instance_number) {
@@ -1366,7 +1365,7 @@ EipStatus Delete(CipInstance *RESTRICT const instance,
     // free all allocated attributes of instance
     CipAttributeStruct *attribute =
         instance->attributes; /* init pointer to array of attributes*/
-    for (int i = 0; i < instance->cip_class->number_of_attributes; i++) {
+    for (EipUint16 i = 0; i < instance->cip_class->number_of_attributes; i++) {
       CipFree(attribute->data);
       ++attribute;
     }
@@ -1382,7 +1381,7 @@ EipStatus Delete(CipInstance *RESTRICT const instance,
                       instance->instance_number);
     CipFree(instance);  // delete instance
 
-    class->number_of_instances -= 1; /* update the total number of instances
+    class->number_of_instances--; /* update the total number of instances
                                             recorded by the class - Attr. 3 */
 
     // update largest instance number (class Attribute 2)
@@ -1398,7 +1397,7 @@ EipStatus Delete(CipInstance *RESTRICT const instance,
   return kEipStatusOk;
 }
 
-EipStatus Reset(CipInstance *RESTRICT const instance,
+EipStatus CipResetService(CipInstance *RESTRICT const instance,
                 CipMessageRouterRequest *const message_router_request,
                 CipMessageRouterResponse *const message_router_response,
                 const struct sockaddr *originator_address,

+ 6 - 6
source/src/cip/cipcommon.h

@@ -145,7 +145,7 @@ EipStatus SetAttributeList(CipInstance *instance,
 int DecodePaddedEPath(CipEpath *epath,
                       const EipUint8 **message);
 
-/** @brief Generic implementation of the Create CIP service
+/** @brief Generic implementation of the CIP Create service
  *
  *  Creates dynamically allocated object instance within the specified class.
  *
@@ -157,7 +157,7 @@ int DecodePaddedEPath(CipEpath *epath,
  * @return status  >0 .. success
  *          -1 .. requested instance not created
  */
-EipStatus Create(
+EipStatus CipCreateService(
     CipInstance *RESTRICT const instance,
     CipMessageRouterRequest *const
         message_router_request,
@@ -166,7 +166,7 @@ EipStatus Create(
     const struct sockaddr *originator_address,
     const int encapsulation_session);
 
-/** @brief Generic implementation of the Delete CIP service
+/** @brief Generic implementation of the CIP Delete service
  *
  *  Deletes dynamically allocated object instance within the specified class
  *  and updates referred class attributes
@@ -179,7 +179,7 @@ EipStatus Create(
  * @return status  >0 .. success
  *          -1 .. requested instance not deleted
  */
-EipStatus Delete(CipInstance *RESTRICT const instance,
+EipStatus CipDeleteService(CipInstance *RESTRICT const instance,
     CipMessageRouterRequest *const
         message_router_request,
     CipMessageRouterResponse *const
@@ -187,7 +187,7 @@ EipStatus Delete(CipInstance *RESTRICT const instance,
     const struct sockaddr *originator_address,
     const int encapsulation_session);
 
-/** @brief Generic implementation of the Reset CIP service
+/** @brief Generic implementation of the CIP Reset service
  *
  *  Causes a transition to a default state or mode of
  *  the object instance within the specified class
@@ -201,7 +201,7 @@ EipStatus Delete(CipInstance *RESTRICT const instance,
  * @return status  >0 .. success
  *          -1 .. requested instance not reseted
  */
-EipStatus Reset(CipInstance *RESTRICT const instance,
+EipStatus CipResetService(CipInstance *RESTRICT const instance,
     CipMessageRouterRequest *const
         message_router_request,
     CipMessageRouterResponse *const

+ 1 - 1
source/src/cip/cipidentity.c

@@ -246,7 +246,7 @@ EipStatus CipIdentityInit() {
                 &GetAttributeSingle,
                 "GetAttributeSingle");
   InsertService(class, kGetAttributeAll, &GetAttributeAll, "GetAttributeAll");
-  InsertService(class, kReset, &Reset, "Reset");
+  InsertService(class, kReset, &CipResetService, "Reset");
   InsertService(class, kGetAttributeList, &GetAttributeList,
                 "GetAttributeList");
   InsertService(class, kSetAttributeList, &SetAttributeList,

+ 1 - 1
source/src/cip/ciptypes.h

@@ -357,7 +357,7 @@ typedef struct cip_class {
   /* the rest of these are specific to the Class class only. */
   CipUdint class_code;   /**< class code */
   EipUint16 revision;   /**< class revision*/
-  EipUint16 max_instance;   /** largest instance number existing in the class */
+  EipUint16 max_instance;   /**< largest instance number existing in the class */
   EipUint16 number_of_instances;   /**< number of instances in the class (not
                                       including instance 0) */
   EipUint16 number_of_attributes;   /**< number of attributes of each instance */