//------------------------------------------------------------------------------ static tOplkError generateHistoryEntryWithError(UINT16 errorCode_p, tNetTime netTime_p, UINT16 oplkError_p) { tOplkError ret; tErrHistoryEntry historyEntry; historyEntry.entryType = ERR_ENTRYTYPE_MODE_OCCURRED | ERR_ENTRYTYPE_PROF_PLK | ERR_ENTRYTYPE_HISTORY; historyEntry.errorCode = errorCode_p; historyEntry.timeStamp = netTime_p; ami_setUint16Le(&historyEntry.aAddInfo[0], (UINT16)oplkError_p); ret = postHistoryEntryEvent(&historyEntry); return ret; }
//------------------------------------------------------------------------------ void ami_setTimeOfDay(void* pAddr_p, tTimeOfDay* pTimeOfDay_p) { ami_setUint32Le(((UINT8*)pAddr_p), pTimeOfDay_p->msec & 0x0FFFFFFF); ami_setUint16Le(((UINT8*)pAddr_p) + 4, pTimeOfDay_p->days); }
//--------------------------------------------------------------------------- static tOplkError copyTxPdo(tPlkFrame* pFrame_p, UINT frameSize_p, BOOL fReadyFlag_p) { tOplkError ret = kErrorOk; BYTE flag1; UINT nodeId; tMsgType msgType; tPdoChannel* pPdoChannel; UINT channelId; UINT16 pdoSize; // set TPDO invalid, so that only fully processed TPDOs are sent as valid flag1 = ami_getUint8Le(&pFrame_p->data.pres.flag1); ami_setUint8Le(&pFrame_p->data.pres.flag1, (flag1 & ~PLK_FRAME_FLAG1_RD)); // retrieve POWERLINK message type msgType = (tMsgType)ami_getUint8Le(&pFrame_p->messageType); if (msgType == kMsgTypePres) { // TPDO is PRes frame nodeId = PDO_PRES_NODE_ID; // 0x00 } else { // TPDO is PReq frame // retrieve node ID nodeId = ami_getUint8Le(&pFrame_p->dstNodeId); } if (pdokInstance_g.fRunning) { // Get PDO channel reference channelId = pdokInstance_g.aTpdoChannelIdLut[nodeId]; pPdoChannel = &pdokInstance_g.pdoChannels.pTxPdoChannel[channelId]; // valid TPDO found if ((pPdoChannel->nodeId == nodeId) && ((unsigned int)(pPdoChannel->pdoSize + 24) <= frameSize_p)) { /* TRACE("%s() Channel:%d Node:%d MapObjectCnt:%d PdoSize:%d\n", __func__, channelId, nodeId, pPdoChannel->mappObjectCount, pPdoChannel->pdoSize); */ // set PDO version in frame ami_setUint8Le(&pFrame_p->data.pres.pdoVersion, pPdoChannel->mappingVersion); pdokcal_readTxPdo(channelId, &pFrame_p->data.pres.aPayload[0], pPdoChannel->pdoSize); // set PDO size in frame pdoSize = pPdoChannel->pdoSize; } else { // TPDO is too short or invalid // $$$ raise PDO error, set ret pdoSize = 0; } } else { // set PDO size in frame to zero, because no TPDO mapped pdoSize = 0; } // set PDO size in frame ami_setUint16Le(&pFrame_p->data.pres.sizeLe, pdoSize); if (fReadyFlag_p != FALSE) { // set TPDO valid ami_setUint8Le(&pFrame_p->data.pres.flag1, (flag1 | PLK_FRAME_FLAG1_RD)); } return ret; }