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; }
// FIXME: Similar code than above. If both UDP-Send and UDP Receive are hosting the same data, do we need to have both of them? void xme_core_pnp_dataLinkGraph_initWaypointUdpReceiveVertexData ( xme_core_pnp_dataLinkGraph_vertexData_t* const vertexData, const uint8_t key[4], const xme_com_interface_address_t* const host ) { XME_ASSERT_NORVAL(NULL != vertexData); XME_ASSERT_NORVAL(XME_CORE_PNP_DATALINKGRAPH_VERTEXTYPE_WAYPOINT_UDPRECEIVE == vertexData->vertexType); (void) xme_hal_mem_copy(vertexData->vertexData.waypointUdpReceiveVertex.key, key, XME_WP_UDP_HEADER_KEY_LENGTH); (void) xme_hal_mem_copy(&vertexData->vertexData.waypointUdpReceiveVertex.host, host, sizeof(xme_com_interface_address_t)); }
xme_status_t xme_core_directory_nodeRegistryController_addInterface ( xme_core_node_nodeId_t nodeId, xme_com_interface_address_t interfaceAddress ) { xme_hal_table_rowHandle_t handle; xme_core_node_nodeData_t* nodeItem; xme_com_interface_address_t* newInterfaceAddress; XME_CHECK(XME_CORE_NODE_INVALID_NODE_ID != nodeId, XME_STATUS_INVALID_PARAMETER); // Search for an existing item for this node handle = XME_HAL_TABLE_INVALID_ROW_HANDLE; nodeItem = NULL; XME_HAL_TABLE_GET_NEXT(xme_core_directory_nodeRegistryController_nodeTable, xme_hal_table_rowHandle_t, handle, xme_core_node_nodeData_t, nodeItem, nodeItem->nodeId == nodeId); // The node should already be registered XME_CHECK(XME_HAL_TABLE_INVALID_ROW_HANDLE != handle, XME_STATUS_NOT_FOUND); if (nodeItem != NULL) { if (0 != XME_HAL_TABLE_ITEM_COUNT(nodeItem->interfaces)) { xme_hal_table_rowHandle_t rh = XME_HAL_TABLE_INVALID_ROW_HANDLE; xme_com_interface_address_t *interfaceItem = NULL; XME_HAL_TABLE_GET_NEXT ( nodeItem->interfaces, xme_hal_table_rowHandle_t, rh, xme_com_interface_address_t, interfaceItem, interfaceItem->addressType == interfaceAddress.addressType ); while (NULL != interfaceItem) { if (0 == xme_hal_mem_compare(interfaceItem, &interfaceAddress, sizeof(xme_com_interface_address_t))) { return XME_STATUS_ALREADY_EXIST; } interfaceItem = NULL; XME_HAL_TABLE_GET_NEXT ( nodeItem->interfaces, xme_hal_table_rowHandle_t, rh, xme_com_interface_address_t, interfaceItem, interfaceItem->addressType == interfaceAddress.addressType ); } } handle = XME_HAL_TABLE_ADD_ITEM(nodeItem->interfaces); XME_CHECK(XME_HAL_TABLE_INVALID_ROW_HANDLE != handle, XME_STATUS_OUT_OF_RESOURCES); newInterfaceAddress = (xme_com_interface_address_t*) XME_HAL_TABLE_ITEM_FROM_HANDLE(nodeItem->interfaces, handle); XME_ASSERT(NULL != newInterfaceAddress); (void) xme_hal_mem_copy(newInterfaceAddress, &interfaceAddress, sizeof(xme_com_interface_address_t)); } return XME_STATUS_SUCCESS; }
xme_status_t reapplyManipulations ( xme_core_dataManager_dataStoreID_t dataStoreID ) { xme_core_dataHandler_database_manipulationItem_t* manipulationItem = NULL; xme_hal_table_rowHandle_t internalHandle = XME_HAL_TABLE_INVALID_ROW_HANDLE; do { void* returnAddress; // Obtain the next element. XME_HAL_TABLE_GET_NEXT ( manipulationsTable, xme_hal_table_rowHandle_t, internalHandle, xme_core_dataHandler_database_manipulationItem_t, manipulationItem, (manipulationItem->dataStoreID == dataStoreID) ); if (XME_HAL_TABLE_INVALID_ROW_HANDLE == internalHandle) continue; XME_ASSERT(NULL != manipulationItem); returnAddress = xme_hal_mem_copy((void*) manipulationItem->address, &(manipulationItem->value), sizeof(manipulationItem->value)); XME_CHECK(returnAddress == (void*) manipulationItem->address, XME_STATUS_INTERNAL_ERROR); } while(XME_HAL_TABLE_INVALID_ROW_HANDLE != internalHandle); return XME_STATUS_SUCCESS; }
xme_status_t xme_core_login_loginClient_fillLoginRequest ( xme_core_topic_login_loginRequest_t* config ) { XME_CHECK(NULL!=config, XME_STATUS_INVALID_PARAMETER); (void) xme_hal_mem_copy(config, &loginInformation, sizeof(xme_core_topic_login_loginRequest_t)); return XME_STATUS_SUCCESS; }
void xme_core_pnp_dataLinkGraph_initUdpLinkEdgeData ( xme_core_pnp_dataLinkGraph_edgeData_t* const edgeData, xme_core_topic_t topicId, const uint8_t key[4] ) { XME_ASSERT_NORVAL(NULL != edgeData); XME_ASSERT_NORVAL(XME_CORE_PNP_DATALINKGRAPH_EDGETYPE_UDPLINK == edgeData->edgeType); edgeData->edgeData.udpLinkEdge.topicId = topicId; if (NULL != key) { (void) xme_hal_mem_copy(&edgeData->edgeData.udpLinkEdge.key, key, sizeof(edgeData->edgeData.udpLinkEdge.key)); } }
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 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; }
extern xme_status_t xme_core_loop_init( xme_core_loop_configStruct_t* initConfig) { /* Initialize with default behavior */ xme_core_loop_intConfig.onFunctionActivate = NULL; xme_core_loop_intConfig.onFunctionReturned = NULL; if(NULL != initConfig) { (void) xme_hal_mem_copy( &xme_core_loop_intConfig, initConfig, sizeof(xme_core_loop_configStruct_t)); } XME_HAL_SINGLYLINKEDLIST_INIT(xme_core_loop_SchedulerData.initQueue); XME_HAL_SINGLYLINKEDLIST_INIT(xme_core_loop_SchedulerData.chunks); /* Registration of the RTE modules */ XME_CHECK_MSG( true == xme_core_loop_registerModulesCallback(), XME_STATUS_INVALID_CONFIGURATION, XME_LOG_FATAL, MODULE_ACRONYM "Could not register RTE modules!\n"); /* A configuration routine to define RTE "chunks" - the basic blocks of RTE module execution on OS level */ XME_CHECK_MSG( true == xme_core_loop_createChunksCallback(), XME_STATUS_INVALID_CONFIGURATION, XME_LOG_FATAL, MODULE_ACRONYM "Could not create RTE chunks!\n"); /* Check the chunks for plausibility and register in EM */ XME_CHECK_MSG( XME_STATUS_SUCCESS == xme_core_loop_completeInitialization(), XME_STATUS_INVALID_CONFIGURATION, XME_LOG_FATAL, MODULE_ACRONYM "Could not complete RTE initialization!\n"); XME_HAL_SINGLYLINKEDLIST_ITERATE_BEGIN(xme_core_loop_SchedulerData.initQueue, xme_core_exec_componentDescriptor_t, compToInit); if(compToInit->autoInit) { XME_LOG(XME_LOG_NOTE, MODULE_ACRONYM "RTE scheduler: initialize component %3d with priority %5d\n", compToInit->componentId, compToInit->initPriority); XME_CHECK_MSG(XME_STATUS_SUCCESS == compToInit->init(compToInit->initParam), XME_STATUS_INVALID_CONFIGURATION, XME_LOG_FATAL, MODULE_ACRONYM "Failure during initialization of the component %d\n", compToInit->componentId); } XME_HAL_SINGLYLINKEDLIST_ITERATE_END(); XME_CHECK( true == xme_core_loop_activateScheduleCallback(), XME_STATUS_INTERNAL_ERROR); return XME_STATUS_SUCCESS; }
xme_status_t xme_core_dataHandler_databaseTestProbe_readAttribute ( xme_core_dataHandler_database_index_t databaseIndex, xme_core_dataManager_dataPacketId_t dataStoreID, uint32_t attributeKey, uint32_t offsetInBytes, void* const targetBuffer, size_t targetBufferSizeInBytes, uint32_t* const readBytes ) { uintptr_t attributeAddress; size_t attributeSizeInBytes; xme_core_dataHandler_database_dataStore_t* dataStore; xme_core_dataHandler_database_attribute_t* attribute; uint32_t totalOffset; void* returnAddress; void* databaseAddress; XME_ASSERT(NULL != xme_core_dataHandler_database); XME_ASSERT(NULL != readBytes); *readBytes = 0U; // Obtain first the data packet and then the attribute. XME_CHECK(XME_STATUS_SUCCESS == getDataStore(dataStoreID, &dataStore), XME_STATUS_INVALID_HANDLE); XME_CHECK(XME_STATUS_SUCCESS == getAttribute(dataStore, attributeKey, &attribute), XME_STATUS_INVALID_PARAMETER); XME_CHECK(databaseIndex <= dataStore->memoryRegion->numOfCopies, XME_STATUS_INVALID_CONFIGURATION); XME_CHECK(attribute->dataAvailable, XME_STATUS_NO_SUCH_VALUE); // Return an error if an attempt is made to read outside the bounds of the data packet XME_CHECK(offsetInBytes < attribute->attributeValueSize, XME_STATUS_INVALID_PARAMETER); // Calculate the total offset to add. totalOffset = attribute->attributeOffset + offsetInBytes; // Add queue write position. if (dataStore->queueSize > 1) { totalOffset += (dataStore->dataStoreSize * dataStore->currentCBReadPosition); } // Get the number of bytes to use in the read operation. attributeSizeInBytes = getBytesToCopy(attribute->attributeValueSize, targetBufferSizeInBytes, offsetInBytes); if (((xme_core_dataHandler_database_index_t)XME_CORE_DATAHANDLER_DATABASE_INDEX_DEFAULT) == databaseIndex) { // Get database address from the active database in the data packet. databaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, dataStore->activeDatabaseIndex - 1U); } else { // Get database address from the provided database index. databaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, databaseIndex - 1U); } // Check that the database address and size contains correct values. XME_CHECK(0U != databaseAddress, XME_STATUS_NOT_FOUND); // Add the offset. attributeAddress = ((uintptr_t) databaseAddress + totalOffset); if (targetBufferSizeInBytes > attributeSizeInBytes) { uintptr_t bufferToCopy; bufferToCopy = ((uintptr_t) targetBuffer + (targetBufferSizeInBytes - attributeSizeInBytes)); returnAddress = xme_hal_mem_copy(targetBuffer, (void*) bufferToCopy, attributeSizeInBytes); XME_CHECK(returnAddress == (void*) targetBuffer, XME_STATUS_INTERNAL_ERROR); } else { // Do the read operation returnAddress = xme_hal_mem_copy(targetBuffer, (void*) attributeAddress, attributeSizeInBytes); XME_CHECK(returnAddress == (void*) targetBuffer, XME_STATUS_INTERNAL_ERROR); } // Set the effectively read bytes. *readBytes = attributeSizeInBytes; // Check that the target buffer is not null-valued. XME_CHECK(NULL != targetBuffer, XME_STATUS_INVALID_CONFIGURATION); return XME_STATUS_SUCCESS; }
xme_status_t copyBetweenMemoryRegionCopies ( xme_core_dataManager_dataStoreID_t dataStoreID, uint16_t sourceDatabaseIndex, uint16_t targetDatabaseIndex ) { uintptr_t sourceDataAddress; uintptr_t sinkDataAddress; xme_core_dataHandler_database_dataStore_t* dataStore; uint32_t transferSizeInBytes; uint32_t totalOffset; void* returnAddress; void* sourceDatabaseAddress; void* sinkDatabaseAddress; XME_ASSERT(NULL != xme_core_dataHandler_database); // Get the data packet information. XME_CHECK(XME_STATUS_SUCCESS == getDataStore(dataStoreID, &dataStore), XME_STATUS_INVALID_HANDLE); // Calculate the total offsets to add. totalOffset = dataStore->topicOffset; // Calculate the position in the queue for the source and sink address. if (dataStore->queueSize > 1) { totalOffset += dataStore->dataStoreSize * dataStore->currentCBWritePosition; } // Get the number of bytes to use in the transfer operation. transferSizeInBytes = getBytesToCopy(dataStore->topicSize, dataStore->topicSize, 0U); // Get source database address from the source database copy. sourceDatabaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, sourceDatabaseIndex - 1U); // Get source database address from the source database copy. sinkDatabaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, targetDatabaseIndex - 1U); // Check that the database addresses contain correct values. XME_CHECK(0U != sourceDatabaseAddress, XME_STATUS_NOT_FOUND); XME_CHECK(0U != sinkDatabaseAddress, XME_STATUS_NOT_FOUND); if (dataStore->dataAvailable) { // Add the offset corresponding to the source and sink addresses. sourceDataAddress = ((uintptr_t) sourceDatabaseAddress + totalOffset); sinkDataAddress = ((uintptr_t) sinkDatabaseAddress + totalOffset); // Do the transfer for the current copy of the database-> returnAddress = xme_hal_mem_copy((void*) sinkDataAddress, (void*) sourceDataAddress, transferSizeInBytes); XME_CHECK(returnAddress == (void*) sinkDataAddress, XME_STATUS_INTERNAL_ERROR); } // Try the transfer for all attributes as well. XME_HAL_SINGLYLINKEDLIST_ITERATE_BEGIN(dataStore->attributes, xme_core_dataHandler_database_attribute_t, attribute); { if (attribute->dataAvailable == true) { // If the attribute exists in the target data packet. uint32_t totalAttributeOffset; uintptr_t sourceAttributeAddress; uintptr_t sinkAttributeAddress; uint32_t totalAttributeSizeInBytes; // Calculate the total offsets to add. totalAttributeOffset = attribute->attributeOffset; // Calculate the position in the queue for the source and sink address. if (dataStore->queueSize > 1) { totalAttributeOffset += dataStore->dataStoreSize * dataStore->currentCBWritePosition; } // Get trasnfer bytes to copy. totalAttributeSizeInBytes = getBytesToCopy(attribute->attributeValueSize, attribute->attributeValueSize, 0U); // Add the offset corresponding to the source and sink addresses. sourceAttributeAddress = ((uintptr_t) sourceDatabaseAddress + totalAttributeOffset); sinkAttributeAddress = ((uintptr_t) sinkDatabaseAddress + totalAttributeOffset); // Do the transfer for the current copy of the database-> returnAddress = xme_hal_mem_copy((void*) sinkAttributeAddress, (void*) sourceAttributeAddress, totalAttributeSizeInBytes); XME_CHECK(returnAddress == (void*) sinkAttributeAddress, XME_STATUS_INTERNAL_ERROR); } } XME_HAL_SINGLYLINKEDLIST_ITERATE_END(); return XME_STATUS_SUCCESS; }
xme_status_t xme_core_dataHandler_databaseTestProbe_readData ( xme_core_dataHandler_database_index_t databaseIndex, xme_core_dataManager_dataPacketId_t dataStoreID, uint32_t offsetInBytes, void* const targetBuffer, size_t targetBufferSizeInBytes, uint32_t* const readBytes ) { uintptr_t dataAddress; size_t dataSizeInBytes; xme_core_dataHandler_database_dataStore_t* dataStore; uint32_t totalOffset; void* returnAddress; void* databaseAddress; XME_ASSERT(NULL != xme_core_dataHandler_database); XME_CHECK(XME_STATUS_SUCCESS == getDataStore(dataStoreID, &dataStore), XME_STATUS_INVALID_HANDLE); XME_CHECK(databaseIndex <= dataStore->memoryRegion->numOfCopies, XME_STATUS_INVALID_CONFIGURATION); if (!dataStore->dataAvailable) { *readBytes = 0U; return XME_STATUS_NO_SUCH_VALUE; } if (offsetInBytes >= dataStore->topicSize) { // We can not read outside the limit of the data packet. An error is returned. *readBytes = 0U; return XME_STATUS_INVALID_PARAMETER; } // Calculate the total offset to add. totalOffset = dataStore->topicOffset + offsetInBytes; // Add queue write position. if (dataStore->queueSize > 1) { totalOffset += (dataStore->dataStoreSize * dataStore->currentCBReadPosition); } // Get the number of bytes to use in the read operation. dataSizeInBytes = getBytesToCopy(dataStore->topicSize, targetBufferSizeInBytes, offsetInBytes); if (((xme_core_dataHandler_database_index_t)XME_CORE_DATAHANDLER_DATABASE_INDEX_DEFAULT) == databaseIndex) { // Get database address from the active database in the data packet. databaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, dataStore->activeDatabaseIndex - 1U); } else { // Get database address from the provided database index. databaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, databaseIndex - 1U); } // Check that the database address and size contains correct values. XME_CHECK(0U != databaseAddress, XME_STATUS_NOT_FOUND); // Add the offset. dataAddress = ((uintptr_t) databaseAddress + totalOffset); if (targetBufferSizeInBytes > dataSizeInBytes) { uintptr_t bufferToCopy; bufferToCopy = ((uintptr_t) targetBuffer + (targetBufferSizeInBytes - dataSizeInBytes)); returnAddress = xme_hal_mem_copy((void*) bufferToCopy, (void*) dataAddress, dataSizeInBytes); XME_CHECK(returnAddress == (void*) bufferToCopy, XME_STATUS_INTERNAL_ERROR); } else { // Do the read operation returnAddress = xme_hal_mem_copy(targetBuffer, (void*) dataAddress, dataSizeInBytes); XME_CHECK(returnAddress == (void*) targetBuffer, XME_STATUS_INTERNAL_ERROR); } // Set the effectively read bytes. *readBytes = dataSizeInBytes; return XME_STATUS_SUCCESS; }
xme_status_t xme_core_dataHandler_databaseTestProbe_writeAttribute ( uint16_t databaseIndex, xme_core_dataManager_dataPacketId_t dataStoreID, uint32_t attributeKey, uint32_t offsetInBytes, const void* const sourceBuffer, size_t sourceBufferSizeInBytes, uint32_t* const writtenBytes ) { uintptr_t attributeAddress; size_t attributeSizeInBytes; xme_core_dataHandler_database_dataStore_t* dataStore; xme_core_dataHandler_database_attribute_t* attribute; uint32_t totalOffset; void* returnAddress; void* databaseAddress; XME_ASSERT(NULL != xme_core_dataHandler_database); // Obtain first the data packet and then the attribute. XME_CHECK(XME_STATUS_SUCCESS == getDataStore(dataStoreID, &dataStore), XME_STATUS_INVALID_HANDLE); XME_CHECK(XME_STATUS_SUCCESS == getAttribute(dataStore, attributeKey, &attribute), XME_STATUS_INVALID_PARAMETER); XME_CHECK(databaseIndex <= dataStore->memoryRegion->numOfCopies, XME_STATUS_INVALID_CONFIGURATION); if (offsetInBytes >= attribute->attributeValueSize) { // We can not write outside the limit of the data packet. An error is returned. *writtenBytes = 0U; return XME_STATUS_INVALID_PARAMETER; } // Calculate the total offset to add. totalOffset = attribute->attributeOffset + offsetInBytes; // Add queue write position. if (dataStore->queueSize > 1) { totalOffset += (dataStore->dataStoreSize * dataStore->currentCBWritePosition); } // Get the number of bytes to use in the write operation. attributeSizeInBytes = getBytesToCopy(attribute->attributeValueSize, sourceBufferSizeInBytes, offsetInBytes); XME_CHECK(XME_CORE_DATAHANDLER_DATABASE_INDEX_DEFAULT != databaseIndex, XME_STATUS_INVALID_PARAMETER); // Get database address. databaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, databaseIndex - 1U); // Check that the data address and size contains correct values. XME_CHECK(0U != databaseAddress, XME_STATUS_NOT_FOUND); // Add the offset. attributeAddress = ((uintptr_t) databaseAddress + totalOffset); // Do the copy operation returnAddress = xme_hal_mem_copy((void*) attributeAddress, sourceBuffer, attributeSizeInBytes); XME_CHECK(returnAddress == (void*) attributeAddress, XME_STATUS_INTERNAL_ERROR); // Set the effectively written bytes. *writtenBytes = attributeSizeInBytes; // Check that the target buffer is not null-valued. XME_CHECK(NULL != sourceBuffer, XME_STATUS_INVALID_CONFIGURATION); // Set attribute availability to true. XME_CHECK(XME_STATUS_SUCCESS == setAttributeAvailability(attribute, true), XME_STATUS_INVALID_CONFIGURATION); if (XME_CORE_DATAHANDLER_DATABASE_INDEX_SHADOW == databaseIndex) { // Add the manipulation. uint32_t* value = (uint32_t*) sourceBuffer; xme_status_t status = addManipulation(dataStoreID, attributeAddress, *value); XME_CHECK(XME_STATUS_SUCCESS == status, XME_STATUS_INVALID_CONFIGURATION); // Activate the shadow database. dataStore->activeDatabaseIndex = XME_CORE_DATAHANDLER_DATABASE_INDEX_SHADOW; } 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; }
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; }
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; }