static void AckStatusCallback(AWS_IoT_Client *pClient, char *topicName, uint16_t topicNameLen, IoT_Publish_Message_Params *params, void *pData) { int32_t tokenCount; uint8_t i; void *pJsonHandler = NULL; char temporaryClientToken[MAX_SIZE_CLIENT_TOKEN_CLIENT_SEQUENCE]; IOT_UNUSED(pClient); IOT_UNUSED(topicNameLen); IOT_UNUSED(pData); if(params->payloadLen > SHADOW_MAX_SIZE_OF_RX_BUFFER) { IOT_WARN("Payload larger than RX Buffer"); return; } memcpy(shadowRxBuf, params->payload, params->payloadLen); shadowRxBuf[params->payloadLen] = '\0'; // jsmn_parse relies on a string if(!isJsonValidAndParse(shadowRxBuf, pJsonHandler, &tokenCount)) { IOT_WARN("Received JSON is not valid"); return; } if(isAckForMyThingName(topicName)) { uint32_t tempVersionNumber = 0; if(extractVersionNumber(shadowRxBuf, pJsonHandler, tokenCount, &tempVersionNumber)) { if(tempVersionNumber > shadowJsonVersionNum) { shadowJsonVersionNum = tempVersionNumber; } } } if(extractClientToken(shadowRxBuf, temporaryClientToken)) { for(i = 0; i < MAX_ACKS_TO_COMEIN_AT_ANY_GIVEN_TIME; i++) { if(!AckWaitList[i].isFree) { if(strcmp(AckWaitList[i].clientTokenID, temporaryClientToken) == 0) { Shadow_Ack_Status_t status; if(strstr(topicName, "accepted") != NULL) { status = SHADOW_ACK_ACCEPTED; } else if(strstr(topicName, "rejected") != NULL) { status = SHADOW_ACK_REJECTED; } else { continue; } /* status == SHADOW_ACK_ACCEPTED || status == SHADOW_ACK_REJECTED */ if(AckWaitList[i].callback != NULL) { AckWaitList[i].callback(AckWaitList[i].thingName, AckWaitList[i].action, status, shadowRxBuf, AckWaitList[i].pCallbackContext); } unsubscribeFromAcceptedAndRejected(i); AckWaitList[i].isFree = true; return; } } } } }
static void shadow_delta_callback(AWS_IoT_Client *pClient, char *topicName, uint16_t topicNameLen, IoT_Publish_Message_Params *params, void *pData) { int32_t tokenCount; uint32_t i = 0; void *pJsonHandler = NULL; int32_t DataPosition; uint32_t dataLength; uint32_t tempVersionNumber = 0; FUNC_ENTRY; IOT_UNUSED(pClient); IOT_UNUSED(topicName); IOT_UNUSED(topicNameLen); IOT_UNUSED(pData); if(params->payloadLen > SHADOW_MAX_SIZE_OF_RX_BUFFER) { IOT_WARN("Payload larger than RX Buffer"); return; } memcpy(shadowRxBuf, params->payload, params->payloadLen); shadowRxBuf[params->payloadLen] = '\0'; // jsmn_parse relies on a string if(!isJsonValidAndParse(shadowRxBuf, pJsonHandler, &tokenCount)) { IOT_WARN("Received JSON is not valid"); return; } if(shadowDiscardOldDeltaFlag) { if(extractVersionNumber(shadowRxBuf, pJsonHandler, tokenCount, &tempVersionNumber)) { if(tempVersionNumber > shadowJsonVersionNum) { shadowJsonVersionNum = tempVersionNumber; } else { IOT_WARN("Old Delta Message received - Ignoring rx: %d local: %d", tempVersionNumber, shadowJsonVersionNum); return; } } } for(i = 0; i < tokenTableIndex; i++) { if(!tokenTable[i].isFree) { if(isJsonKeyMatchingAndUpdateValue(shadowRxBuf, pJsonHandler, tokenCount, (jsonStruct_t *) tokenTable[i].pStruct, &dataLength, &DataPosition)) { if(tokenTable[i].callback != NULL) { tokenTable[i].callback(shadowRxBuf + DataPosition, dataLength, (jsonStruct_t *) tokenTable[i].pStruct); } } } } }
static int AckStatusCallback(MQTTCallbackParams params) { int32_t tokenCount; int32_t i; void *pJsonHandler; char temporaryClientToken[MAX_SIZE_CLIENT_TOKEN_CLIENT_SEQUENCE]; if (params.MessageParams.PayloadLen > SHADOW_MAX_SIZE_OF_RX_BUFFER) { return GENERIC_ERROR; } memcpy(shadowRxBuf, params.MessageParams.pPayload, params.MessageParams.PayloadLen); shadowRxBuf[params.MessageParams.PayloadLen] = '\0'; // jsmn_parse relies on a string if (!isJsonValidAndParse(shadowRxBuf, pJsonHandler, &tokenCount)) { WARN("Received JSON is not valid"); return GENERIC_ERROR; } if (isAckForMyThingName(params.pTopicName)) { uint32_t tempVersionNumber = 0; if (extractVersionNumber(shadowRxBuf, pJsonHandler, tokenCount, &tempVersionNumber)) { if (tempVersionNumber > shadowJsonVersionNum) { shadowJsonVersionNum = tempVersionNumber; } } } if (extractClientToken(shadowRxBuf, temporaryClientToken)) { for (i = 0; i < MAX_ACKS_TO_COMEIN_AT_ANY_GIVEN_TIME; i++) { if (!AckWaitList[i].isFree) { if (strcmp(AckWaitList[i].clientTokenID, temporaryClientToken) == 0) { Shadow_Ack_Status_t status; if (strstr(params.pTopicName, "accepted") != NULL) { status = SHADOW_ACK_ACCEPTED; } else if (strstr(params.pTopicName, "rejected") != NULL) { status = SHADOW_ACK_REJECTED; } if (status == SHADOW_ACK_ACCEPTED || status == SHADOW_ACK_REJECTED) { if (AckWaitList[i].callback != NULL) { AckWaitList[i].callback(AckWaitList[i].thingName, AckWaitList[i].action, status, shadowRxBuf, AckWaitList[i].pCallbackContext); } unsubscribeFromAcceptedAndRejected(i); AckWaitList[i].isFree = true; return NONE_ERROR; } } } } } return GENERIC_ERROR; }
static int shadow_delta_callback(MQTTCallbackParams params) { int32_t tokenCount; uint32_t i = 0; void *pJsonHandler; int32_t DataPosition; uint32_t dataLength; if (params.MessageParams.PayloadLen > SHADOW_MAX_SIZE_OF_RX_BUFFER) { return GENERIC_ERROR; } memcpy(shadowRxBuf, params.MessageParams.pPayload, params.MessageParams.PayloadLen); shadowRxBuf[params.MessageParams.PayloadLen] = '\0'; // jsmn_parse relies on a string if (!isJsonValidAndParse(shadowRxBuf, pJsonHandler, &tokenCount)) { WARN("Received JSON is not valid"); return GENERIC_ERROR; } if (shadowDiscardOldDeltaFlag) { uint32_t tempVersionNumber = 0; if (extractVersionNumber(shadowRxBuf, pJsonHandler, tokenCount, &tempVersionNumber)) { if (tempVersionNumber > shadowJsonVersionNum) { shadowJsonVersionNum = tempVersionNumber; DEBUG("New Version number: %d", shadowJsonVersionNum); } else { WARN("Old Delta Message received - Ignoring rx: %d local: %d", tempVersionNumber, shadowJsonVersionNum); return GENERIC_ERROR; } } } for (i = 0; i < tokenTableIndex; i++) { if (!tokenTable[i].isFree) { if (isJsonKeyMatchingAndUpdateValue(shadowRxBuf, pJsonHandler, tokenCount, tokenTable[i].pStruct, &dataLength, &DataPosition)) { if (tokenTable[i].callback != NULL) { tokenTable[i].callback(shadowRxBuf + DataPosition, dataLength, tokenTable[i].pStruct); } } } } return NONE_ERROR; }
//========================================================================================================= bool GetASICInfo(ASICInfo& rASICInfo) { if (nullptr == oglUtils::_oglGetPerfMonitorCountersAMD || nullptr == oglUtils::_oglGetPerfMonitorGroupStringAMD || nullptr == oglUtils::_oglGetPerfMonitorCounterInfoAMD || nullptr == oglUtils::_oglGetPerfMonitorCounterStringAMD || nullptr == oglUtils::_oglGenPerfMonitorsAMD || nullptr == oglUtils::_oglDeletePerfMonitorsAMD || nullptr == oglUtils::_oglSelectPerfMonitorCountersAMD || nullptr == oglUtils::_oglBeginPerfMonitorAMD || nullptr == oglUtils::_oglEndPerfMonitorAMD || nullptr == oglUtils::_oglGetPerfMonitorCounterDataAMD) { // No AMD_peformance_monitor support, means no ASIC info GPA_LogError("One or more of the GL_AMD_performance_monitor functions were not found."); return false; } // Find the ASIC info group (GPIN = GPu INformation) GLint nASICGroupId = GetGroupID(ASIC_GROUP); if (nASICGroupId == -1) { GPA_LogError("Unable to find the GPIN group."); return false; } // Get the ASIC ID GLuint nAsicType = 0; if (!GetCounterValue(nASICGroupId, ASIC_TYPE, nAsicType)) { GPA_LogError("Unable to get the asic id."); return false; } // query the driver version so that we can correct the asic ID after a driver // change that happened for 10.2, where support for pre-R6xx hardware was removed //(legacy driver will support that) #ifndef GLES // Since GL ES didn't exist before version 9551, there's no need to check the // version number. For now, it is assumed the version number will be >9551 const GLubyte* pVersion = oglUtils::_oglGetString(GL_VERSION); int nVersion = extractVersionNumber(pVersion); std::stringstream message; message << "ASIC ID returned from driver is: " << nAsicType << " and GL_VERSION is: " << reinterpret_cast<const char*>(pVersion) << "."; GPA_LogMessage(message.str().c_str()); #else int nVersion = INT_MAX; #endif if (nVersion < 13452) { // pre-GCN devices were removed from the driver starting with version 13452. // if the driver version is earlier than that we will return an error. GPA_LogError("OpenGL driver version is too old. Please update your driver."); return false; } // store the Asic Revision ID rASICInfo.eAsicRev = (ATIAsicID) nAsicType; // Decode the ASIC Type if (nAsicType == ATIASIC_ID_TAHITI_P || nAsicType == ATIASIC_ID_PITCAIRN_PM || nAsicType == ATIASIC_ID_CAPEVERDE_M || nAsicType == ATIASIC_ID_OLAND_M || nAsicType == ATIASIC_ID_HAINAN_M) { GPA_LogMessage("Recognized a GFX6 card."); rASICInfo.eAsicType = ASIC_Gfx6; } else if (nAsicType == ATIASIC_ID_BONAIRE_M || nAsicType == ATIASIC_ID_HAWAII_P) { GPA_LogMessage("Recognized a GFX7 card."); rASICInfo.eAsicType = ASIC_Gfx7; } else if (nAsicType == ATIASIC_ID_KALINDI || nAsicType == ATIASIC_ID_GODAVARI || nAsicType == ATIASIC_ID_SPECTRE || nAsicType == ATIASIC_ID_SPOOKY) { GPA_LogMessage("Recognized an APU with GFX7 graphics."); rASICInfo.eAsicType = ASIC_Gfx7; } else if (nAsicType == ATIASIC_ID_ICELAND_M || nAsicType == ATIASIC_ID_TONGA_P || nAsicType == ATIASIC_ID_FIJI_P || nAsicType == ATIASIC_ID_ELLESMERE || nAsicType == ATIASIC_ID_BAFFIN || nAsicType == ATIASIC_ID_LEXA || nAsicType == ATIASIC_ID_VEGAM) { GPA_LogMessage("Recognized a GFX8 card."); rASICInfo.eAsicType = ASIC_Gfx8; } else if (nAsicType == ATIASIC_ID_CARRIZO || nAsicType == ATIASIC_ID_STONEY) { GPA_LogMessage("Recognized an APU with GFX8 graphics."); rASICInfo.eAsicType = ASIC_Gfx8; } else if (nAsicType == ATIASIC_ID_GFX900 || nAsicType == ATIASIC_ID_PLACEHOLDER1 || nAsicType == ATIASIC_ID_GFX906) { GPA_LogMessage("Recognized a GFX9 card."); rASICInfo.eAsicType = ASIC_Gfx9; } else if (nAsicType == ATIASIC_ID_GFX902 || nAsicType == ATIASIC_ID_PLACEHOLDER) { GPA_LogMessage("Recognized an APU with GFX9 graphics."); rASICInfo.eAsicType = ASIC_Gfx9; } else { std::stringstream errorMessage; errorMessage << "Unrecognized asic type: " << nAsicType << "."; GPA_LogError(errorMessage.str().c_str()); assert(0); // Unknown ASIC Type, need to update enums list from UGL driver rASICInfo.eAsicType = ASIC_UNKNOWN; return false; } // Now, fill in the rest of the ASIC structure switch (rASICInfo.eAsicType) { case ASIC_Gfx6: case ASIC_Gfx7: case ASIC_Gfx8: case ASIC_Gfx9: if (!GetCounterValue(nASICGroupId, "GPIN_001", rASICInfo.nNumSIMD)) { GPA_LogError("Unable to query GPIN_001."); return false; } if (!GetCounterValue(nASICGroupId, "GPIN_002", rASICInfo.nNumQuadPipe)) { GPA_LogError("Unable to query GPIN_002."); return false; } if (!GetCounterValue(nASICGroupId, "GPIN_003", rASICInfo.nNumRB)) { GPA_LogError("Unable to query GPIN_003."); return false; } if (!GetCounterValue(nASICGroupId, "GPIN_004", rASICInfo.nNumSPI)) { GPA_LogError("Unable to query GPIN_004."); return false; } break; default: break; } return true; }