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)); }
public J2534ERR ConnectToDevice(string Device) { J2534ERR Status; IntPtr pDeviceName = IntPtr.Zero; if (!string.IsNullOrEmpty(Device)) { pDeviceName = Marshal.StringToHGlobalAnsi(Device); } else { DeviceName = string.Format("Device {0}", J2534Discovery.PhysicalDevices.FindAll(Listed => Listed.Library == this.Library).Count + 1); } J2534HeapInt DeviceID = new J2534HeapInt(); lock (Library.API_LOCK) { Status = (J2534ERR)Library.API.Open(pDeviceName, DeviceID); Marshal.FreeHGlobal(pDeviceName); if (Status == J2534ERR.STATUS_NOERROR || (Library.API_Signature.SAE_API == SAE_API.V202_SIGNATURE && J2534Discovery.PhysicalDevices.FindAll(Listed => Listed.Library == this.Library).Count == 0 && IsConnected)) { this.DeviceID = DeviceID; ValidDevice = true; GetVersion(); } return(Status); } }
/// <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)); }
public void PopulateWith(J2534PROTOCOL ProtocolID, J2534TXFLAG TxFlags, byte[] Data) { Length = 1; Marshal.WriteInt32(pMessages, (int)ProtocolID); Marshal.WriteInt32(pMessages, 8, (int)TxFlags); Marshal.WriteInt32(pMessages, 16, Data.Length); Marshal.Copy(Data, 0, IntPtr.Add(pMessages, 24), Data.Length); }
public void PopulateWith(List <J2534Message> Messages) { Length = Messages.Count; for (int i = 0; i < Messages.Count; i++) { this[i] = Messages[i]; } }
public J2534HeapMessageArray(int Length) { if (Length < 1) { throw new ArgumentException("Length must be at least 1 (HEAPMessageArray"); } array_max_length = Length; length = new J2534HeapInt(); pMessages = Marshal.AllocHGlobal(CONST.J2534MESSAGESIZE * Length); }
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); }
public int MeasureProgrammingVoltage() { J2534ERR Status; J2534HeapInt Voltage = new J2534HeapInt(); lock (Library.API_LOCK) { Status = (J2534ERR)Library.API.IOCtl(DeviceID, (int)J2534IOCTL.READ_PROG_VOLTAGE, IntPtr.Zero, Voltage); if (Status != J2534ERR.STATUS_NOERROR) { throw new J2534Exception(Status, Library.GetLastError()); } return(Voltage); } }
public int MeasureProgrammingVoltage() { J2534Status Status = new J2534Status(); J2534HeapInt Voltage = new J2534HeapInt(); lock (Library.API_LOCK) { Status.Code = Library.API.IOCtl(DeviceID, (int)J2534IOCTL.READ_PROG_VOLTAGE, IntPtr.Zero, Voltage); if (Status.IsNotOK) { Status.Description = Library.GetLastError(); throw new J2534Exception(Status); } return(Voltage); } }
private void Connect() { J2534HeapInt ChannelID = new J2534HeapInt(); lock (Device.Library.API_LOCK) { ConnectionStatus = (J2534ERR)Device.Library.API.Connect(Device.DeviceID, (int)ProtocolID, (int)ConnectFlags, Baud, ChannelID); if (ConnectionStatus == J2534ERR.STATUS_NOERROR) { IsOpen = true; this.ChannelID = ChannelID; } //else // throw new J2534Exception(Status, Device.Library.GetLastError()); } }
public int MeasureBatteryVoltage() { if (Device.Library.API_Signature.SAE_API == SAE_API.V202_SIGNATURE) { J2534ERR Status; J2534HeapInt Voltage = new J2534HeapInt(); lock (Device.Library.API_LOCK) { Status = (J2534ERR)Device.Library.API.IOCtl(ChannelID, (int)J2534IOCTL.READ_VBATT, IntPtr.Zero, Voltage); if (Status != J2534ERR.STATUS_NOERROR) { throw new J2534Exception(Status, Device.Library.GetLastError()); } return(Voltage); } } return(Device.MeasureBatteryVoltage()); }
private void Connect() { J2534HeapInt ChannelID = new J2534HeapInt(); lock (Device.Library.API_LOCK) { ConnectionStatus.Code = Device.Library.API.Connect(Device.DeviceID, (int)ProtocolID, (int)ConnectFlags, Baud, ChannelID.Ptr); if (ConnectionStatus.IsOK) { IsOpen = true; this.ChannelID = ChannelID; } else { ConnectionStatus.Description = Device.Library.GetLastError(); } } }
public int MeasureBatteryVoltage() { if (Device.Library.API_Signature.SAE_API == SAE_API.V202_SIGNATURE) { J2534Status Status = new J2534Status(); J2534HeapInt Voltage = new J2534HeapInt(); lock (Device.Library.API_LOCK) { Status.Code = Device.Library.API.IOCtl(ChannelID, (int)J2534IOCTL.READ_VBATT, IntPtr.Zero, Voltage.Ptr); if (Status.IsNotOK) { Status.Description = Device.Library.GetLastError(); throw new J2534Exception(Status); } return(Voltage); } } return(Device.MeasureBatteryVoltage()); }
public int MeasureBatteryVoltage() { J2534ERR Status; J2534HeapInt Voltage = new J2534HeapInt(); lock (Library.API_LOCK) { Status = (J2534ERR)Library.API.IOCtl(DeviceID, (int)J2534IOCTL.READ_VBATT, IntPtr.Zero, Voltage); if (Status != J2534ERR.STATUS_NOERROR) { throw new J2534Exception(Status, Library.GetLastError()); } //The return was kept inside the lock here to ensure the conversion to INT is done before the //lock is released. This is in case the API reuses the Ptr location for this data on subsequent //calls. In that case, two back to back calls could interfere with each other of the second //call is allowed to execute before the first call marshals the Int from the heap. return(Voltage); } }
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); }
public J2534HeapMessageArray(int Length) { array_max_length = Length; length = new J2534HeapInt(); pMessages = Marshal.AllocHGlobal(CONST.J2534MESSAGESIZE * Length); }
public void PopulateWith(J2534Message Message) { Length = 1; this[0] = Message; }