Răsfoiți Sursa

Cleans GetAttributeSingle from unused code

Signed-off-by: Martin Melik Merkumians <melik-merkumians@acin.tuwien.ac.at>
Martin Melik Merkumians 5 ani în urmă
părinte
comite
9f1d4dacf0

+ 4 - 17
source/src/cip/cipcommon.c

@@ -500,36 +500,23 @@ EipStatus GetAttributeSingle(CipInstance *RESTRICT const instance,
     message_router_request->request_path.attribute_number;
 
   if ( (NULL != attribute) && (NULL != attribute->data) ) {
-    uint8_t get_bit_mask = 0;
-    if (kGetAttributeAll == message_router_request->service) {
-      get_bit_mask =
-        (instance->cip_class->get_all_bit_mask[CalculateIndex(
-                                                 attribute_number)]);
-      message_router_response->general_status = kCipErrorSuccess;
-    } else {
-      get_bit_mask =
-        (instance->cip_class->get_single_bit_mask[CalculateIndex(
+    uint8_t get_bit_mask = (instance->cip_class->get_single_bit_mask[CalculateIndex(
                                                     attribute_number)]);
-    }
     if (0 != (get_bit_mask & (1 << (attribute_number % 8) ) ) ) {
       OPENER_TRACE_INFO("getAttribute %d\n",
                         message_router_request->request_path.attribute_number);                 /* create a reply message containing the data*/
 
       /* Call the PreGetCallback if enabled for this attribute and the class provides one. */
-      if (attribute->attribute_flags & kPreGetFunc && NULL != instance->cip_class->PreGetCallback) {
+      if ((attribute->attribute_flags & kPreGetFunc) && NULL != instance->cip_class->PreGetCallback) {
         instance->cip_class->PreGetCallback(instance, attribute, message_router_request->service);
       }
 
       OPENER_ASSERT(NULL != attribute)
-      if(NULL == attribute->encode) {
-    	  EncodeData(attribute->type, attribute->data, message_router_response);
-      } else {
-    	  attribute->encode(attribute->data, &message_router_response->message);
-      }
+      attribute->encode(attribute->data, &message_router_response->message);
       message_router_response->general_status = kCipErrorSuccess;
 
       /* Call the PostGetCallback if enabled for this attribute and the class provides one. */
-      if (attribute->attribute_flags & kPostGetFunc && NULL != instance->cip_class->PostGetCallback) {
+      if ((attribute->attribute_flags & kPostGetFunc) && NULL != instance->cip_class->PostGetCallback) {
         instance->cip_class->PostGetCallback(instance, attribute, message_router_request->service);
       }
     }

+ 1 - 2
source/src/cip/cipconnectionmanager.c

@@ -884,7 +884,7 @@ EipStatus AssembleForwardCloseResponse(
 
   message_router_response->reply_service = (0x80
                                             | message_router_request->service);
-  /* excepcted length is 10 if there is no application specific data */
+  /* Excepted length is 10 if there is no application specific data */
 
   if (kConnectionManagerExtendedStatusCodeSuccess == extended_error_code) {
     AddSintToMessage(0, &message_router_response->message); /* no application data */
@@ -901,7 +901,6 @@ EipStatus AssembleForwardCloseResponse(
     }
   }
 
-  // TODO: check if needed message++; seem superfluous with the new AddSint command above
   AddSintToMessage(0, &message_router_response->message); /* reserved */
 
   return kEipStatusOkSend;

+ 2 - 0
source/src/enet_encap/cpf.c

@@ -58,6 +58,7 @@ EipStatus NotifyCommonPacketFormat
             &g_message_router_response, &g_common_packet_format_data_item,
             outgoing_message);
 
+          /* Save pointer and move to start for Encapusulation Header */
           CipOctet *buffer = outgoing_message->current_message_position;
           outgoing_message->current_message_position =
             outgoing_message->message_buffer;
@@ -66,6 +67,7 @@ EipStatus NotifyCommonPacketFormat
                                       received_data->session_handle,
                                       kEncapsulationProtocolSuccess,
                                       outgoing_message);
+          /* Move pointer back to last octet */
           outgoing_message->current_message_position = buffer;
           return_value = kEipStatusOkSend;
         }