Example #1
0
HRESULT CDIL_CAN_STUB::CAN_ResetHardware(void)
{
    // Clear the transmitable message list

    // Now disconnect the node
    return CAN_StopHardware();
}
Example #2
0
/**
* \brief         Performs closure operations.
* \param         void
* \return        S_OK if the CAN_StopHardware call successfull otherwise S_FALSE
*/
HRESULT CDIL_CAN_MHS::CAN_PerformClosureOperations(void)
{
HRESULT hResult = S_OK;

hResult = CAN_StopHardware();
// ------------------------------------
// Close driver
// ------------------------------------
CanDownDriver();

// Remove all the existing clients
while (sg_unClientCnt > 0)
  bRemoveClient(sg_asClientToBufMap[0].m_dwClientID);
/* Delete the critical section */
DeleteCriticalSection(&sg_DIL_CriticalSection);
sg_bCurrState = STATE_DRIVER_SELECTED;
return(hResult);
}
Example #3
0
/**
 * \return S_OK for success, S_FALSE for failure
 *
 * Sets the controller configuration data supplied by InitData.
 */
HRESULT CDIL_CAN_i_VIEW::CAN_SetConfigData(
    PSCONTROLLER_DETAILS    InitData,
    int         /*Length*/ )
{
    VALIDATE_VALUE_RETURN_VAL(m_CurrState, STATE_HW_INTERFACE_SELECTED, ERR_IMPROPER_STATE);
    CAN_StopHardware();

    for (UINT i = 0; i < m_nChannels; i++)
    {
        pVCI_t VCI = m_Channel[i];
        if (!VCI)
        {
            continue;
        }
        VCI->Baudrate( FromString<UNUM32>( InitData[i].m_omStrBaudrate ) );
        VCI->ClearFilters();
        for( UINT f=0; f<defCAN_MSG_IDS; f++ )
        {
            pFilter_t Filter=nullptr;
            UNUM8 Id[4]= {0,0,0,0}, Mask[4]= {0,0,0,0};
            if (InitData[i].m_enmHWFilterType[f]==HW_FILTER_MANUAL_SET)
            {
                Id[0] = (UNUM8)FromString<UNUM32>(InitData[i].m_omStrAccCodeByte1[f], true);
                Id[1] = (UNUM8)FromString<UNUM32>(InitData[i].m_omStrAccCodeByte2[f], true);
                Id[2] = (UNUM8)FromString<UNUM32>(InitData[i].m_omStrAccCodeByte3[f], true);
                Id[3] = (UNUM8)FromString<UNUM32>(InitData[i].m_omStrAccCodeByte4[f], true);
                Mask[0] = (UNUM8)FromString<UNUM32>(InitData[i].m_omStrAccMaskByte1[f], true);
                Mask[1] = (UNUM8)FromString<UNUM32>(InitData[i].m_omStrAccMaskByte2[f], true);
                Mask[2] = (UNUM8)FromString<UNUM32>(InitData[i].m_omStrAccMaskByte3[f], true);
                Mask[3] = (UNUM8)FromString<UNUM32>(InitData[i].m_omStrAccMaskByte4[f], true);
            }
            if (InitData[i].m_enmHWFilterType[f]!=HW_FILTER_REJECT_ALL)
            {
                pFilter_t Filter = new CFilter( VCI_PASS_FILTER,
                                                f==1?VCI_CAN_29BIT_ID:0,4,Id,Mask);
                VCI->AddFilter( Filter );
            }
        }
    }
    return S_OK;
}
Example #4
0
HRESULT CDIL_CAN_STUB::CAN_SetConfigData(PCHAR /*ConfigFile*/, int /*Length*/)
{
    switch (GetCurrState())
    {
        case STATE_REGISTERED:
        case STATE_CONNECTED:
        case STATE_INITIALISED:
        break;
        case STATE_PRIMORDIAL:
        case STATE_RESET:
        default:
        {
            strcpy(sg_acErrStr, "CAN_STUB_SetConfigData called at improper state");
            return S_FALSE;
        }
        break;
    }

    // First disconnect the node
    CAN_StopHardware();
    return S_OK;
}
Example #5
0
/**
 * Close doen the iView interface driver.
 * Remove all the clients and buffers.
 * Stop the mDNS browser deselect the interfaces and
 * delete all the registered VCIs.
 */
HRESULT CDIL_CAN_i_VIEW::CAN_PerformClosureOperations(void)
{
    VALIDATE_VALUE_RETURN_VAL(m_CurrState,
                              STATE_DRIVER_SELECTED, ERR_IMPROPER_STATE);
    pClientMap_t Clients = m_Clients;
    pClientMap_t::iterator CItr = Clients.begin();

    for (; CItr != Clients.end(); CItr++ )
    {
        DWORD Id = CItr->first;
        CAN_RegisterClient(FALSE, Id, nullptr);
    }

    if (m_iViewBrowser)
    {
        m_iViewBrowser->Stop();
        delete m_iViewBrowser;
    }

    if( m_CurrState == STATE_CONNECTED )
    {
        CAN_StopHardware();
    }
    CAN_DeselectHwInterface();

    EnterCriticalSection(&m_Mutex);
    pVCIMap_t::iterator VItr = m_VCI.begin();
    for (; VItr != m_VCI.end(); VItr++ )
    {
        delete VItr->second->VCiIF();
        delete VItr->second;
    }
    LeaveCriticalSection(&m_Mutex);
    DeleteCriticalSection(&m_Mutex);
    m_CurrState = STATE_DRIVER_LOADED;
    return S_OK;
}
Example #6
0
/**
* \brief         Resets the controller.
* \param         void
* \return        S_OK for success, S_FALSE for failure
*/
HRESULT CDIL_CAN_MHS::CAN_ResetHardware(void)
{
    (void)CAN_StopHardware();
    return(S_OK);
}