فهرست منبع

Changes cip_path parameter to recommended unsigned char, adds test for electronic key

CapXilinx 9 سال پیش
والد
کامیت
a3ca00af19
3فایلهای تغییر یافته به همراه82 افزوده شده و 71 حذف شده
  1. 19 19
      source/src/cip/cipepath.c
  2. 16 13
      source/src/cip/cipepath.h
  3. 47 39
      source/tests/cip/cipepathtest.cpp

+ 19 - 19
source/src/cip/cipepath.c

@@ -69,7 +69,7 @@ typedef enum {
 
 
 /*** Path Segment ***/
-SegmentType GetPathSegmentType(const char *const cip_path) {
+SegmentType GetPathSegmentType(const unsigned char *const cip_path) {
   const unsigned int kSegmentTypeMask = 0xE0;
   const unsigned int segment_type = *cip_path & kSegmentTypeMask;
   SegmentType result = kSegmentTypeReserved;
@@ -106,7 +106,7 @@ SegmentType GetPathSegmentType(const char *const cip_path) {
   return result;
 }
 
-void SetPathSegmentType(SegmentType segment_type, char *const cip_path) {
+void SetPathSegmentType(SegmentType segment_type, unsigned char *const cip_path) {
   switch (segment_type) {
     case kSegmentTypePortSegment:
       *cip_path |= SEGMENT_TYPE_PORT_SEGMENT_MESSAGE_VALUE;
@@ -139,7 +139,7 @@ void SetPathSegmentType(SegmentType segment_type, char *const cip_path) {
 }
 
 /*** Port Segment ***/
-bool GetPathPortSegmentExtendedLinkAddressSizeBit(const char *const cip_path) {
+bool GetPathPortSegmentExtendedLinkAddressSizeBit(const unsigned char *const cip_path) {
   const unsigned int kExtendedLinkAddressSizeMask = 0x10;
   if (kExtendedLinkAddressSizeMask == (*cip_path & kExtendedLinkAddressSizeMask) ) {
     return true;
@@ -147,7 +147,7 @@ bool GetPathPortSegmentExtendedLinkAddressSizeBit(const char *const cip_path) {
   return false;
 }
 
-unsigned int GetPathPortSegmentPortIdentifier(const char *const cip_path) {
+unsigned int GetPathPortSegmentPortIdentifier(const unsigned char *const cip_path) {
   const unsigned int kPortIdentifierMask = 0x0F;
   unsigned int port_identifier = *cip_path & kPortIdentifierMask;
 //  OPENER_ASSERT(0 != port_identifier, "Use of reserved port identifier 0\n");
@@ -157,7 +157,7 @@ unsigned int GetPathPortSegmentPortIdentifier(const char *const cip_path) {
 }
 
 void SetPathPortSegmentPortIdentifier(const unsigned int port_identifier,
-                                      char *const cip_path) {
+                                      unsigned char *const cip_path) {
 //  OPENER_ASSERT(
 //      port_identifier < 16,
 //      "Port identifier too large for standard port identifier field\n");
@@ -165,14 +165,14 @@ void SetPathPortSegmentPortIdentifier(const unsigned int port_identifier,
   (*cip_path) |= port_identifier;
 }
 
-unsigned int GetPathPortSegmentLinkAddressSize(const char *const cip_path) {
+unsigned int GetPathPortSegmentLinkAddressSize(const unsigned char *const cip_path) {
 //  OPENER_ASSERT(false == GetPathPortSegmentExtendedLinkAddressSizeBit(cip_path),
 //                "Call to non existent extended link address size\n");
   OPENER_ASSERT(true == GetPathPortSegmentExtendedLinkAddressSizeBit(cip_path));
   return *(cip_path + 1);
 }
 
-unsigned int GetPathPortSegmentExtendedPortNumber(const char *const cip_path) {
+unsigned int GetPathPortSegmentExtendedPortNumber(const unsigned char *const cip_path) {
 //  OPENER_ASSERT(kPortSegmentExtendedPort == GetPathPortSegmentPortIdentifier(cip_path),
 //                "There is no extended port available!\n");
   OPENER_ASSERT(kPortSegmentExtendedPort == GetPathPortSegmentPortIdentifier(cip_path));
@@ -183,7 +183,7 @@ unsigned int GetPathPortSegmentExtendedPortNumber(const char *const cip_path) {
 }
 
 void SetPathPortSegmentExtendedPortIdentifier(
-    const unsigned int extended_port_identifier, char *const cip_path) {
+    const unsigned int extended_port_identifier, unsigned char *const cip_path) {
   SetPathPortSegmentPortIdentifier(kPortSegmentExtendedPort, cip_path);
   const unsigned int kExtendedPortSegmentPosition =
       GetPathPortSegmentExtendedLinkAddressSizeBit(cip_path) == true ? 2 : 1;
@@ -197,7 +197,7 @@ void SetPathPortSegmentExtendedPortIdentifier(
 /*** Logical Segment ***/
 
 LogicalSegmentLogicalType GetPathLogicalSegmentLogicalType(
-    const char *const cip_path) {
+    const unsigned char *const cip_path) {
   OPENER_ASSERT(kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path));
   const unsigned int kLogicalTypeMask = 0x1C;
   const unsigned int logical_type = (*cip_path) & kLogicalTypeMask;
@@ -236,7 +236,7 @@ LogicalSegmentLogicalType GetPathLogicalSegmentLogicalType(
 }
 
 LogicalSegmentLogicalFormat GetPathLogicalSegmentLogicalFormat(
-    const char *const cip_path) {
+    const unsigned char *const cip_path) {
   OPENER_ASSERT(kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path));
   const unsigned int kLogicalFormatMask = 0x03;
   const unsigned int logical_format = (*cip_path) & kLogicalFormatMask;
@@ -259,7 +259,7 @@ LogicalSegmentLogicalFormat GetPathLogicalSegmentLogicalFormat(
   return result;
 }
 
-LogicalSegmentExtendedLogicalType GetPathLogicalSegmentExtendedLogicalType(const char *const cip_path) {
+LogicalSegmentExtendedLogicalType GetPathLogicalSegmentExtendedLogicalType(const unsigned char *const cip_path) {
 //  OPENER_ASSERT(LOGICAL_SEGMENT_TYPE_EXTENDED_kLogicalSegmentLogicalTypeExtendedLogicalMessageValue == GetPathLogicalSegmentLogicalType(cip_path),
 //                "Trying to extract non-existent extended logical type");
   OPENER_ASSERT(kLogicalSegmentLogicalTypeExtendedLogical == GetPathLogicalSegmentLogicalType(cip_path));
@@ -277,7 +277,7 @@ LogicalSegmentExtendedLogicalType GetPathLogicalSegmentExtendedLogicalType(const
   return result;
 }
 
-LogicalSegmentSpecialTypeLogicalFormat GetPathLogicalSegmentSpecialTypeLogicalType(const char *const cip_path) {
+LogicalSegmentSpecialTypeLogicalFormat GetPathLogicalSegmentSpecialTypeLogicalType(const unsigned char *const cip_path) {
 //  OPENER_ASSERT(kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path), "Not a logical segment!\n");
   OPENER_ASSERT(kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path));
   OPENER_ASSERT(kLogicalSegmentLogicalTypeSpecial == GetPathLogicalSegmentLogicalType(cip_path));
@@ -294,7 +294,7 @@ LogicalSegmentSpecialTypeLogicalFormat GetPathLogicalSegmentSpecialTypeLogicalTy
   return result;
 }
 
-ElectronicKeySegmentFormat GetPathLogicalSegmentElectronicKeyFormat(const char *const cip_path) {
+ElectronicKeySegmentFormat GetPathLogicalSegmentElectronicKeyFormat(const unsigned char *const cip_path) {
 //  OPENER_ASSERT(kLogicalSegmentSpecialTypeLogicalFormatElectronicKey ==
 //      GetPathLogicalSegmentSpecialTypeLogicalType(cip_path), "Not an electronic key!\n");
   OPENER_ASSERT(kLogicalSegmentSpecialTypeLogicalFormatElectronicKey ==
@@ -307,7 +307,7 @@ ElectronicKeySegmentFormat GetPathLogicalSegmentElectronicKeyFormat(const char *
   return result;
 }
 
-ElectronicKeyFormat4 *GetPathLogicalSegmentElectronicKeyFormat4(const char *const cip_path) {
+ElectronicKeyFormat4 *GetPathLogicalSegmentElectronicKeyFormat4(const unsigned char *const cip_path) {
 //  OPENER_ASSERT(kElectronicKeySegmentFormatKeyFormat4 ==
 //      GetPathLogicalSegmentElectronicKeyFormat(cip_path), "Not electronic key format 4!\n");
   OPENER_ASSERT(kElectronicKeySegmentFormatKeyFormat4 ==
@@ -334,7 +334,7 @@ ElectronicKeyFormat4 *GetPathLogicalSegmentElectronicKeyFormat4(const char *cons
  *  @param cip_path Pointer to the start of the EPath message
  *  @return The Network Segment subtype of the EPath
  */
-NetworkSegmentSubType GetPathNetworkSegmentSubtype(const char *const cip_path) {
+NetworkSegmentSubType GetPathNetworkSegmentSubtype(const unsigned char *const cip_path) {
   const unsigned int kSubtypeMask = 0x1F;
   const unsigned int subtype = (*cip_path) & kSubtypeMask;
   NetworkSegmentSubType result = kNetworkSegmentSubtypeReserved;
@@ -361,7 +361,7 @@ NetworkSegmentSubType GetPathNetworkSegmentSubtype(const char *const cip_path) {
  * @param cip_path Pointer to the start of the EPath message
  * @return the Production Inhibit Time in milliseconds ranging from 0 to 255
  */
-CipUsint GetPathNetworkSegmentProductionInhibitTimeInMilliseconds(const char *const cip_path) {
+CipUsint GetPathNetworkSegmentProductionInhibitTimeInMilliseconds(const unsigned char *const cip_path) {
 //  OPENER_ASSERT(kSegmentTypeNetworkSegment == GetPathSegmentType(cip_path),"Not a network segment!\n");
 //  OPENER_ASSERT(kNetworkSegmentSubtypeProductionInhibitTimeInMilliseconds == GetPathNetworkSegmentSubtype(cip_path),
 //                "Not a Production Inhibit Time milliseconds segment!\n");
@@ -376,7 +376,7 @@ CipUsint GetPathNetworkSegmentProductionInhibitTimeInMilliseconds(const char *co
  * @param cip_path Pointer to the start of the EPath message
  * @return the Production Inhibit Time in microseconds ranging from 0 to 4294967295
  */
-CipUdint GetPathNetworkSegmentProductionInhibitTimeInMicroseconds(const char *const cip_path) {
+CipUdint GetPathNetworkSegmentProductionInhibitTimeInMicroseconds(const unsigned char *const cip_path) {
 //  OPENER_ASSERT(kSegmentTypeNetworkSegment == GetPathSegmentType(cip_path),"Not a network segment!\n");
 //  OPENER_ASSERT(kNetworkSegmentSubtypeProductionInhibitTimeInMicroseconds == GetPathNetworkSegmentSubtype(cip_path),
 //                  "Not a Production Inhibit Time microseconds segment!\n");
@@ -400,7 +400,7 @@ CipUdint GetPathNetworkSegmentProductionInhibitTimeInMicroseconds(const char *co
 
 /*** Data Segment ***/
 
-DataSegmentSubtype GetPathDataSegmentSubtype(const char *const cip_path) {
+DataSegmentSubtype GetPathDataSegmentSubtype(const unsigned char *const cip_path) {
   const unsigned int kDataSegmentSubtypeMask = 0x1F;
   const unsigned int data_subtype = (*cip_path) & kDataSegmentSubtypeMask;
 
@@ -420,7 +420,7 @@ DataSegmentSubtype GetPathDataSegmentSubtype(const char *const cip_path) {
  * @param cip_path Pointer to the start of the EPath message
  * @return The amount of 16-bit words of data in the EPath
  */
-CipUsint GetPathDataSegmentSimpleDataWordLength(const char * const cip_path) {
+CipUsint GetPathDataSegmentSimpleDataWordLength(const unsigned char *const cip_path) {
 //  OPENER_ASSERT(kSegmentTypeDataSegment == GetPathSegmentType(cip_path),"Not a data segment!\n");
 //  OPENER_ASSERT(kDataSegmentSubtypeSimpleData == GetPathDataSegmentSubtype(cip_path), "Not a simple data segment!\n");
   OPENER_ASSERT(kSegmentTypeDataSegment == GetPathSegmentType(cip_path));

+ 16 - 13
source/src/cip/cipepath.h

@@ -10,6 +10,7 @@
 #include <stdbool.h>
 
 #include "ciptypes.h"
+#include "cipelectronickey.h"
 
 #define SEGMENT_TYPE_PORT_SEGMENT_MESSAGE_VALUE 0x00 /**< Message value of the Port segment */
 #define SEGMENT_TYPE_LOGICAL_SEGMENT_MESSAGE_VALUE 0x20 /**< Message value of the Logical segment */
@@ -65,33 +66,35 @@ typedef enum {
   kElectronicKeySegmentFormatKeyFormat4
 } ElectronicKeySegmentFormat;
 
-SegmentType GetPathSegmentType(const char *const cip_path);
+SegmentType GetPathSegmentType(const unsigned char *const cip_path);
 
-void SetPathSegmentType(SegmentType segment_type, char *const cip_path);
+void SetPathSegmentType(SegmentType segment_type, unsigned char *const cip_path);
 
-bool GetPathPortSegmentExtendedLinkAddressSizeBit(const char *const cip_path);
+bool GetPathPortSegmentExtendedLinkAddressSizeBit(const unsigned char *const cip_path);
 
-unsigned int GetPathPortSegmentPortIdentifier(const char *const cip_path);
+unsigned int GetPathPortSegmentPortIdentifier(const unsigned char *const cip_path);
 
 void SetPathPortSegmentPortIdentifier(const unsigned int port_identifier,
-                                      char *const cip_path);
+                                      unsigned char *const cip_path);
 
-unsigned int GetPathPortSegmentLinkAddressSize(const char *const cip_path);
+unsigned int GetPathPortSegmentLinkAddressSize(const unsigned char *const cip_path);
 
-unsigned int GetPathPortSegmentExtendedPortNumber(const char *const cip_path);
+unsigned int GetPathPortSegmentExtendedPortNumber(const unsigned char *const cip_path);
 
 void SetPathPortSegmentExtendedPortIdentifier(
-    const unsigned int extended_port_identifier, char *const cip_path);
+    const unsigned int extended_port_identifier, unsigned char *const cip_path);
 
-LogicalSegmentLogicalType GetPathLogicalSegmentLogicalType(const char *const cip_path);
+LogicalSegmentLogicalType GetPathLogicalSegmentLogicalType(const unsigned char *const cip_path);
 
 LogicalSegmentLogicalFormat GetPathLogicalSegmentLogicalFormat(
-    const char *const cip_path);
+    const unsigned char *const cip_path);
 
-LogicalSegmentExtendedLogicalType GetPathLogicalSegmentExtendedLogicalType(const char *const cip_path);
+LogicalSegmentExtendedLogicalType GetPathLogicalSegmentExtendedLogicalType(const unsigned char *const cip_path);
 
-LogicalSegmentSpecialTypeLogicalFormat GetPathLogicalSegmentSpecialTypeLogicalType(const char *const cip_path);
+LogicalSegmentSpecialTypeLogicalFormat GetPathLogicalSegmentSpecialTypeLogicalType(const unsigned char *const cip_path);
 
-ElectronicKeySegmentFormat GetPathLogicalSegmentElectronicKeyFormat(const char *const cip_path);
+ElectronicKeySegmentFormat GetPathLogicalSegmentElectronicKeyFormat(const unsigned char *const cip_path);
+
+ElectronicKeyFormat4 *GetPathLogicalSegmentElectronicKeyFormat4(const unsigned char *const cip_path);
 
 #endif /* SRC_CIP_CIPEPATH_H_ */

+ 47 - 39
source/tests/cip/cipepathtest.cpp

@@ -20,239 +20,247 @@ TEST_GROUP(CipEpath) {
 
 /** Segment type tests **/
 TEST(CipEpath, GetSegmentTypePortSegment) {
-  const char message[] = {0x00};
+  const unsigned char message[] = {0x00};
   SegmentType segment_type = GetPathSegmentType(message);
   CHECK_EQUAL(kSegmentTypePortSegment, segment_type);
 }
 
 TEST(CipEpath, GetSegmentTypeLogicalSegment) {
-  const char message[] = {0x20};
+  const unsigned char message[] = {0x20};
   SegmentType segment_type = GetPathSegmentType(message);
   CHECK_EQUAL(kSegmentTypeLogicalSegment, segment_type);
 }
 
 TEST(CipEpath, GetSegmentTypeNetworkSegment) {
-  const char message[] = {0x40};
+  const unsigned char message[] = {0x40};
   SegmentType segment_type = GetPathSegmentType(message);
   CHECK_EQUAL(kSegmentTypeNetworkSegment, segment_type);
 }
 
 TEST(CipEpath, GetSegmentTypeSymbolicSegment) {
-  const char message[] = {0x60};
+  const unsigned char message[] = {0x60};
   SegmentType segment_type = GetPathSegmentType(message);
   CHECK_EQUAL(kSegmentTypeSymbolicSegment, segment_type);
 }
 
 TEST(CipEpath, GetSegmentTypeDataSegment) {
-  const char message[] = {0x80};
+  const unsigned char message[] = {0x80};
   SegmentType segment_type = GetPathSegmentType(message);
   CHECK_EQUAL(kSegmentTypeDataSegment, segment_type);
 }
 
 TEST(CipEpath, GetSegmentTypeDataTypeConstructed) {
-  const char message[] = {0xA0};
+  const unsigned char message[] = {0xA0};
   SegmentType segment_type = GetPathSegmentType(message);
   CHECK_EQUAL(kSegmentTypeDataTypeConstructed, segment_type);
 }
 
 TEST(CipEpath, GetSegmentTypeDataTypeElementary) {
-  const char message[] = {0xC0};
+  const unsigned char message[] = {0xC0};
   SegmentType segment_type = GetPathSegmentType(message);
   CHECK_EQUAL(kSegmentTypeDataTypeElementary, segment_type);
 }
 
 TEST(CipEpath, GetSegmentTypeReserved) {
-  const char message[] = {0xE0};
+  const unsigned char message[] = {0xE0};
   SegmentType segment_type = GetPathSegmentType(message);
   CHECK_EQUAL(kSegmentTypeReserved, segment_type);
 }
 
 /** Port segment tests **/
 TEST(CipEpath, GetPortSegmentExtendedAddressSizeTrue) {
-  const char message[] = {0x10};
+  const unsigned char message[] = {0x10};
   bool extended_address = GetPathPortSegmentExtendedLinkAddressSizeBit(message);
   CHECK_EQUAL(true, extended_address);
 }
 
 TEST(CipEpath, GetPortSegmentExtendedAddressSizeFalse) {
-  const char message[] = {0x00};
+  const unsigned char message[] = {0x00};
   bool extended_address = GetPathPortSegmentExtendedLinkAddressSizeBit(message);
   CHECK_EQUAL(false, extended_address);
 }
 
 TEST(CipEpath, GetPortSegmentPortIdentifier) {
-  const char message[] = {0x0F};
+  const unsigned char message[] = {0x0F};
   unsigned int port = GetPathPortSegmentPortIdentifier(message);
   unsigned int mes = (unsigned int)(message[0]);
   CHECK_EQUAL(15, mes);
 }
 
 TEST(CipEpath, SetPortSegmentPortIdentifier) {
-  char message[] = {0x00};
+  unsigned char message[] = {0x00};
   SetPathPortSegmentPortIdentifier(15, message);
   CHECK_EQUAL(15, (unsigned int)(message[0]));
 }
 
 TEST(CipEpath, GetPortSegmentLinkAddressSize) {
-  const char message[] = {0x10,0x04};
+  const unsigned char message[] = {0x10,0x04};
   unsigned int size = GetPathPortSegmentLinkAddressSize(message);
   CHECK_EQUAL(4, size);
 }
 
 TEST(CipEpath, GetPortSegmentExtendedPortNumberNoExtendedAddress) {
-  const char message[] = {0x0F, 0x22, 0x64};
+  const unsigned char message[] = {0x0F, 0x22, 0x64};
   unsigned int extended_port = GetPathPortSegmentExtendedPortNumber(message);
   CHECK_EQUAL(25634, extended_port);
 }
 
 TEST(CipEpath, GetPortSegmentExtendedPortNumberWithExtendedAddress) {
-  const char message[] = {0x1F, 0x00, 0x22, 0x64};
+  const unsigned char message[] = {0x1F, 0x00, 0x22, 0x64};
   unsigned int extended_port = GetPathPortSegmentExtendedPortNumber(message);
   CHECK_EQUAL(25634, extended_port);
 }
 
 TEST(CipEpath, SetPortSegmentExtendedPortNoExtendedAddress) {
-  char message[] = {0x00, 0x00, 0x00};
+  unsigned char message[] = {0x00, 0x00, 0x00};
   const char expected_message[] = {0x0F, 0x22, 0x64};
   SetPathPortSegmentExtendedPortIdentifier((unsigned int)25634, message);
   MEMCMP_EQUAL(expected_message, message, 3);
 }
 
 TEST(CipEpath, SetPortSegmentExtendedPortWithExtendedAddress) {
-  char message[] = {0x10, 0x00, 0x00, 0x00};
+  unsigned char message[] = {0x10, 0x00, 0x00, 0x00};
   const char expected_message[] = {0x1F, 0x00, 0x22, 0x64};
   SetPathPortSegmentExtendedPortIdentifier((unsigned int)25634, message);
   MEMCMP_EQUAL(expected_message, message, 4);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalTypeClassId) {
-  const char message[] = {0x20};
+  const unsigned char message[] = {0x20};
   const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentLogicalTypeClassId, type);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalTypeInstanceId) {
-  const char message[] = {0x24};
+  const unsigned char message[] = {0x24};
   const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentLogicalTypeInstanceId, type);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalTypeMemberId) {
-  const char message[] = {0x28};
+  const unsigned char message[] = {0x28};
   const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentLogicalTypeMemberId, type);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalTypeConnectionPoint) {
-  const char message[] = {0x2C};
+  const unsigned char message[] = {0x2C};
   const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentLogicalTypeConnectionPoint, type);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalTypeAttributeId) {
-  const char message[] = {0x30};
+  const unsigned char message[] = {0x30};
   const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentLogicalTypeAttributeId, type);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalTypeSpecial) {
-  const char message[] = {0x34};
+  const unsigned char message[] = {0x34};
   const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentLogicalTypeSpecial, type);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalTypeServiceId) {
-  const char message[] = {0x38};
+  const unsigned char message[] = {0x38};
   const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentLogicalTypeServiceId, type);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalTypeExtendedLogical) {
-  const char message[] = {0x3C};
+  const unsigned char message[] = {0x3C};
   const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentLogicalTypeExtendedLogical, type);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalFormatEightBits) {
-  const char message[] = {0x20};
+  const unsigned char message[] = {0x20};
   const LogicalSegmentLogicalFormat format = GetPathLogicalSegmentLogicalFormat(message);
   CHECK_EQUAL(kLogicalSegmentLogicalFormatEightBit, format);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalFormatSixteenBits) {
-  const char message[] = {0x21};
+  const unsigned char message[] = {0x21};
   const LogicalSegmentLogicalFormat format = GetPathLogicalSegmentLogicalFormat(message);
   CHECK_EQUAL(kLogicalSegmentLogicalFormatSixteenBit, format);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalFormatThirtyTwoBits) {
-  const char message[] = {0x22};
+  const unsigned char message[] = {0x22};
   const LogicalSegmentLogicalFormat format = GetPathLogicalSegmentLogicalFormat(message);
   CHECK_EQUAL(kLogicalSegmentLogicalFormatThirtyTwoBit, format);
 }
 
 TEST(CipEpath, GetLogicalSegmentExtendedLogicalTypeReserved) {
-  const char message[] = {0x3C, 0x00};
+  const unsigned char message[] = {0x3C, 0x00};
   const LogicalSegmentExtendedLogicalType extended_type = GetPathLogicalSegmentExtendedLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentExtendedLogicalTypeReserved, extended_type);
 }
 
 TEST(CipEpath, GetLogicalSegmentExtendedLogicalTypeArrayIndex) {
-  const char message[] = {0x3C, 0x01};
+  const unsigned char message[] = {0x3C, 0x01};
   const LogicalSegmentExtendedLogicalType extended_type = GetPathLogicalSegmentExtendedLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentExtendedLogicalTypeArrayIndex, extended_type);
 }
 
 TEST(CipEpath, GetLogicalSegmentExtendedLogicalTypeIndirectArrayIndex) {
-  const char message[] = {0x3C, 0x02};
+  const unsigned char message[] = {0x3C, 0x02};
   const LogicalSegmentExtendedLogicalType extended_type = GetPathLogicalSegmentExtendedLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentExtendedLogicalTypeIndirectArrayIndex, extended_type);
 }
 
 TEST(CipEpath, GetLogicalSegmentExtendedLogicalTypeBitIndex) {
-  const char message[] = {0x3C, 0x03};
+  const unsigned char message[] = {0x3C, 0x03};
   const LogicalSegmentExtendedLogicalType extended_type = GetPathLogicalSegmentExtendedLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentExtendedLogicalTypeBitIndex, extended_type);
 }
 
 TEST(CipEpath, GetLogicalSegmentExtendedLogicalTypeIndirectBitIndex) {
-  const char message[] = {0x3C, 0x04};
+  const unsigned char message[] = {0x3C, 0x04};
   const LogicalSegmentExtendedLogicalType extended_type = GetPathLogicalSegmentExtendedLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentExtendedLogicalTypeIndirectBitIndex, extended_type);
 }
 
 TEST(CipEpath, GetLogicalSegmentExtendedLogicalTypeStructureMemberNumber) {
-  const char message[] = {0x3C, 0x05};
+  const unsigned char message[] = {0x3C, 0x05};
   const LogicalSegmentExtendedLogicalType extended_type = GetPathLogicalSegmentExtendedLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentExtendedLogicalTypeStructureMemberNumber, extended_type);
 }
 
 TEST(CipEpath, GetLogicalSegmentExtendedLogicalTypeStructureMemberHandle) {
-  const char message[] = {0x3C, 0x06};
+  const unsigned char message[] = {0x3C, 0x06};
   const LogicalSegmentExtendedLogicalType extended_type = GetPathLogicalSegmentExtendedLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentExtendedLogicalTypeStructureMemberHandle, extended_type);
 }
 
 TEST(CipEpath, GetLogicalSegmentSpecialTypeLogicalTypeReserved) {
-  const char message[] = {0x35};
+  const unsigned char message[] = {0x35};
   LogicalSegmentSpecialTypeLogicalFormat special_type = GetPathLogicalSegmentSpecialTypeLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentSpecialTypeLogicalFormatReserved, special_type);
 }
 
 TEST(CipEpath, GetLogicalSegmentSpecialTypeLogicalTypeElectronicKey) {
-  const char message[] = {0x34};
+  const unsigned char message[] = {0x34};
   LogicalSegmentSpecialTypeLogicalFormat special_type = GetPathLogicalSegmentSpecialTypeLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentSpecialTypeLogicalFormatElectronicKey, special_type);
 }
 
 TEST(CipEpath, GetPathLogicalSegmentElectronicKeyFormatReserved) {
-  const char message[] = {0x34, 0x00};
+  const unsigned char message[] = {0x34, 0x00};
   ElectronicKeySegmentFormat key_format = GetPathLogicalSegmentElectronicKeyFormat(message);
   CHECK_EQUAL(kElectronicKeySegmentFormatReserved, key_format);
 }
 
 TEST(CipEpath, GetPathLogicalSegmentElectronicKeyFormat4) {
-  const char message[] = {0x34, 0x04};
+  const unsigned char message[] = {0x34, 0x04};
   ElectronicKeySegmentFormat key_format = GetPathLogicalSegmentElectronicKeyFormat(message);
   CHECK_EQUAL(kElectronicKeySegmentFormatKeyFormat4, key_format);
 }
+
+TEST(CipEpath, GetLogicalSegmentElectronicKeyFormat4) {
+  const unsigned char message[] = {0x34,0x04};
+  ElectronicKeyFormat4 *electronic_key = GetPathLogicalSegmentElectronicKeyFormat4(message);
+
+  //TODO: check on how to free in CppuTest
+  //free(electronic_key);
+}