Exemple #1
0
 private PassThruStream(string passThruDllPath)
 {
     if (passThruDllPath == "Mock")
     {
         this.passThru = new MockPassThru();
     }
     else
     {
         this.passThru = DynamicPassThru.GetInstance(passThruDllPath);
     }
 }
Exemple #2
0
 public static bool OpenPort20Exists()
 {
     try
     {
         using (DynamicPassThru temp = DynamicPassThru.GetInstance("op20pt32.dll"))
         {
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemple #3
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                PrintUsage();
                return;
            }

            string    mode           = args[0];
            IPassThru implementation = null;

            if (mode.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
            {
                implementation = DynamicPassThru.GetInstance(mode);
            }
            else if (mode == "mock")
            {
                //Copy("J2534Mock.dll");
                //Copy("J2534Mock.pdb");
                implementation = new MockPassThru();
            }
            else if (mode == "op")
            {
                implementation = new OpenPort20PassThru();
            }
            else
            {
                PrintUsage();
                return;
            }

            Console.WriteLine("Opening device");
            PassThruDevice device = PassThruDevice.GetInstance(implementation);

            device.Open();

            Console.WriteLine("Opening channel");
            PassThruChannel channel = device.OpenChannel(
                PassThruProtocol.Iso9141,
                PassThruConnectFlags.Iso9141NoChecksum,
                PassThruBaudRate.Rate4800);

            Console.WriteLine("Initializing channel for SSM");
            channel.InitializeSsm();

            byte[]      messageBytes   = new byte[] { 0x80, 0x10, 0xF0, 0x01, 0xBF, 0x40 };
            PassThruMsg initRequestMsg = new PassThruMsg(PassThruProtocol.Iso9141);

            initRequestMsg.ProtocolID = PassThruProtocol.Iso9141;
            initRequestMsg.DataSize   = (UInt32)messageBytes.Length;
            for (int i = 0; i < messageBytes.Length; i++)
            {
                initRequestMsg.Data[i] = messageBytes[i];
            }

            //PassThruMsg[] initRequestMsgs = new PassThruMsg[] { initRequestMsg };
            //UInt32 numMsgs = 1;

            Console.WriteLine("Sending SSM init message");
            channel.WriteMessage(initRequestMsg, TimeSpan.FromMilliseconds(1000));

            PassThruMsg received = new PassThruMsg(PassThruProtocol.Iso9141);

            //PassThruMsg[] receivedMessages = new PassThruMsg[] { received };
            //UInt32 numMsgs = 1;

            Console.WriteLine("Waiting for SSM init response");
            bool success = channel.ReadMessage(
                received,
                TimeSpan.FromMilliseconds(1000));

            Console.WriteLine("ReadMessage success: " + success);

            Console.WriteLine("SSM init response:");
            string response = BitConverter.ToString(received.Data, 0, (int)received.DataSize);

            Console.WriteLine(response);

            Console.WriteLine("Closing channel");
            channel.Close();

            Console.WriteLine("Closing device");
            device.Close();
            implementation.Dispose();
        }
Exemple #4
0
 private SsmPassThruTransport(string passThruDllPath)
 {
     this.passThru = DynamicPassThru.GetInstance(passThruDllPath);
 }