Ejemplo n.º 1
0
//------------------------------------------------------------------------------
static tOplkError processCfmResultEvent(tOplkApiEventType EventType_p,
                                        tOplkApiEventArg* pEventArg_p,
                                        void* pUserArg_p)
{
    tOplkApiEventCfmResult*       pCfmResult = &pEventArg_p->cfmResult;

    UNUSED_PARAMETER(EventType_p);
    UNUSED_PARAMETER(pUserArg_p);

    switch (pCfmResult->nodeCommand)
    {
        case kNmtNodeCommandConfOk:
            console_printlog("CFM Result: (Node=%d, ConfOk)\n", pCfmResult->nodeId);
            break;

        case kNmtNodeCommandConfErr:
            console_printlog("CFM Result: (Node=%d, ConfErr)\n", pCfmResult->nodeId);
            break;

        case kNmtNodeCommandConfReset:
            console_printlog("CFM Result: (Node=%d, ConfReset)\n", pCfmResult->nodeId);
            break;

        case kNmtNodeCommandConfRestored:
            console_printlog("CFM Result: (Node=%d, ConfRestored)\n", pCfmResult->nodeId);
            break;

        default:
            console_printlog("CFM Result: (Node=%d, CfmResult=0x%X)\n", pCfmResult->nodeId,
                             pCfmResult->nodeCommand);
            break;
    }
    return kErrorOk;
}
Ejemplo n.º 2
0
//------------------------------------------------------------------------------
static tOplkError processPdoChangeEvent(tOplkApiEventType EventType_p,
                                        tOplkApiEventArg* pEventArg_p,
                                        void* pUserArg_p)
{
    tOplkApiEventPdoChange*     pPdoChange = &pEventArg_p->pdoChange;
    UINT                        subIndex;
    UINT64                      mappObject;
    tOplkError                  ret;
    UINT                        varLen;

    UNUSED_PARAMETER(EventType_p);
    UNUSED_PARAMETER(pUserArg_p);

    console_printlog("PDO change event: (%sPDO = 0x%X to node 0x%X with %d objects %s)\n",
                     (pPdoChange->fTx ? "T" : "R"), pPdoChange->mappParamIndex,
                     pPdoChange->nodeId, pPdoChange->mappObjectCount,
                     (pPdoChange->fActivated ? "activated" : "deleted"));

    for (subIndex = 1; subIndex <= pPdoChange->mappObjectCount; subIndex++)
    {
        varLen = sizeof(mappObject);
        ret = oplk_readLocalObject(pPdoChange->mappParamIndex, subIndex, &mappObject, &varLen);
        if (ret != kErrorOk)
        {
            console_printlog("  Reading 0x%X/%d failed with 0x%X\n",
                             pPdoChange->mappParamIndex, subIndex, ret);
            continue;
        }
        console_printlog("  %d. mapped object 0x%X/%d\n", subIndex, mappObject & 0x00FFFFULL,
                         (mappObject & 0xFF0000ULL) >> 16);
    }
    return kErrorOk;
}
Ejemplo n.º 3
0
//------------------------------------------------------------------------------
static tOplkError processCfmProgressEvent(tOplkApiEventType EventType_p,
                                          tOplkApiEventArg* pEventArg_p,
                                          void* pUserArg_p)
{
    tCfmEventCnProgress*     pCfmProgress = &pEventArg_p->cfmProgress;

    UNUSED_PARAMETER(EventType_p);
    UNUSED_PARAMETER(pUserArg_p);

    console_printlog("CFM Progress: (Node=%u, CFM-Progress: Object 0x%X/%u, ",
                     pCfmProgress->nodeId,
                     pCfmProgress->objectIndex,
                     pCfmProgress->objectSubIndex);

    console_printlogadd("%lu/%lu Bytes", (ULONG)pCfmProgress->bytesDownloaded,
                        (ULONG)pCfmProgress->totalNumberOfBytes);

    if ((pCfmProgress->sdoAbortCode != 0) ||
        (pCfmProgress->error != kErrorOk))
    {
        console_printlogadd(" -> SDO Abort=0x%lX, Error=0x%X)\n",
                            (ULONG)pCfmProgress->sdoAbortCode,
                            pCfmProgress->error);
    }
    else
    {
        console_printlogadd(")\n");
    }
    return kErrorOk;
}
Ejemplo n.º 4
0
//------------------------------------------------------------------------------
static tOplkError processNodeEvent(tOplkApiEventType EventType_p,
                                   tOplkApiEventArg* pEventArg_p,
                                   void* pUserArg_p)
{
    tOplkApiEventNode*   pNode = &pEventArg_p->nodeEvent;

    UNUSED_PARAMETER(EventType_p);
    UNUSED_PARAMETER(pUserArg_p);

    // check additional argument
    switch (pNode->nodeEvent)
    {
        case kNmtNodeEventCheckConf:
            console_printlog("NodeEvent: (Node=%u, CheckConf)\n", pNode->nodeId);
            break;

        case kNmtNodeEventUpdateConf:
            console_printlog("NodeEvent: (Node=%u, UpdateConf)\n", pNode->nodeId);
            break;

        case kNmtNodeEventNmtState:
            console_printlog("NodeEvent: (Node=%u, NmtState=%s)\n",
                             pNode->nodeId,
                             debugstr_getNmtStateStr(pNode->nmtState));
            break;

        case kNmtNodeEventError:
            console_printlog("NodeEvent: (Node=%u): Error=%s (0x%.4X)\n",
                             pNode->nodeId,
                             debugstr_getEmergErrCodeStr(pNode->errorCode),
                             pNode->errorCode);
            break;

        case kNmtNodeEventFound:
            console_printlog("NodeEvent: (Node=%u, Found)\n", pNode->nodeId);
            break;

        default:
            break;
    }
    return kErrorOk;
}
Ejemplo n.º 5
0
//------------------------------------------------------------------------------
static tOplkError processErrorWarningEvent(tOplkApiEventType EventType_p,
                                           tOplkApiEventArg* pEventArg_p,
                                           void* pUserArg_p)
{
    // error or warning occurred within the stack or the application
    // on error the API layer stops the NMT state machine

    tEventError*            pInternalError = &pEventArg_p->internalError;

    UNUSED_PARAMETER(EventType_p);
    UNUSED_PARAMETER(pUserArg_p);

    console_printlog("Err/Warn: Source = %s (%02X) OplkError = %s (0x%03X)\n",
                     debugstr_getEventSourceStr(pInternalError->eventSource),
                     pInternalError->eventSource,
                     debugstr_getRetValStr(pInternalError->oplkError),
                     pInternalError->oplkError);

    // check additional argument
    switch (pInternalError->eventSource)
    {
        case kEventSourceEventk:
        case kEventSourceEventu:
            // error occurred within event processing
            // either in kernel or in user part
            console_printlog(" OrgSource = %s %02X\n",
                             debugstr_getEventSourceStr(pInternalError->errorArg.eventSource),
                             pInternalError->errorArg.eventSource);
            break;

        case kEventSourceDllk:
            // error occurred within the data link layer (e.g. interrupt processing)
            // the DWORD argument contains the DLL state and the NMT event
            console_printlog(" val = %X\n", pInternalError->errorArg.uintArg);
            break;

        default:
            console_printlog("\n");
            break;
    }
    return kErrorOk;
}
//------------------------------------------------------------------------------
static tOplkError processStateChangeEvent(const tEventNmtStateChange* pNmtStateChange_p,
                                          void* pUserArg_p)
{
    tOplkError  ret = kErrorOk;

    UNUSED_PARAMETER(pUserArg_p);

    if (instance_l.config.pfGsOff == NULL)
    {
        console_printlog("Application event module is not initialized!\n");
        return kErrorGeneralError;
    }

    eventlog_printStateEvent(pNmtStateChange_p);

    switch (pNmtStateChange_p->newNmtState)
    {
        case kNmtGsOff:
           // NMT state machine was shut down,
            // because of user signal (CTRL-C) or critical POWERLINK stack error
            // -> also shut down oplk_process() and main()
            ret = kErrorShutdown;

            printf("Stack received kNmtGsOff!\n");

            // signal that stack is off
            *instance_l.config.pfGsOff = TRUE;
            break;

        case kNmtGsResetCommunication:
            break;

        case kNmtGsResetConfiguration:
            break;

        case kNmtGsInitialising:
        case kNmtGsResetApplication:        // Implement
        case kNmtMsNotActive:               // handling of
        case kNmtMsPreOperational1:         // different
        case kNmtMsPreOperational2:         // states here
        case kNmtMsReadyToOperate:
        case kNmtMsOperational:
        case kNmtMsBasicEthernet:           // no break

        default:
            printf("Stack entered state: %s\n",
                   debugstr_getNmtStateStr(pNmtStateChange_p->newNmtState));
            break;
    }

    return ret;
}
Ejemplo n.º 7
0
//------------------------------------------------------------------------------
static tOplkError processHistoryEvent(tOplkApiEventType EventType_p,
                                      tOplkApiEventArg* pEventArg_p,
                                      void* pUserArg_p)
{
    tErrHistoryEntry*    pHistoryEntry = &pEventArg_p->errorHistoryEntry;

    UNUSED_PARAMETER(EventType_p);
    UNUSED_PARAMETER(pUserArg_p);

    console_printlog("HistoryEntry: Type=0x%04X Code=0x%04X (0x%02X %02X %02X %02X %02X %02X %02X %02X)\n",
             pHistoryEntry->entryType, pHistoryEntry->errorCode,
            (WORD)pHistoryEntry->aAddInfo[0], (WORD)pHistoryEntry->aAddInfo[1],
            (WORD)pHistoryEntry->aAddInfo[2], (WORD)pHistoryEntry->aAddInfo[3],
            (WORD)pHistoryEntry->aAddInfo[4], (WORD)pHistoryEntry->aAddInfo[5],
            (WORD)pHistoryEntry->aAddInfo[6], (WORD)pHistoryEntry->aAddInfo[7]);

    return kErrorOk;
}
Ejemplo n.º 8
0
//------------------------------------------------------------------------------
static tOplkError processStateChangeEvent(tOplkApiEventType EventType_p,
                                          tOplkApiEventArg* pEventArg_p,
                                          void* pUserArg_p)
{
    tOplkError                  ret = kErrorOk;
    tEventNmtStateChange*       pNmtStateChange = &pEventArg_p->nmtStateChange;

    UNUSED_PARAMETER(EventType_p);
    UNUSED_PARAMETER(pUserArg_p);

    if (pfGsOff_l == NULL)
    {
        console_printlog("Application event module is not initialized!\n");
        return kErrorGeneralError;
    }

    switch (pNmtStateChange->newNmtState)
    {
        case kNmtGsOff:
           // NMT state machine was shut down,
            // because of user signal (CTRL-C) or critical POWERLINK stack error
            // -> also shut down oplk_process() and main()
            ret = kErrorShutdown;

            console_printlog("StateChangeEvent:kNmtGsOff originating event = 0x%X (%s)\n",
                             pNmtStateChange->nmtEvent,
                             debugstr_getNmtEventStr(pNmtStateChange->nmtEvent));

            // signal that stack is off
            *pfGsOff_l = TRUE;
            break;

        case kNmtGsResetCommunication:
#ifndef CONFIG_INCLUDE_CFM
            ret = setDefaultNodeAssignment();
#endif
            console_printlog("StateChangeEvent(0x%X) originating event = 0x%X (%s)\n",
                             pNmtStateChange->newNmtState,
                             pNmtStateChange->nmtEvent,
                             debugstr_getNmtEventStr(pNmtStateChange->nmtEvent));
            break;

        case kNmtGsResetConfiguration:
            console_printlog("StateChangeEvent(0x%X) originating event = 0x%X (%s)\n",
                             pNmtStateChange->newNmtState,
                             pNmtStateChange->nmtEvent,
                             debugstr_getNmtEventStr(pNmtStateChange->nmtEvent));
            break;

        case kNmtGsInitialising:
        case kNmtGsResetApplication:        // Implement
        case kNmtMsNotActive:               // handling of
        case kNmtMsPreOperational1:         // different
        case kNmtMsPreOperational2:         // states here
        case kNmtMsReadyToOperate:
        case kNmtMsOperational:
        case kNmtMsBasicEthernet:           // no break

        default:
            console_printlog("StateChangeEvent(0x%X) originating event = 0x%X (%s)\n",
                             pNmtStateChange->newNmtState,
                             pNmtStateChange->nmtEvent,
                             debugstr_getNmtEventStr(pNmtStateChange->nmtEvent));
            break;
    }

    return ret;
}