コード例 #1
0
        public long CanTpCreateConnection(string appName, uint appChannel, XLDefine.XL_HardwareType hwType, uint hwIndex, uint hwChannel, XLDefine.XL_BusTypes busType)
        {
            XLDefine.XL_Status status;

            status = CANTPDriver.XL_OpenDriver();
            Console.WriteLine("Open Driver       : " + status);
            if (status != XLDefine.XL_Status.XL_SUCCESS)
            {
                return(-1);
            }

            status = CANTPDriver.XL_SetApplConfig(appName, appChannel, hwType, hwIndex, hwChannel, busType);
            Console.WriteLine("SetApplConfig      : " + status);
            if (status != XLDefine.XL_Status.XL_SUCCESS)
            {
                return(-2);
            }
            accessMask     = CANTPDriver.XL_GetChannelMask(hwType, (int)hwIndex, (int)hwChannel);
            permissionMask = accessMask;
            txMask         = accessMask;

            status = CANTPDriver.XL_OpenPort(ref portHandle, appName, accessMask, ref permissionMask, 1024, XLDefine.XL_InterfaceVersion.XL_INTERFACE_VERSION, XLDefine.XL_BusTypes.XL_BUS_TYPE_CAN);
            Console.WriteLine("Open Port      : " + status);
            if (status != XLDefine.XL_Status.XL_SUCCESS)
            {
                return(-3);
            }

            status = CANTPDriver.XL_CanRequestChipState(portHandle, accessMask);
            Console.WriteLine("Can Request Chip State: " + status);
            if (status != XLDefine.XL_Status.XL_SUCCESS)
            {
                return(-4);
            }

            status = CANTPDriver.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)
            {
                return(-5);
            }

            status = CANTPDriver.XL_SetNotification(portHandle, ref eventHandle, 1);
            Console.WriteLine("Set Notification      : " + status);
            if (status != XLDefine.XL_Status.XL_SUCCESS)
            {
                return(-6);
            }

            status = CANTPDriver.XL_ResetClock(portHandle);
            Console.WriteLine("Reset Clock           : " + status + "\n\n");
            if (status != XLDefine.XL_Status.XL_SUCCESS)
            {
                return(-7);
            }

            Console.WriteLine("Start Rx thread...");
            rxThread = new Thread(new ThreadStart(CanTp_ReceptionInd));
            rxThread.Start();

            return(0);
        }
コード例 #2
0
 public DiagCommonClass(uint txID, uint rxID, byte blockSize, byte stmin, byte paddingValue,
                        string appName, uint appChannel, XLDefine.XL_HardwareType hwType, uint hwIndex, uint hwChannel, XLDefine.XL_BusTypes busType)
 {
     CANTPHandle = new CANTP(txID, rxID, blockSize, stmin, paddingValue);
     CANTPHandle.CanTpCreateConnection(appName, 0, XLDefine.XL_HardwareType.XL_HWTYPE_VIRTUAL, 0, 0, XLDefine.XL_BusTypes.XL_BUS_TYPE_CAN);
     CANTPHandle.CanTpOnDiagPDURecedEvent += diagResponseReceived;
     diagResponseReceivedEvent[0]          = diagNormalReceivedEvent;
     diagResponseReceivedEvent[1]          = diagPaddingReceivedEvent;
 }