void CSocketSelectDlg::SocketListUpdate( ) { VCIDEVICECAPS sDevCaps; TCHAR szText[32]; SendItemMessage(IDC_SOCLIST, CB_RESETCONTENT, 0, 0); EnableControl(IDC_SOCLIST, FALSE); if (vciDeviceGetCaps(m_hCurDev, &sDevCaps) == VCI_OK) { char cNumCtls = 0; for (UINT8 s = 0; s < sDevCaps.BusCtrlCount; s++) { if (VCI_BUS_TYPE(sDevCaps.BusCtrlTypes[s]) == m_BusType) { switch (m_BusType) { case VCI_BUS_CAN: wsprintf(szText, TEXT("CAN - %c"), cNumCtls + 'A'); break; case VCI_BUS_LIN: wsprintf(szText, TEXT("LIN - %c"), cNumCtls + 'A'); break; } cNumCtls++; SendItemMessage(IDC_SOCLIST, CB_ADDSTRING, 0, (LPARAM) szText); } } EnableControl(IDC_SOCLIST, cNumCtls > 0); } }
/** * @brief * Add the CAN controller information of all IXXAT VCI * devices to the array with the hardware information. * * @param [in] iStartPosArray * The start position array where to write the data into. * @param [in] pVciDevInfo * If non-null, information describing the current VCI device * found by the device enumerator. * @param [out] sSelHwInterface * The array with the information of all hardware interfaces. * * @return * The number of found CAN controllers. The calling function * must use this value to increment the current position in * the hardware array. */ int CDIL_CAN_IXXAT_VCI::VciDeviceInfoAddToArray(int iStartPosArray, VCIDEVICEINFO* pVciDevInfo, INTERFACE_HW_LIST& sSelHwInterface) { int iNumOfCANController = 0; HANDLE hDevice = nullptr; VCIDEVICECAPS sVciDeviceCaps; // try to open the VCI device if ( VCI_OK == DYNCALL(vciDeviceOpen)(pVciDevInfo->VciObjectId, &hDevice) ) { // try to get the capabilities of the current open device to check // the number and type of the CAN controller to add it to the // program global device array. if ( VCI_OK == DYNCALL(vciDeviceGetCaps)(hDevice, &sVciDeviceCaps) ) { for (int i=0; i < sVciDeviceCaps.BusCtrlCount; i++) { if (VCI_BUS_CAN == VCI_BUS_TYPE(sVciDeviceCaps.BusCtrlTypes[i])) { iNumOfCANController++; // store the current information in our class internal structure m_arrTmpIxxatCanChannels[iStartPosArray].SetHardwareParams(pVciDevInfo->VciObjectId.AsInt64, i, &m_ClientList); sSelHwInterface[iStartPosArray].m_dwIdInterface = iStartPosArray; sSelHwInterface[iStartPosArray].m_bytNetworkID = (BYTE) i; ///< Controller number inside this device. sSelHwInterface[iStartPosArray].m_dwVendor = 0; // always 0 //strcpy_s(sSelHwInterface[iStartPosArray].m_acDeviceName, MAX_CHAR_SHORT, pVciDevInfo->Description); // the name of the device sSelHwInterface[iStartPosArray].m_acDeviceName = pVciDevInfo->Description; // the name of the device std::ostringstream oss; oss<<"CAN "<<i; sSelHwInterface[iStartPosArray].m_acNameInterface = oss.str(); // if the cantype.h from IXXAT was enhanced then add the new hardware descriptions here switch (VCI_CTL_TYPE(sVciDeviceCaps.BusCtrlTypes[i])) { case CAN_CTRL_82527: //strcpy_s( sSelHwInterface[iStartPosArray].m_acDescription, MAX_CHAR_LONG, "Intel 82527" ); sSelHwInterface[iStartPosArray].m_acDescription = "Intel 82527"; break; case CAN_CTRL_82C200: //strcpy_s( sSelHwInterface[iStartPosArray].m_acDescription, MAX_CHAR_LONG, "Intel 82C200" ); sSelHwInterface[iStartPosArray].m_acDescription = "Intel 82C200"; break; case CAN_CTRL_82C90: //strcpy_s( sSelHwInterface[iStartPosArray].m_acDescription, MAX_CHAR_LONG, "Intel 82C90" ); sSelHwInterface[iStartPosArray].m_acDescription = "Intel 82C90"; break; case CAN_CTRL_82C92: //strcpy_s( sSelHwInterface[iStartPosArray].m_acDescription, MAX_CHAR_LONG, "Intel 82C92" ); sSelHwInterface[iStartPosArray].m_acDescription = "Intel 82C92"; break; case CAN_CTRL_SJA1000: //strcpy_s( sSelHwInterface[iStartPosArray].m_acDescription, MAX_CHAR_LONG, "Philips SJA 1000" ); sSelHwInterface[iStartPosArray].m_acDescription = "Philips SJA 1000"; break; case CAN_CTRL_82C900: //strcpy_s( sSelHwInterface[iStartPosArray].m_acDescription, MAX_CHAR_LONG, "Infinion 82C900 (TwinCAN)" ); sSelHwInterface[iStartPosArray].m_acDescription = "Infinion 82C900 (TwinCAN)"; break; case CAN_CTRL_TOUCAN: //strcpy_s( sSelHwInterface[iStartPosArray].m_acDescription, MAX_CHAR_LONG, "Motorola TOUCAN" ); sSelHwInterface[iStartPosArray].m_acDescription = "Motorola TOUCAN"; break; case CAN_CTRL_IFI: //strcpy_s( sSelHwInterface[iStartPosArray].m_acDescription, MAX_CHAR_LONG, "IFI-CAN" ); sSelHwInterface[iStartPosArray].m_acDescription = "IFI-CAN"; break; default: //strcpy_s( sSelHwInterface[iStartPosArray].m_acDescription, MAX_CHAR_LONG, _("unknown CAN controller") ); sSelHwInterface[iStartPosArray].m_acDescription = "unknown CAN controller"; break; } // jump to the next array entry iStartPosArray++; if (iStartPosArray >= CHANNEL_CAN_MAX) { LogMessage(FALSE, _("Too many IXXAT CAN controllers found. Abort filling hardware list!")); break; } } } } // close the formerly opened device for later use DYNCALL(vciDeviceClose)(hDevice); hDevice = nullptr; } // return the number of found CAN controllers return iNumOfCANController; }
/** * @brief * Add the CAN controller information of all IXXAT VCI * devices to the array with the hardware information. * * @param [in,out] iStartPosArray * The start position array where to write the data into. * The veriable will be inremented at every found CAN controller * @param [in] pVciDevInfo * If non-null, information describing the current VCI device * found by the device enumerator. * @param [out] sSelHwInterface * The array with the information of all hardware interfaces. * * @return * The number of found CAN controllers. The calling function * must use this value to increment the current position in * the hardware array. */ int CDIL_CAN_IXXAT_VCI::VciDeviceInfoAddToArray(INT& nStartPosArray, VCIDEVICEINFO* pVciDevInfo, INTERFACE_HW_LIST& sSelHwInterface) { int iNumOfCANController = 0; HANDLE hDevice = nullptr; VCIDEVICECAPS sVciDeviceCaps; // try to open the VCI device if ( VCI_OK == DYNCALL(vciDeviceOpen)(pVciDevInfo->VciObjectId, &hDevice) ) { // try to get the capabilities of the current open device to check // the number and type of the CAN controller to add it to the // program global device array. if ( VCI_OK == DYNCALL(vciDeviceGetCaps)(hDevice, &sVciDeviceCaps) ) { for (int i=0; i < sVciDeviceCaps.BusCtrlCount; i++) { #ifdef _IXXAT_DEBUG LogMessage(TRUE, "------> Interface: %s BusCtrl No.: %u Type: 0x%.4X\n", pVciDevInfo->Description, i, sVciDeviceCaps.BusCtrlTypes[i]); #endif if (VCI_BUS_CAN == VCI_BUS_TYPE(sVciDeviceCaps.BusCtrlTypes[i])) { iNumOfCANController++; #ifdef _IXXAT_DEBUG LogMessage(TRUE, "------> iNumOfCANController: %u\n", iNumOfCANController); #endif // store the current information in our class internal structure m_arrTmpIxxatCanChannels[nStartPosArray].SetHardwareParams(pVciDevInfo->VciObjectId.AsInt64, i, &m_ClientList); sSelHwInterface[nStartPosArray].m_dwIdInterface = nStartPosArray; sSelHwInterface[nStartPosArray].m_bytNetworkID = (BYTE)i; ///< Controller number inside this device. sSelHwInterface[nStartPosArray].m_dwVendor = 0; // always 0 //strcpy_s(sSelHwInterface[iStartPosArray].m_acDeviceName, MAX_CHAR_SHORT, pVciDevInfo->Description); // the name of the device sSelHwInterface[nStartPosArray].m_acDeviceName = pVciDevInfo->Description; // the name of the device std::ostringstream oss; oss<<"CAN "<<i; sSelHwInterface[nStartPosArray].m_acNameInterface = oss.str(); // if the cantype.h from IXXAT was enhanced then add the new hardware descriptions here switch (VCI_CTL_TYPE(sVciDeviceCaps.BusCtrlTypes[i])) { case CAN_CTRL_82527: sSelHwInterface[nStartPosArray].m_acDescription = "Intel 82527"; break; case CAN_CTRL_82C200: sSelHwInterface[nStartPosArray].m_acDescription = "Intel 82C200"; break; case CAN_CTRL_81C90: sSelHwInterface[nStartPosArray].m_acDescription = "Intel 81C90"; break; case CAN_CTRL_81C92: sSelHwInterface[nStartPosArray].m_acDescription = "Intel 81C92"; break; case CAN_CTRL_SJA1000: sSelHwInterface[nStartPosArray].m_acDescription = "Philips SJA 1000"; break; case CAN_CTRL_82C900: sSelHwInterface[nStartPosArray].m_acDescription = "Infinion 82C900 (TwinCAN)"; break; case CAN_CTRL_TOUCAN: sSelHwInterface[nStartPosArray].m_acDescription = "Motorola TOUCAN"; break; case CAN_CTRL_MSCAN: // Freescale Star12 MSCAN sSelHwInterface[nStartPosArray].m_acDescription = "Freescale Star12 MSCAN"; break; case CAN_CTRL_FLEXCAN: // Freescale FlexCAN sSelHwInterface[nStartPosArray].m_acDescription = "Freescale FlexCAN"; break; case CAN_CTRL_IFICAN: sSelHwInterface[nStartPosArray].m_acDescription = "IFI-CAN"; break; case CAN_CTRL_BCCAN: // Bosch C_CAN sSelHwInterface[nStartPosArray].m_acDescription = "Bosch C_CAN"; break; case CAN_CTRL_BXCAN: // ST BX_CAN sSelHwInterface[nStartPosArray].m_acDescription = "ST BX_CAN"; break; case CAN_CTRL_IFICFD: // IFI CAN FD Controller sSelHwInterface[nStartPosArray].m_acDescription = "IFI CAN FD"; break; case CAN_CTRL_BMCAN: // Bosch M_CAN sSelHwInterface[nStartPosArray].m_acDescription = "Bosch M_CAN"; break; // end default: sSelHwInterface[nStartPosArray].m_acDescription = "Unknown CAN controller"; break; } // jump to the next array entry nStartPosArray++; if (nStartPosArray >= CHANNEL_CAN_MAX) { LogMessage(FALSE, _("Too many IXXAT CAN controllers found. Abort filling hardware list!")); break; } } #ifdef _IXXAT_DEBUG else { // TODO remove LogMessage(TRUE, "------> Not Added! Interface: %s BusCtrl No.: %u Type: 0x%.4X\n", pVciDevInfo->Description, i, sVciDeviceCaps.BusCtrlTypes[i]); } #endif } } // close the formerly opened device for later use DYNCALL(vciDeviceClose)(hDevice); hDevice = nullptr; } // return the number of found CAN controllers return iNumOfCANController; }