HRESULT avcUnitNotifyRemoveOld(LM_CONTEXT* notifyList, uint32 nodeAddr) { HRESULT hResult = NO_ERROR; uint32 pos = 0; uint32 index = 0; UNION_NOTIFY *notify; uint32 notifyAddr = 0; BOOL bFound = FALSE; DO_FOREVER { hResult = lmGetNthElement(notifyList, (void **) ¬ify, pos++, &index); if (hResult != NO_ERROR) return NO_ERROR; hResult = pbGetPacketSrcNodeAddr (notify->notifyComm.packetBlock, ¬ifyAddr); lmReleaseElement(notifyList, index); if (hResult != NO_ERROR) return NO_ERROR; if (nodeAddr == notifyAddr) { lmRemoveElement(notifyList, index); bFound = TRUE; break; } } #ifdef _SYSDEBUG if (bFound) { if (sysDebugIsEnabled(SYSDEBUG_TRACE_AVC & SYSDEBUG_TRACE_ERRORS)) //SYSDEBUG_TRACE_AVC { sysPrintCurTime(); sysDebugPrintf("avcUnitNotify removed old notify\n\r"); } } #endif //_SYSDEBUG return hResult; }
HRESULT cliBuiltInTool_ENV(uint32 argc, char** argv) { HRESULT hResult = NO_ERROR; uint32 counter=0; CLIDescriptor** elem=0; uint32 index=0; char tempstring[80]; argc = argc; argv = argv; cliOutputLine("Environment Variables:"); cliOutputLine("------------------------------------------------------------"); while (lmGetNthElement(cliEnvironmentList, (void **) &elem, counter++, &index) == NO_ERROR) { char* varname = 0; uint32 value = 0; uint32* pValue = 0; uint32 displaytype = 0; uint32 displaysize = 32; char* variablefields = NULL; char spacer[40]; CLIVariableChangedCallback varcallback = 0; kvGetValue(*elem, kCLI_Name, (uint32*)&varname); kvGetValue(*elem, kCLI_Variable,(uint32*)&pValue); kvGetValue(*elem, kCLI_VariableDisplayType, &displaytype); kvGetValue(*elem, kCLI_VariableSize, &displaysize); kvGetValue(*elem, kCLI_Function, (uint32*)&varcallback); kvGetValue(*elem, kCLI_VariableBitFields, (uint32*)&variablefields); memset(spacer,' ',ARRAYSIZE(spacer)); spacer[24-strlen(varname)]=0; if (varcallback) { // For virtual variable, it will have a varcallback, that we can ask for the value of the variable. hResult = (varcallback)(kCLI_VariableCallbackOperation_GET,varname,0L,&value); if (hResult != NO_ERROR) { sprintf(tempstring,"%s%s= N/A",varname,spacer); cliOutputLine(tempstring); hResult = NO_ERROR; continue; } } else { // For normal variables which just point to a place in memory. if (pValue) { value=*pValue; } } if (varname) { if (kCLI_DISPLAYTYPE_HEX==displaytype) { switch (displaysize) { case 32: sprintf(tempstring,"%s%s= 0x%08X",varname,spacer,value); break; case 24: sprintf(tempstring,"%s%s= 0x%06X",varname,spacer,value); break; case 16: sprintf(tempstring,"%s%s= 0x%04X",varname,spacer,value); break; case 8: sprintf(tempstring,"%s%s= 0x%02X",varname,spacer,value); break; } cliOutputRaw(tempstring); } if (kCLI_DISPLAYTYPE_DECIMAL==displaytype) { sprintf(tempstring,"%s%s= %d",varname,spacer,value); cliOutputRaw(tempstring); } if (kCLI_DISPLAYTYPE_BOOLEAN==displaytype) { sprintf(tempstring,"%s%s= ",varname,spacer); if (value) { strcat(tempstring,"true"); } else { strcat(tempstring,"false"); } cliOutputRaw(tempstring); } if (kCLI_DISPLAYTYPE_BINARY==displaytype) { uint32 i = 0; sprintf(tempstring,"%s%s= ",varname,spacer); for (i = displaysize; i > 0; i--) { uint32 mask = (uint32) (1 << (i-1)); if ((value) & mask) { strcat(tempstring,"1"); } else { strcat(tempstring,"0"); } } cliOutputRaw(tempstring); } // Check to see if we should display fields in the variables. if (variablefields) { cliPrintVariableFields(value,variablefields); } cliOutputLine(" "); } lmReleaseElement(cliEnvironmentList,index); } return hResult; }
HRESULT avcUnitNotifyCheck(LM_CONTEXT* notifyList, NOTIFY_CHECK_CALLBACK notifyCheckCB, NOTIFY_UPDATE_CALLBACK notifyUpdateCB) { HRESULT hResult = NO_ERROR; uint32 pos = 0; uint32 index = 0; pDataStream pStream = NULL; UNION_NOTIFY* notify = NULL; AVC_HEADER avcHeader; BOOL bChanged = FALSE; PB *packetBlock; // determine if there is a notify on the specified subunit DO_FOREVER { hResult = lmGetNthElement(notifyList, (void **) ¬ify, pos, &index); if (hResult != NO_ERROR) return NO_ERROR; bChanged = FALSE; // call callback to make notify specific check on notify state hResult = (* notifyCheckCB) (notify, &bChanged); if (bChanged) { #ifdef _SYSDEBUG if (sysDebugIsEnabled(SYSDEBUG_TRACE_AVC & SYSDEBUG_TRACE_ERRORS)) //SYSDEBUG_TRACE_AVC { sysPrintCurTime(); sysDebugPrintf("avcUnitNotify changed state for notify\n\r"); } #endif //_SYSDEBUG hResult = pbGetApplicationDatastream(notify->notifyComm.packetBlock, &pStream); if (hResult != NO_ERROR) break; hResult = avcDecodeHeader(pStream, &avcHeader); if (hResult != NO_ERROR) break; hResult = dsGotoMarker(pStream, DSMARKER_OPERAND_0); if (hResult != NO_ERROR) break; hResult = dsSwitchMode(pStream, dsMODE_WRITE); if (hResult != NO_ERROR) break; // call callback to write notify specific data into stream (from operand[0]) hResult = (* notifyUpdateCB) (notify, pStream); if (hResult != NO_ERROR) break; packetBlock = notify->notifyComm.packetBlock; hResult = lmReleaseElement(notifyList, index); if (hResult != NO_ERROR) break; hResult = lmRemoveElement(notifyList, index); if (hResult != NO_ERROR) break; hResult = avcReplyResponse (AVC_RESPONSE_CHANGED, packetBlock); if (hResult != NO_ERROR) break; } else { lmReleaseElement(notifyList, index); pos++; } } lmReleaseElement(notifyList, index); return hResult; }