Parcourir la source

cip: support for setting Device Type and Product Code at runtime

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Joachim Wiberg il y a 3 ans
Parent
commit
160998e9ce
2 fichiers modifiés avec 24 ajouts et 0 suppressions
  1. 10 0
      source/src/cip/cipidentity.c
  2. 14 0
      source/src/opener_api.h

+ 10 - 0
source/src/cip/cipidentity.c

@@ -65,6 +65,16 @@ void SetDeviceSerialNumber(const EipUint32 serial_number) {
   g_identity.serial_number = serial_number;
 }
 
+/* The Doxygen comment is with the function's prototype in opener_api.h. */
+void SetDeviceType(const EipUint16 type) {
+  g_identity.device_type = type;
+}
+
+/* The Doxygen comment is with the function's prototype in opener_api.h. */
+void SetDeviceProductCode(const EipUint16 code) {
+  g_identity.product_code = code;
+}
+
 /* The Doxygen comment is with the function's prototype in opener_api.h. */
 void SetDeviceStatus(const CipWord status) {
   g_identity.status = status;

+ 14 - 0
source/src/opener_api.h

@@ -87,6 +87,20 @@ void SetDeviceRevision(EipUint8 major, EipUint8 minor);
  */
 void SetDeviceSerialNumber(const EipUint32 serial_number);
 
+/** @ingroup CIP_API
+ * @brief Set the DeviceType of the device's identity object.
+ *
+ * @param type 16 bit unsigned number representing the CIP device type
+ */
+void SetDeviceType(const EipUint16 type);
+
+/** @ingroup CIP_API
+ * @brief Set the ProductCode of the device's identity object.
+ *
+ * @param type 16 bit unsigned number representing the product code
+ */
+void SetDeviceProductCode(const EipUint16 code);
+
 /** @ingroup CIP_API
  * @brief Set the device's Status word also updating the Extended Device Status
  *