コード例 #1
0
/**
 * \brief Claim address
 * \req RSI_26_013 - DILJ_NM_ClaimAddress
 * \param[in] dwClientId Already register node's client Id
 * \param[in] unChannel Channel number
 * \param[in] byAddress New address to be claimed
 * \param[in] byPriority Priority (0 - 7)
 * \return S_OK if successful, else S_FALSE.
 *
 * Node tries to claim a new address by sending Address Claim message into the network.
 */
USAGEMODE HRESULT DILJ_NM_ClaimAddress (DWORD dwClientId, UINT unChannel, BYTE byAddress, BYTE byPriority)
{
    HRESULT hResult = S_FALSE; 
    CNodeConManager* pManager = NULL;
    pManager = CNetworkMgmt::ouGetNWManagementObj().pouGetConMagrObj(dwClientId);
    if (NULL != pManager && pManager->bIsActive())
    {
        hResult = S_OK;
        if (pManager->bIsMonitorNode())
        {
            pManager->vSetNodeAddress(byAddress);
        }
        pManager->vSendMessage(unChannel, MSG_TYPE_NM_ACL, byAddress, 0, NULL, byPriority, ADDRESS_ALL);
    }
    return hResult;
}
コード例 #2
0
/**
 * \brief Requests a PGN from a node
 * \req RSI_26_007 - DILJ_RequestPGN
 * \param[in] dwClient Client Id
 * \param[in] unChannel Channel number
 * \param[in] unPGN Parameter group number to be requested
 * \param[in] byPriority Priority (0-7)
 * \param[in] byDesrAdress Destination address.
 * \return S_OK if successful, else S_FALSE.
 *
 * Requests a PGN from the node.
 */
USAGEMODE HRESULT DILJ_RequestPGN(DWORD dwClient, UINT unChannel, UINT32 unPGN, 
                                  BYTE byPriority, BYTE bySrc, BYTE byDestAddress)
{
    HRESULT hResult = S_FALSE; 
    CNodeConManager* pManager = NULL;
    pManager = CNetworkMgmt::ouGetNWManagementObj().pouGetConMagrObj(dwClient);
    if (NULL != pManager && pManager->bIsActive())
    {
        hResult = S_OK;
        if (pManager->bIsMonitorNode())
        {
            pManager->vSetNodeAddress(bySrc);
        }
        pManager->vSendMessage(unChannel, MSG_TYPE_REQUEST, unPGN, 0, 0, byPriority, byDestAddress);
    }
    return hResult;
}
コード例 #3
0
ファイル: DIL_J1939.cpp プロジェクト: ETAS-Nithin/busmaster
/**
 * \brief Requests address from the node.
 * \req RSI_26_014 - DILJ_NM_RequestAddress
 * \param[in] dwClientId Already register node's client Id
 * \param[in] unChannel Channel number
 * \param[in] byDestAddress Destination Address
 * \param[in] byPriority Priority (0 - 7).
 * \return S_OK if successful, else S_FALSE.
 *
 * A node requests address from an another node.
 */
USAGEMODE HRESULT DILJ_NM_RequestAddress(DWORD dwClient, UINT unChannel, BYTE byPriority,
        BYTE bySrc, BYTE byDestAddress)
{
    HRESULT hResult = S_FALSE;
    CNodeConManager* pManager = nullptr;
    pManager = CNetworkMgmt::ouGetNWManagementObj().pouGetConMagrObj(dwClient);
    if (nullptr != pManager && pManager->bIsActive())
    {
        hResult = S_OK;
        if (pManager->bIsMonitorNode())
        {
            pManager->vSetNodeAddress(bySrc);
        }
        pManager->vSendMessage(unChannel, MSG_TYPE_NM_RQST_ACL, 0, nullptr, 0, byPriority, byDestAddress);
    }
    return hResult;
}
コード例 #4
0
/**
 * \brief Sends a J1939 message.
 * \req RSI_26_005 - DILJ_SendJ1939Msg
 * \param[in] dwClient Client Id
 * \param[in] unChannel Channel number
 * \param[in] eMsgType COMMAND, BROADCAST, REQUEST, RESPONSE
 * \param[in] unPGN Parameter group number
 * \param[in] pbyData Data bytes
 * \param[in] unDLC Data length in number of bytes.
 * \param[in] byPriority Priority (0-7) byDesrAdress = Destination address.
 * \return S_OK if successful, else S_FALSE.
 *
 * Sends a J1939 message.
 */
USAGEMODE HRESULT DILJ_SendJ1939Msg (DWORD dwClientId, UINT unChannel, EJ1939_MSG_TYPE eMsgType, UINT32 unPGN,
                                     BYTE* pbyData, UINT unDLC, BYTE byPriority, BYTE bySrc, BYTE byDestAdres)
{
    HRESULT hResult = S_FALSE;
    CNodeConManager* pManager = NULL;
    pManager = CNetworkMgmt::ouGetNWManagementObj().pouGetConMagrObj(dwClientId);
    if (NULL != pManager && pManager->bIsActive())
    {
        hResult = S_OK;
        if (pManager->bIsMonitorNode())
        {
            pManager->vSetNodeAddress(bySrc);
        }
        pManager->vSendMessage(unChannel, eMsgType, unPGN, pbyData, unDLC, byPriority, byDestAdres);
        
    }
    return hResult;
}
コード例 #5
0
ファイル: DIL_J1939.cpp プロジェクト: Ferrere/busmaster
/**
 * \brief Sends a acknowledgement message.
 * \req RSI_26_006 - DILJ_SendAckMsg
 * \param[in] dwClientId Already register node's client Id
 * \param[in] unChannel Channel number
 * \param[in] eAckType Acknowledge type (ACK_POS, ACK_NEG)
 * \param[in] unPGN PGN to be sent.
 * \param[in] pbyData PGN data.
 * \param[in] byAddresAck Destination address.
 * \return S_OK if successful, else S_FALSE.
 *
 * Sends Positive/Negative acknowledgement msg.
 */
USAGEMODE HRESULT DILJ_SendAckMsg(DWORD dwClient, UINT unChannel, ETYPE_ACK eAckType, UINT32 unPGN, BYTE bySrc, BYTE byAddresAck)
{
    HRESULT hResult = S_FALSE;
    CNodeConManager* pManager = NULL;
    pManager = CNetworkMgmt::ouGetNWManagementObj().pouGetConMagrObj(dwClient);

    if (NULL != pManager && pManager->bIsActive())
    {
        hResult = S_OK;

        if (pManager->bIsMonitorNode())
        {
            pManager->vSetNodeAddress(bySrc);
        }

        BYTE abyFrame[MAX_FRAME_DATA_SIZE];

        switch (eAckType)
        {
            case ACK_POS:
            {
                abyFrame[0] = CB_ACK_POS;
                abyFrame[4] = byAddresAck;
            }
            break;

            case ACK_NEG:
            {
                abyFrame[0] = CB_ACK_NEG;
                abyFrame[4] = ADDRESS_NULL;
            }
            break;
        }

        abyFrame[1] = 0xFF;
        abyFrame[2] = 0xFF;
        abyFrame[3] = 0xFF;
        abyFrame[5] = (BYTE)unPGN;
        abyFrame[6] = (BYTE)(unPGN >> 8);
        abyFrame[7] = (BYTE)(unPGN >> 16);
        pManager->vSendMessage(unChannel, MSG_TYPE_ACKNOWLEDGEMENT,
                               unPGN, abyFrame, 0, DEFAULT_PRIORITY, byAddresAck);
    }
コード例 #6
0
/**
 * \brief Commands a node with perticular NAME to assume a address.
 * \req RSI_26_015 - DILJ_NM_CommandAddress
 * \param[in] dwClientId Already register node's client Id
 * \param[in] unChannel Channel number
 * \param[in] unECU_NAME 64 bit ECU NAME of the destination node
 * \param[in] byDestAddress Destination Address
 * \param[in] byPriority Priority (0 - 7)
 * \return S_OK if successful, else S_FALSE.
 *
 * A node commands another node to assume an address.
 */
USAGEMODE HRESULT DILJ_NM_CommandAddress(DWORD dwClient, UINT unChannel, UINT64 unECU_NAME, 
                                         BYTE byNewAddress, BYTE byPriority, BYTE bySrc, BYTE byDestAddress)
{
    HRESULT hResult = S_FALSE; 
    CNodeConManager* pManager = NULL;
    pManager = CNetworkMgmt::ouGetNWManagementObj().pouGetConMagrObj(dwClient);
    if (NULL != pManager && pManager->bIsActive())
    {
        hResult = S_OK;
        if (pManager->bIsMonitorNode())
        {
            pManager->vSetNodeAddress(bySrc);
        }
        BYTE abyFrame[DATA_LEN_CMD_ADDRESS]  = {0xFF};
        memcpy(abyFrame, &unECU_NAME, MAX_FRAME_DATA_SIZE);
        abyFrame[DATA_LEN_CMD_ADDRESS - 1] = byNewAddress;
        pManager->vSendMessage(unChannel, MSG_TYPE_NM_CMD_ADDRESS, 0, abyFrame, DATA_LEN_CMD_ADDRESS, byPriority, byDestAddress);
    }
    return hResult;
}