예제 #1
0
 static private void ConnectAllDevices(J2534Library DLL)
 {
     //If the DLL successfully executes GetNextCarDAQ_RESET()
     if (DLL.GetNextCarDAQ_RESET().IsOK)
     {
         GetNextCarDAQResults TargetDrewtechDevice = DLL.GetNextCarDAQ();
         while (TargetDrewtechDevice.Exists)
         {
             J2534Device ThisDevice = DLL.ConstructDevice(TargetDrewtechDevice);
             if (ThisDevice.IsConnected) //This should always succeed.
             {                           //To avoid populating the list with duplicate devices due to disconnection
                 //Remove any unconnected devices that are attached to this library.
                 PhysicalDevices.RemoveAll(Listed => Listed.DeviceName == ThisDevice.DeviceName);
                 PhysicalDevices.Add(ThisDevice);
             }
             TargetDrewtechDevice = DLL.GetNextCarDAQ();
         }
     }
     //If its not a drewtech library, then attempt to connect a device
     else
     {
         J2534Device ThisDevice = DLL.ConstructDevice();
         if (ThisDevice.IsConnected)
         {   //To avoid populating the list with duplicate devices due to disconnection
             //Remove any unconnected devices that are attached to this library.
             PhysicalDevices.RemoveAll(Listed => (Listed.Library == ThisDevice.Library) && !Listed.IsConnected);
             PhysicalDevices.Add(ThisDevice);
         }
     }
 }
예제 #2
0
        public J2534Device(J2534.J2534Device jport, ILogger logger) : base(logger)
        {
            J2534Port              = new J2534_Struct();
            J2534Port.Functions    = new J2534Extended();
            J2534Port.LoadedDevice = jport;

            this.MaxSendSize    = 4096 + 10 + 2; // Driver or protocol limit?
            this.MaxReceiveSize = 4096 + 10 + 2; // Driver or protocol limit?
            this.Supports4X     = true;
        }
예제 #3
0
        public J2534Device(J2534.J2534Device jport, ILogger logger) : base(logger)
        {
            J2534Port              = new J2534_Struct();
            J2534Port.Functions    = new J2534Extended();
            J2534Port.LoadedDevice = jport;

            this.MaxSendSize    = 12;    // Driver or protocol limit?
            this.MaxReceiveSize = 12;    // Driver or protocol limit?
            this.Supports4X     = false; // TODO: add code to support the switch to 4x and update this flag
        }
예제 #4
0
 //Channel Constructor
 internal Channel(J2534Device Device, J2534PROTOCOL ProtocolID, J2534BAUD Baud, J2534CONNECTFLAG ConnectFlags)
 {
     HeapMessageArray  = new J2534HeapMessageArray(CONST.HEAPMESSAGEBUFFERSIZE);
     this.Device       = Device;
     this.ProtocolID   = ProtocolID;
     this.Baud         = (int)Baud;
     this.ConnectFlags = ConnectFlags;
     DefaultTxTimeout  = 50;
     DefaultRxTimeout  = 250;
     DefaultTxFlag     = J2534TXFLAG.NONE;
     Connect();
 }
예제 #5
0
 /// <summary>
 /// load in dll
 /// </summary>
 private Response <bool> LoadLibrary(J2534.J2534Device TempDevice)
 {
     ToolName = TempDevice.Name;
     J2534Port.LoadedDevice = TempDevice;
     if (J2534Port.Functions.LoadLibrary(J2534Port.LoadedDevice))
     {
         return(Response.Create(ResponseStatus.Success, true));
     }
     else
     {
         return(Response.Create(ResponseStatus.Error, false));
     }
 }
예제 #6
0
        /// <summary>
        /// Find all installed J2534 DLLs
        /// </summary>
        public static List <J2534.J2534Device> FindInstalledJ2534DLLs(ILogger logger)
        {
            List <J2534.J2534Device> installedDLLs = new List <J2534.J2534Device>();

            try
            {
                RegistryKey myKey = Registry.LocalMachine.OpenSubKey(PASSTHRU_REGISTRY_PATH, false);
                if ((myKey == null))
                {
                    myKey = Registry.LocalMachine.OpenSubKey(PASSTHRU_REGISTRY_PATH_6432, false);
                    if ((myKey == null))
                    {
                        return(installedDLLs);
                    }
                }

                string[] devices = myKey.GetSubKeyNames();
                foreach (string device in devices)
                {
                    J2534.J2534Device tempDevice = new J2534.J2534Device();
                    RegistryKey       deviceKey  = myKey.OpenSubKey(device);
                    if ((deviceKey == null))
                    {
                        continue; //Skip device... its empty
                    }

                    tempDevice.Vendor            = (string)deviceKey.GetValue("Vendor", "");
                    tempDevice.Name              = (string)deviceKey.GetValue("Name", "");
                    tempDevice.ConfigApplication = (string)deviceKey.GetValue("ConfigApplication", "");
                    tempDevice.FunctionLibrary   = (string)deviceKey.GetValue("FunctionLibrary", "");
                    tempDevice.CAN          = (int)(deviceKey.GetValue("CAN", 0));
                    tempDevice.ISO14230     = (int)(deviceKey.GetValue("ISO14230", 0));
                    tempDevice.ISO15765     = (int)(deviceKey.GetValue("ISO15765", 0));
                    tempDevice.ISO9141      = (int)(deviceKey.GetValue("ISO9141", 0));
                    tempDevice.J1850PWM     = (int)(deviceKey.GetValue("J1850PWM", 0));
                    tempDevice.J1850VPW     = (int)(deviceKey.GetValue("J1850VPW", 0));
                    tempDevice.SCI_A_ENGINE = (int)(deviceKey.GetValue("SCI_A_ENGINE", 0));
                    tempDevice.SCI_A_TRANS  = (int)(deviceKey.GetValue("SCI_A_TRANS", 0));
                    tempDevice.SCI_B_ENGINE = (int)(deviceKey.GetValue("SCI_B_ENGINE", 0));
                    tempDevice.SCI_B_TRANS  = (int)(deviceKey.GetValue("SCI_B_TRANS", 0));
                    installedDLLs.Add(tempDevice);
                }
                return(installedDLLs);
            }
            catch (Exception exception)
            {
                logger.AddDebugMessage("Error occured while finding installed J2534 devices");
                logger.AddDebugMessage(exception.ToString());
                return(installedDLLs);
            }
        }