xme_status_t doMarshalingForLogin_pnpLoginResponse ( xme_core_dataManager_dataPacketId_t inputPort, void* buffer ) { xme_core_topic_login_pnpLoginResponse_t topicData; unsigned int topicDataSize; unsigned int bytesRead; uint8_t* bufferPtr; xme_status_t status; topicDataSize = sizeof(xme_core_topic_login_pnpLoginResponse_t); // Read topic data status = xme_core_dataHandler_readData ( inputPort, &topicData, topicDataSize, &bytesRead ); XME_CHECK(status == XME_STATUS_SUCCESS, XME_STATUS_INTERNAL_ERROR); XME_CHECK(bytesRead == topicDataSize, XME_STATUS_INTERNAL_ERROR); // Marshal topic data bufferPtr = (uint8_t*)buffer; // uint32_t topicData.nodeId { uint32_t netValue; netValue = xme_hal_net_htonl((uint32_t)topicData.nodeId); (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint32_t)); bufferPtr += sizeof(uint32_t); } // uint32_t topicData.ipAddress { uint32_t netValue; netValue = xme_hal_net_htonl((uint32_t)topicData.ipAddress); (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint32_t)); bufferPtr += sizeof(uint32_t); } // uint16_t topicData.portAddress { uint16_t netValue; netValue = xme_hal_net_htons((uint16_t)topicData.portAddress); (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint16_t)); bufferPtr += sizeof(uint16_t); } return XME_STATUS_SUCCESS; }
xme_status_t sensorMonitor_adv_monitorB_monitorBComponentWrapper_readPortSensorValueIn ( const sensorMonitor_topic_sensorData_t* data ) { uint8_t inputPortIndex; unsigned int bytesRead; xme_status_t status; #ifdef XME_MULTITHREAD char* accessed; #endif // #ifdef XME_MULTITHREAD XME_CHECK(NULL != data, XME_STATUS_INVALID_PARAMETER); inputPortIndex = (uint8_t)SENSORMONITOR_ADV_MONITORB_MONITORBCOMPONENTWRAPPER_PORT_SENSORVALUEIN; #ifdef XME_MULTITHREAD XME_ASSERT(inputPortAccessed != XME_HAL_TLS_INVALID_TLS_HANDLE); accessed = (char*) xme_hal_tls_get(inputPortAccessed); XME_ASSERT(NULL != accessed); if (!(accessed[inputPortIndex / 8U] & (1 << (inputPortIndex % 8U)))) #else // #ifdef XME_MULTITHREAD if (!inputPorts[inputPortIndex].state.locked) #endif // #ifdef XME_MULTITHREAD { status = xme_core_dataHandler_startReadOperation(inputPorts[inputPortIndex].dataPacketId); XME_CHECK(XME_STATUS_SUCCESS == status, XME_STATUS_INTERNAL_ERROR); #ifdef XME_MULTITHREAD accessed[inputPortIndex / 8U] |= (1 << (inputPortIndex % 8U)); #endif // #ifdef XME_MULTITHREAD inputPorts[inputPortIndex].state.locked = 1; } status = xme_core_dataHandler_readData ( inputPorts[inputPortIndex].dataPacketId, (void*)data, (uint32_t)sizeof(sensorMonitor_topic_sensorData_t), &bytesRead ); if (XME_STATUS_SUCCESS == status) { inputPorts[inputPortIndex].state.dataValid = 1; } else { inputPorts[inputPortIndex].state.error = 1; } return status; }
xme_status_t detector_adv_logger_loggerComponentWrapper_readPortInfo ( const detector_topic_device_info_t* data ) { uint8_t inputPortIndex; unsigned int bytesRead; xme_status_t status; #ifdef XME_MULTITHREAD char* accessed; #endif // #ifdef XME_MULTITHREAD XME_CHECK(NULL != data, XME_STATUS_INVALID_PARAMETER); inputPortIndex = (uint8_t)DETECTOR_ADV_LOGGER_LOGGERCOMPONENTWRAPPER_PORT_INFO; #ifdef XME_MULTITHREAD XME_ASSERT(inputPortAccessed != XME_HAL_TLS_INVALID_TLS_HANDLE); accessed = (char*) xme_hal_tls_get(inputPortAccessed); XME_ASSERT(NULL != accessed); if (!(accessed[inputPortIndex / 8U] & (1 << (inputPortIndex % 8U)))) #else // #ifdef XME_MULTITHREAD if (!inputPorts[inputPortIndex].state.locked) #endif // #ifdef XME_MULTITHREAD { status = xme_core_dataHandler_startReadOperation(inputPorts[inputPortIndex].dataPacketId); XME_CHECK(XME_STATUS_SUCCESS == status, XME_STATUS_INTERNAL_ERROR); #ifdef XME_MULTITHREAD accessed[inputPortIndex / 8U] |= (1 << (inputPortIndex % 8U)); #endif // #ifdef XME_MULTITHREAD inputPorts[inputPortIndex].state.locked = 1; } status = xme_core_dataHandler_readData ( inputPorts[inputPortIndex].dataPacketId, (void*)data, (uint32_t)sizeof(detector_topic_device_info_t), &bytesRead ); if (XME_STATUS_SUCCESS == status) { inputPorts[inputPortIndex].state.dataValid = 1; } else { inputPorts[inputPortIndex].state.error = 1; } return status; }
xme_status_t doMarshalingForWriteText ( xme_core_dataManager_dataPacketId_t inputPort, void* buffer ) { chromosomeGui_topic_WriteText_t topicData; unsigned int topicDataSize; unsigned int bytesRead; uint8_t* bufferPtr; xme_status_t status; topicDataSize = sizeof(chromosomeGui_topic_WriteText_t); // Read topic data status = xme_core_dataHandler_readData ( inputPort, &topicData, topicDataSize, &bytesRead ); XME_CHECK(status == XME_STATUS_SUCCESS, XME_STATUS_INTERNAL_ERROR); XME_CHECK(bytesRead == topicDataSize, XME_STATUS_INTERNAL_ERROR); // Marshal topic data bufferPtr = (uint8_t*)buffer; // char topicData.text { uint16_t i0; for (i0 = 0; i0 < 1000; i0++) { // char topicData.text[i0] xme_hal_mem_copy(bufferPtr, &topicData.text[i0], sizeof(char)); bufferPtr += sizeof(char); } } return XME_STATUS_SUCCESS; }
xme_status_t doMarshalingForTopic0 ( xme_core_dataManager_dataPacketId_t inputPort, void* buffer ) { xme_wp_deMarshalerTest_topic_topic0_t topicData; unsigned int topicDataSize; unsigned int bytesRead; uint8_t* bufferPtr; xme_status_t status; topicDataSize = sizeof(xme_wp_deMarshalerTest_topic_topic0_t); // Read topic data status = xme_core_dataHandler_readData ( inputPort, &topicData, topicDataSize, &bytesRead ); XME_CHECK(status == XME_STATUS_SUCCESS, XME_STATUS_INTERNAL_ERROR); XME_CHECK(bytesRead == topicDataSize, XME_STATUS_INTERNAL_ERROR); // Marshal topic data bufferPtr = (uint8_t*)buffer; // uint32_t topicData.test { uint32_t netValue; netValue = xme_hal_net_htonl((uint32_t)topicData.test); (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint32_t)); bufferPtr += sizeof(uint32_t); } return XME_STATUS_SUCCESS; }
xme_status_t autopnp_adv_cleaningGui_cleaningGuiComponentWrapper_readPortImageIn ( autopnp_topic_image_t* data ) { uint8_t portIndex; unsigned int bytesRead; xme_status_t returnValue; portIndex = 0; returnValue = xme_core_dataHandler_readData ( ports[portIndex], (void*) data, sizeof(autopnp_topic_image_t), &bytesRead ); return returnValue; }
xme_status_t doMarshalingForButtonSignal ( xme_core_dataManager_dataPacketId_t inputPort, void* buffer ) { chromosomeGui_topic_ButtonSignal_t topicData; unsigned int topicDataSize; unsigned int bytesRead; uint8_t* bufferPtr; xme_status_t status; topicDataSize = sizeof(chromosomeGui_topic_ButtonSignal_t); // Read topic data status = xme_core_dataHandler_readData ( inputPort, &topicData, topicDataSize, &bytesRead ); XME_CHECK(status == XME_STATUS_SUCCESS, XME_STATUS_INTERNAL_ERROR); XME_CHECK(bytesRead == topicDataSize, XME_STATUS_INTERNAL_ERROR); // Marshal topic data bufferPtr = (uint8_t*)buffer; // char topicData.buttonPushed xme_hal_mem_copy(bufferPtr, &topicData.buttonPushed, sizeof(char)); bufferPtr += sizeof(char); return XME_STATUS_SUCCESS; }
xme_status_t doMarshalingForPnpManager_runtime_graph_model3 ( xme_core_dataManager_dataPacketId_t inputPort, void* buffer ) { xme_core_topic_pnpManager_runtime_graph_model3_t topicData; unsigned int topicDataSize; unsigned int bytesRead; uint8_t* bufferPtr; xme_status_t status; topicDataSize = sizeof(xme_core_topic_pnpManager_runtime_graph_model3_t); // Read topic data status = xme_core_dataHandler_readData ( inputPort, &topicData, topicDataSize, &bytesRead ); XME_CHECK(status == XME_STATUS_SUCCESS, XME_STATUS_INTERNAL_ERROR); XME_CHECK(bytesRead == topicDataSize, XME_STATUS_INTERNAL_ERROR); // Marshal topic data bufferPtr = (uint8_t*)buffer; // uint16_t topicData.nodeId { uint16_t netValue; netValue = xme_hal_net_htons((uint16_t)topicData.nodeId); xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint16_t)); bufferPtr += sizeof(uint16_t); } // struct topicData.vertex { uint8_t i0; for (i0 = 0; i0 < 10; i0++) { // struct topicData.vertex[i0] { // uint8_t topicData.vertex[i0].vertexType { uint8_t netValue; netValue = (uint8_t)topicData.vertex[i0].vertexType; xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint8_t)); bufferPtr += sizeof(uint8_t); } // char topicData.vertex[i0].vertexData { uint16_t i1; for (i1 = 0; i1 < 256; i1++) { // char topicData.vertex[i0].vertexData[i1] xme_hal_mem_copy(bufferPtr, &topicData.vertex[i0].vertexData[i1], sizeof(char)); bufferPtr += sizeof(char); } } // uint32_t topicData.vertex[i0].instanceId { uint32_t netValue; netValue = xme_hal_net_htonl((uint32_t)topicData.vertex[i0].instanceId); xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint32_t)); bufferPtr += sizeof(uint32_t); } } } } // struct topicData.edge { uint8_t i0; for (i0 = 0; i0 < 10; i0++) { // struct topicData.edge[i0] { // int8_t topicData.edge[i0].srcVertexIndex { uint8_t netValue; netValue = (uint8_t)topicData.edge[i0].srcVertexIndex; xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint8_t)); bufferPtr += sizeof(uint8_t); } // int8_t topicData.edge[i0].sinkVertexIndex { uint8_t netValue; netValue = (uint8_t)topicData.edge[i0].sinkVertexIndex; xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint8_t)); bufferPtr += sizeof(uint8_t); } // uint8_t topicData.edge[i0].edgeType { uint8_t netValue; netValue = (uint8_t)topicData.edge[i0].edgeType; xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint8_t)); bufferPtr += sizeof(uint8_t); } // char topicData.edge[i0].edgeData { uint8_t i1; for (i1 = 0; i1 < 32; i1++) { // char topicData.edge[i0].edgeData[i1] xme_hal_mem_copy(bufferPtr, &topicData.edge[i0].edgeData[i1], sizeof(char)); bufferPtr += sizeof(char); } } } } } return XME_STATUS_SUCCESS; }
TEST_F(DataHandlerTestProbeSmokeTest, InitialTest) { // TODO: Remove when changing the API. uint32_t bytesRead; uint32_t bytesWritten; // Purspose of the test: // A full lifecycle of read/write operations, combining both TestProbe and Applications. // // Preconditions: // As DataHandler design provides two interfaces (named DataHandler.h and DataHandlerAdvanced.h) // They will be used as follows: // - DataHandler.h will be used by the Applications. // - DataHandlerTest.h will be used by the TestProbe. // // Steps in this test: // Step 1: // Perform a write operation over a data packet from an application and read that value. // Step 2: // Write from TestProbe the shadow database and activate the shadow data packet. // Step 3: // Application: Read again the data packet. The read value should be the one written by the TestProbe. // Step 4: // Read from TestProbe in shadow database (read in master database is allowed, but theoretically, not used). // Take into account that TestProbe can use less bytes than the topic size (to check). // Step 5: // Write from TestProbe in both databases different values. // Step 6: // Read from standard application. This operation will read the value written by the TestProbe in Step 5 // from shadow database. // Step 7: // Activate the master database (aka deactivate the shadow database). // Step 8: // Read from standard application. This operation will read the value written by the TestProbe in Step 5 // from master database. // Step 9: // Read from TestProbe both from Master Database and from Shadow Database. // Database Status (before Step 1) // // ------------------------ // DP1 | 0 | 0 | // ------------------------ // Master(1)* Shadow(2) // Step 1: // Perform a write operation over a data packet from an application and read that value. { int32_t readDataDP1; // Start write operation (DP1). ASSERT_EQ(XME_STATUS_SUCCESS, xme_core_dataHandler_startWriteOperation(dataPacketID1)); // Write (from Application) ASSERT_EQ(XME_STATUS_SUCCESS, xme_core_dataHandler_writeData(dataPacketID1, &masterFirstWrittenData, sizeof(masterFirstWrittenData))); // Complete write operation (DP1). ASSERT_EQ(XME_STATUS_SUCCESS, xme_core_dataHandler_completeWriteOperation(dataPacketID1)); // Read DP1 (from Application). ASSERT_EQ(XME_STATUS_SUCCESS, xme_core_dataHandler_readData(dataPacketID1, &readDataDP1, sizeof(readDataDP1), &bytesRead)); EXPECT_EQ(sizeof(readDataDP1), bytesRead); EXPECT_EQ(masterFirstWrittenData, readDataDP1); } // Database Status (before Step 2) // // ------------------------ // DP1 | 1234 | 0 | // ------------------------ // Master(1)* Shadow(2) // Step 2: // Write from TestProbe the shadow database and activate the shadow data packet. { // Write (from TestProbe in Shadow Database (2)) ASSERT_EQ(XME_STATUS_SUCCESS, xme_core_dataHandlerTestProbe_writeDataInDatabase(DB_SHADOW, dataPacketID1, OFFSET_ZERO, &shadowFirstWrittenData, sizeof(shadowFirstWrittenData), &bytesWritten)); EXPECT_EQ(sizeof(masterFirstWrittenData), bytesWritten); // TestProbe: Activate the data packet to be used by the applications. ASSERT_EQ(XME_STATUS_SUCCESS, xme_core_dataHandlerTestProbe_activateDatabaseForDataPacket(DB_SHADOW, dataPacketID1)); } // Database Status (before Step 3) // // ------------------------ // DP1 | 1234 | 5678 | // ------------------------ // Master(1) Shadow(2)* // Step 3: // Application: Read again the data packet. The read value should be the one written by the TestProbe. { // Read data. int32_t readDataDP1; // Read DP1 (from Application). ASSERT_EQ(XME_STATUS_SUCCESS, xme_core_dataHandler_readData(dataPacketID1, &readDataDP1, sizeof(readDataDP1), &bytesRead)); EXPECT_EQ(sizeof(readDataDP1), bytesRead); EXPECT_EQ(shadowFirstWrittenData, readDataDP1); } // Database Status (before Step 4) // // ------------------------ // DP1 | -1234 | 5678 | // ------------------------ // Master(1) Shadow(2)* // Step 4: // Read from TestProbe in shadow database (read in master database is allowed, but theoretically, not used). // Take into account that TestProbe can use less bytes than the topic size (to check in a separate test). { // Read datas. int32_t readDataDP1; // Read DP1 (from TestProbe from Shadow Database(2)). ASSERT_EQ(XME_STATUS_SUCCESS, xme_core_dataHandlerTestProbe_readDataInDatabase(DB_SHADOW, dataPacketID1, OFFSET_ZERO, &readDataDP1, sizeof(readDataDP1), &bytesRead)); EXPECT_EQ(sizeof(readDataDP1), bytesRead); EXPECT_EQ(shadowFirstWrittenData, readDataDP1); } // Database Status (before Step 5) // // ------------------------ // DP1 | -1234 | 5678 | // ------------------------ // Master(1) Shadow(2)* // Step 5: // Write from TestProbe in both databases different values. { // Write (from TestProbe in Master Database (1)) -- This is the directManipulation. ASSERT_EQ(XME_STATUS_SUCCESS, xme_core_dataHandlerTestProbe_writeDataInDatabase(DB_MASTER, dataPacketID1, OFFSET_ZERO, &masterSecondWrittenData, sizeof(masterSecondWrittenData), &bytesWritten)); EXPECT_EQ(sizeof(masterSecondWrittenData), bytesWritten); // Note: For write operation from TestProbe is not needed to lock/unlock the data packet. // The call will directly invoke the write operation. // Write (from TestProbe in Shadow Database (2)) -- This is the manipulation. ASSERT_EQ(XME_STATUS_SUCCESS, xme_core_dataHandlerTestProbe_writeDataInDatabase(DB_SHADOW, dataPacketID1, OFFSET_ZERO, &shadowSecondWrittenData, sizeof(shadowSecondWrittenData), &bytesWritten)); EXPECT_EQ(sizeof(shadowSecondWrittenData), bytesWritten); // We do need not to activate again, because it was previously activated by the TestProbe in the first write. } // Database Status (before Step 6) // // ------------------------ // DP1 | 3456 | -7890 | // ------------------------ // Master(1) Shadow(2)* // Step 6: // Read from standard application. This operation will read the value written by the TestProbe in Step 5 // from shadow database. { // Read datas. int32_t readDataDP1; // Read DP1 (from Application). ASSERT_EQ(XME_STATUS_SUCCESS, xme_core_dataHandler_readData(dataPacketID1, &readDataDP1, sizeof(readDataDP1), &bytesRead)); EXPECT_EQ(sizeof(readDataDP1), bytesRead); EXPECT_EQ(shadowSecondWrittenData, readDataDP1); } // Database Status (before Step 7) // // ------------------------ // DP1 | 3456 | -7890 | // ------------------------ // Master(1) Shadow(2)* // Step 7: // Activate the master database (aka deactivate the shadow database). { // Activate the master database (index=1U) (from TestProbe) ASSERT_EQ(XME_STATUS_SUCCESS, xme_core_dataHandlerTestProbe_activateDatabaseForDataPacket(DB_MASTER, dataPacketID1)); } // Database Status (before Step 8) // // ------------------------ // DP1 | 3456 | -7890 | // ------------------------ // Master(1)* Shadow(2) // Step 8: // Read from standard application. This operation will read the value written by the TestProbe in Step 5 // from master database. { int32_t readDataDP1; // Read DP1 (from Application). ASSERT_EQ(XME_STATUS_SUCCESS, xme_core_dataHandler_readData(dataPacketID1, &readDataDP1, sizeof(readDataDP1), &bytesRead)); EXPECT_EQ(sizeof(readDataDP1), bytesRead); EXPECT_EQ(masterSecondWrittenData, readDataDP1); } // Database Status (before Step 9) // // ------------------------ // DP1 | 3456 | -7890 | // ------------------------ // Master(1)* Shadow(2) // Step 9: // Read from TestProbe both from Master Database and from Shadow Database. { int32_t readDataDP1a; int32_t readDataDP1b; // Read DP1 (from TestProbe from Master Database(1)). // Note that this is NOT the normal read operation from TestProbe. ASSERT_EQ(XME_STATUS_SUCCESS, xme_core_dataHandlerTestProbe_readDataInDatabase(DB_MASTER, dataPacketID1, OFFSET_ZERO, &readDataDP1a, sizeof(readDataDP1a), &bytesRead)); EXPECT_EQ(sizeof(readDataDP1a), bytesRead); EXPECT_EQ(masterSecondWrittenData, readDataDP1a); // Read DP1 (from TestProbe from Shadow Database(2)). // Note that this is the normal read operation from TestProbe. ASSERT_EQ(XME_STATUS_SUCCESS, xme_core_dataHandlerTestProbe_readDataInDatabase(DB_SHADOW, dataPacketID1, OFFSET_ZERO, &readDataDP1b, sizeof(readDataDP1b), &bytesRead)); EXPECT_EQ(sizeof(readDataDP1b), bytesRead); EXPECT_EQ(shadowSecondWrittenData, readDataDP1b); } }
xme_status_t doMarshalingForTest ( xme_core_dataManager_dataPacketId_t inputPort, void* buffer ) { xme_wp_deMarshalerTest_topic_test_t topicData; unsigned int topicDataSize; unsigned int bytesRead; uint8_t* bufferPtr; xme_status_t status; topicDataSize = sizeof(xme_wp_deMarshalerTest_topic_test_t); // Read topic data status = xme_core_dataHandler_readData ( inputPort, &topicData, topicDataSize, &bytesRead ); XME_CHECK(status == XME_STATUS_SUCCESS, XME_STATUS_INTERNAL_ERROR); XME_CHECK(bytesRead == topicDataSize, XME_STATUS_INTERNAL_ERROR); // Marshal topic data bufferPtr = (uint8_t*)buffer; // bool topicData.flag { uint8_t netValue; netValue = topicData.flag ? 0x01 : 0x00; (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint8_t)); bufferPtr += sizeof(uint8_t); } // uint8_t topicData.uint8 { uint8_t netValue; netValue = (uint8_t)topicData.uint8; (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint8_t)); bufferPtr += sizeof(uint8_t); } // uint16_t topicData.uint16 { uint16_t netValue; netValue = xme_hal_net_htons((uint16_t)topicData.uint16); (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint16_t)); bufferPtr += sizeof(uint16_t); } // uint32_t topicData.uint32 { uint32_t netValue; netValue = xme_hal_net_htonl((uint32_t)topicData.uint32); (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint32_t)); bufferPtr += sizeof(uint32_t); } // uint64_t topicData.uint64 { uint64_t netValue; netValue = xme_hal_net_htonll((uint64_t)topicData.uint64); (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint64_t)); bufferPtr += sizeof(uint64_t); } // int8_t topicData.int8 { uint8_t netValue; netValue = (uint8_t)topicData.int8; (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint8_t)); bufferPtr += sizeof(uint8_t); } // int16_t topicData.int16 { uint16_t netValue; netValue = xme_hal_net_htons((uint16_t)topicData.int16); (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint16_t)); bufferPtr += sizeof(uint16_t); } // int32_t topicData.int32 { uint32_t netValue; netValue = xme_hal_net_htonl((uint32_t)topicData.int32); (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint32_t)); bufferPtr += sizeof(uint32_t); } // int64_t topicData.int64 { uint64_t netValue; netValue = xme_hal_net_htonll((uint64_t)topicData.int64); (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint64_t)); bufferPtr += sizeof(uint64_t); } // float topicData.f { // Note that the marshaler assumes binary32 (IEEE 754) storage format for float union { uint32_t i; float f; } value; value.f = topicData.f; value.i = xme_hal_net_htonl(value.i); (void) xme_hal_mem_copy(bufferPtr, &value, 4); bufferPtr += 4; } // double topicData.d { // Note that the marshaler assumes binary64 (IEEE 754) storage format for double union { uint64_t i; double d; } value; value.d = topicData.d; value.i = xme_hal_net_htonll(value.i); (void) xme_hal_mem_copy(bufferPtr, &value, 8); bufferPtr += 8; } // char topicData.c xme_hal_mem_copy(bufferPtr, &topicData.c, sizeof(char)); bufferPtr += sizeof(char); // enum topicData.e { uint32_t netValue; netValue = xme_hal_net_htonl((uint32_t)topicData.e); (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint32_t)); bufferPtr += sizeof(uint32_t); } // uint16_t topicData.array0 { uint8_t i0; for (i0 = 0; i0 < 3; i0++) { // uint16_t topicData.array0[i0] { uint16_t netValue; netValue = xme_hal_net_htons((uint16_t)topicData.array0[i0]); (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint16_t)); bufferPtr += sizeof(uint16_t); } } } // uint16_t topicData.array1 { uint8_t i0; uint8_t i1; for (i0 = 0; i0 < 2; i0++) { for (i1 = 0; i1 < 3; i1++) { // uint16_t topicData.array1[i0][i1] { uint16_t netValue; netValue = xme_hal_net_htons((uint16_t)topicData.array1[i0][i1]); (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint16_t)); bufferPtr += sizeof(uint16_t); } } } } // struct topicData.subStruct { // uint16_t topicData.subStruct.uint16 { uint16_t netValue; netValue = xme_hal_net_htons((uint16_t)topicData.subStruct.uint16); (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint16_t)); bufferPtr += sizeof(uint16_t); } // uint16_t topicData.subStruct.a { uint8_t i0; for (i0 = 0; i0 < 3; i0++) { // uint16_t topicData.subStruct.a[i0] { uint16_t netValue; netValue = xme_hal_net_htons((uint16_t)topicData.subStruct.a[i0]); (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint16_t)); bufferPtr += sizeof(uint16_t); } } } // struct topicData.subStruct.subSubStruct { // bool topicData.subStruct.subSubStruct.flag0 { uint8_t netValue; netValue = topicData.subStruct.subSubStruct.flag0 ? 0x01 : 0x00; (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint8_t)); bufferPtr += sizeof(uint8_t); } // bool topicData.subStruct.subSubStruct.flag1 { uint8_t netValue; netValue = topicData.subStruct.subSubStruct.flag1 ? 0x01 : 0x00; (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint8_t)); bufferPtr += sizeof(uint8_t); } } } // struct topicData.array2 { uint8_t i0; for (i0 = 0; i0 < 2; i0++) { // struct topicData.array2[i0] { // bool topicData.array2[i0].flag0 { uint8_t netValue; netValue = topicData.array2[i0].flag0 ? 0x01 : 0x00; (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint8_t)); bufferPtr += sizeof(uint8_t); } // bool topicData.array2[i0].flag1 { uint8_t netValue; netValue = topicData.array2[i0].flag1 ? 0x01 : 0x00; (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint8_t)); bufferPtr += sizeof(uint8_t); } } } } // struct topicData.array3 { uint8_t i0; for (i0 = 0; i0 < 1; i0++) { // struct topicData.array3[i0] { // char topicData.array3[i0].x { uint8_t i1; for (i1 = 0; i1 < 2; i1++) { // char topicData.array3[i0].x[i1] (void) xme_hal_mem_copy(bufferPtr, &topicData.array3[i0].x[i1], sizeof(char)); bufferPtr += sizeof(char); } } // struct topicData.array3[i0].y { uint8_t i1; for (i1 = 0; i1 < 2; i1++) { // struct topicData.array3[i0].y[i1] { // char topicData.array3[i0].y[i1].c { uint8_t i2; for (i2 = 0; i2 < 2; i2++) { // char topicData.array3[i0].y[i1].c[i2] (void) xme_hal_mem_copy(bufferPtr, &topicData.array3[i0].y[i1].c[i2], sizeof(char)); bufferPtr += sizeof(char); } } } } } // struct topicData.array3[i0].z { uint8_t i1; for (i1 = 0; i1 < 2; i1++) { // struct topicData.array3[i0].z[i1] { // char topicData.array3[i0].z[i1].c { uint8_t i2; for (i2 = 0; i2 < 2; i2++) { // char topicData.array3[i0].z[i1].c[i2] (void) xme_hal_mem_copy(bufferPtr, &topicData.array3[i0].z[i1].c[i2], sizeof(char)); bufferPtr += sizeof(char); } } } } } } } } return XME_STATUS_SUCCESS; }
xme_status_t doMarshalingForPnp_componentInstanceManifest ( xme_core_dataManager_dataPacketId_t inputPort, void* buffer ) { xme_core_topic_pnp_componentInstanceManifest_t topicData; unsigned int topicDataSize; unsigned int bytesRead; uint8_t* bufferPtr; xme_status_t status; topicDataSize = sizeof(xme_core_topic_pnp_componentInstanceManifest_t); // Read topic data status = xme_core_dataHandler_readData ( inputPort, &topicData, topicDataSize, &bytesRead ); XME_CHECK(status == XME_STATUS_SUCCESS, XME_STATUS_INTERNAL_ERROR); XME_CHECK(bytesRead == topicDataSize, XME_STATUS_INTERNAL_ERROR); // Marshal topic data bufferPtr = (uint8_t*)buffer; // uint32_t topicData.nodeId { uint32_t netValue; netValue = xme_hal_net_htonl((uint32_t)topicData.nodeId); (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint32_t)); bufferPtr += sizeof(uint32_t); } // struct topicData.components { uint8_t i0; for (i0 = 0; i0 < 10; i0++) { // struct topicData.components[i0] { // uint32_t topicData.components[i0].componentId { uint32_t netValue; netValue = xme_hal_net_htonl((uint32_t)topicData.components[i0].componentId); (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint32_t)); bufferPtr += sizeof(uint32_t); } // uint32_t topicData.components[i0].componentType { uint32_t netValue; netValue = xme_hal_net_htonl((uint32_t)topicData.components[i0].componentType); (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint32_t)); bufferPtr += sizeof(uint32_t); } } } } return XME_STATUS_SUCCESS; }