public VectorCan() { CANDriver = new XLDriver(); driverConfig = new XLClass.xl_driver_config(); hwType = XLDefine.XL_HardwareType.XL_HWTYPE_NONE; xlEvWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, null); info = "vxlapi_NET : " + typeof(XLDriver).Assembly.GetName().Version + "\n"; }
public VectorHardware(XLDriver driver, XLClass.xl_driver_config driverConfig, String applicationName, int numberOfChannels) { this.driver = driver; this.driverConfig = driverConfig; this.applicationName = applicationName; this.numberOfChannels = numberOfChannels; this.accessMaskMaster = new ulong[numberOfChannels]; this.channelIndex = new int[numberOfChannels]; }
public XLInterface() { MessageTypes = new Dictionary <int, string>(); MessageTypes.Add(FULL_THROTTLE_ON, "Throttle On"); MessageTypes.Add(FULL_THROTTLE_OFF, "Throttle Off"); MessageTypes.Add(FULL_BRAKE_ON, "Brake On"); MessageTypes.Add(FULL_BRAKE_OFF, "Brake Off"); XLDefine.XL_Status status; driver = new XLDriver(); driverConfig = new XLClass.xl_driver_config(); driver.XL_GetDriverConfig(ref driverConfig); // If the application name cannot be found in VCANCONF... if ((driver.XL_GetApplConfig(appName, 0, ref hwType, ref hwIndex, ref hwChannel, XLDefine.XL_BusTypes.XL_BUS_TYPE_CAN) != XLDefine.XL_Status.XL_SUCCESS)) { //...create the item with two CAN channels status = driver.XL_SetApplConfig(appName, 0, XLDefine.XL_HardwareType.XL_HWTYPE_CANCASEXL, 0, 0, XLDefine.XL_BusTypes.XL_BUS_TYPE_CAN); Console.WriteLine(status); } // Read setting of CAN1 driver.XL_GetApplConfig(appName, 0, ref hwType, ref hwIndex, ref hwChannel, XLDefine.XL_BusTypes.XL_BUS_TYPE_CAN); // Notify user if no channel is assigned to this application if (hwType == XLDefine.XL_HardwareType.XL_HWTYPE_NONE) { PrintAssignError(); } accessMask = driver.XL_GetChannelMask(hwType, (int)hwIndex, (int)hwChannel); txMask = accessMask; // this channel is used for Tx PrintConfig(); permissionMask = accessMask; // Open port status = driver.XL_OpenPort(ref portHandle, appName, accessMask, ref permissionMask, 1024, XLDefine.XL_InterfaceVersion.XL_INTERFACE_VERSION, XLDefine.XL_BusTypes.XL_BUS_TYPE_CAN); Console.WriteLine("\n\nOpen Port : " + status); if (status != XLDefine.XL_Status.XL_SUCCESS) { PrintFunctionError(); } // Check port status = driver.XL_CanRequestChipState(portHandle, accessMask); Console.WriteLine("Can Request Chip State: " + status); if (status != XLDefine.XL_Status.XL_SUCCESS) { PrintFunctionError(); } // Activate channel status = driver.XL_ActivateChannel(portHandle, accessMask, XLDefine.XL_BusTypes.XL_BUS_TYPE_CAN, XLDefine.XL_AC_Flags.XL_ACTIVATE_NONE); Console.WriteLine("Activate Channel : " + status); if (status != XLDefine.XL_Status.XL_SUCCESS) { PrintFunctionError(); } // Reset time stamp clock status = driver.XL_ResetClock(portHandle); Console.WriteLine("Reset Clock : " + status + "\n\n"); if (status != XLDefine.XL_Status.XL_SUCCESS) { PrintFunctionError(); } }