示例#1
0
        /// <summary>
        /// Starts a single message filter and if successful, adds it to the FilterList.
        /// </summary>
        /// <param name="Filter"></param>
        /// <returns>Returns false if successful</returns>
        public int StartMsgFilter(MessageFilter Filter)
        {
            J2534Status  Status   = new J2534Status();
            J2534HeapInt FilterID = new J2534HeapInt();

            J2534HeapMessage Mask        = new J2534HeapMessage(ProtocolID, Filter.TxFlags, Filter.Mask);
            J2534HeapMessage Pattern     = new J2534HeapMessage(ProtocolID, Filter.TxFlags, Filter.Pattern);
            J2534HeapMessage FlowControl = new J2534HeapMessage(ProtocolID, Filter.TxFlags, Filter.FlowControl);

            lock (Device.Library.API_LOCK)
            {
                Status.Code = Device.Library.API.StartMsgFilter(ChannelID,
                                                                (int)Filter.FilterType,
                                                                Mask.Ptr,
                                                                Pattern.Ptr,
                                                                Filter.FilterType == J2534FILTER.FLOW_CONTROL_FILTER ? FlowControl.Ptr : IntPtr.Zero,
                                                                FilterID.Ptr);
                if (Status.IsNotOK)
                {
                    Status.Description = Device.Library.GetLastError();
                    throw new J2534Exception(Status);
                }
                filterlist.Add(Filter);
            }
            return(filterlist.IndexOf(Filter));
        }
示例#2
0
        public int StartPeriodicMessage(PeriodicMsg PeriodicMessage)
        {
            J2534Status  Status    = new J2534Status();
            J2534HeapInt MessageID = new J2534HeapInt();

            J2534HeapMessage PeriodicMessageHeap = new J2534HeapMessage(ProtocolID,
                                                                        PeriodicMessage.Message.TxFlags,
                                                                        PeriodicMessage.Message.Data);

            lock (Device.Library.API_LOCK)
            {
                Status.Code = Device.Library.API.StartPeriodicMsg(ChannelID,
                                                                  PeriodicMessageHeap.Ptr,
                                                                  MessageID.Ptr,
                                                                  PeriodicMessage.Interval);
                if (Status.IsNotOK)
                {
                    Status.Description = Device.Library.GetLastError();
                    throw new J2534Exception(Status);
                }
                PeriodicMessage.MessageID = MessageID;
                PeriodicMsgList.Add(PeriodicMessage);
            }
            return(PeriodicMsgList.IndexOf(PeriodicMessage));
        }
示例#3
0
        private J2534ERR StartPeriodicMessage(int Index)
        {
            J2534ERR Status;

            J2534HeapInt MessageID = new J2534HeapInt();

            J2534HeapMessage Message = new J2534HeapMessage(PeriodicMsgList[Index].Message);

            Status = (J2534ERR)Device.Library.API.StartPeriodicMsg(ChannelID, Message, MessageID, PeriodicMsgList[Index].Interval);

            PeriodicMsgList[Index].MessageID = MessageID;
            return(Status);
        }
示例#4
0
        public J2534Message FastInit(J2534Message TxMessage)
        {
            J2534ERR         Status;
            J2534HeapMessage Input  = new J2534HeapMessage(TxMessage);
            J2534HeapMessage Output = new J2534HeapMessage();

            lock (Device.Library.API_LOCK)
            {
                Status = (J2534ERR)Device.Library.API.IOCtl(ChannelID, (int)J2534IOCTL.FAST_INIT, Input, Output);
                if (Status != J2534ERR.STATUS_NOERROR)
                {
                    throw new J2534Exception(Status, Device.Library.GetLastError());
                }
                return(Output);
            }
        }
示例#5
0
        public J2534Message FastInit(J2534Message TxMessage)
        {
            J2534Status      Status = new J2534Status();
            J2534HeapMessage Input  = new J2534HeapMessage(ProtocolID, TxMessage.TxFlags, TxMessage.Data);
            J2534HeapMessage Output = new J2534HeapMessage();

            lock (Device.Library.API_LOCK)
            {
                Status.Code = Device.Library.API.IOCtl(ChannelID, (int)J2534IOCTL.FAST_INIT, Input.Ptr, Output.Ptr);
                if (Status.IsNotOK)
                {
                    Status.Description = Device.Library.GetLastError();
                    throw new J2534Exception(Status);
                }
                return(Output);
            }
        }
示例#6
0
        private J2534ERR StartMsgFilter(int Index)
        {
            J2534ERR     Status;
            J2534HeapInt FilterID = new J2534HeapInt();

            J2534HeapMessage Mask        = new J2534HeapMessage(new J2534Message(ProtocolID, FilterList[Index].TxFlags, FilterList[Index].Mask));
            J2534HeapMessage Pattern     = new J2534HeapMessage(new J2534Message(ProtocolID, FilterList[Index].TxFlags, FilterList[Index].Pattern));
            J2534HeapMessage FlowControl = new J2534HeapMessage(new J2534Message(ProtocolID, FilterList[Index].TxFlags, FilterList[Index].FlowControl));

            //The lock is performed in the calling method to protect the 'FilterList' coherency.
            if (FilterList[Index].FilterType == J2534FILTER.FLOW_CONTROL_FILTER)
            {
                Status = (J2534ERR)Device.Library.API.StartMsgFilter(ChannelID, (int)FilterList[Index].FilterType, Mask, Pattern, FlowControl, FilterID);
            }
            else
            {
                Status = (J2534ERR)Device.Library.API.StartMsgFilter(ChannelID, (int)FilterList[Index].FilterType, Mask, Pattern, IntPtr.Zero, FilterID);
            }

            FilterList[Index].FilterId = FilterID;
            return(Status);
        }