Exemple #1
0
 private PassThruStream(string passThruDllPath)
 {
     if (passThruDllPath == "Mock")
     {
         this.passThru = new MockPassThru();
     }
     else
     {
         this.passThru = DynamicPassThru.GetInstance(passThruDllPath);
     }
 }
Exemple #2
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 #3
0
 private SsmPassThruTransport(string passThruDllPath)
 {
     this.passThru = DynamicPassThru.GetInstance(passThruDllPath);
 }
Exemple #4
0
 /// <summary>
 /// Creates a PassThruDevice
 /// </summary>
 public static PassThruDevice GetInstance(IPassThru implementation)
 {
     return(new PassThruDevice(implementation));
 }
Exemple #5
0
 /// <summary>
 /// Private constructor to force consumers to use GetInstance
 /// </summary>
 private PassThruDevice(IPassThru implementation)
 {
     this.implementation = implementation;
 }
Exemple #6
0
 /// <summary>
 /// Factory, should only be called from PassThruDevice.Connect
 /// </summary>
 internal static PassThruChannel GetInstance(IPassThru implementation, UInt32 channelId)
 {
     return(new PassThruChannel(implementation, channelId));
 }
Exemple #7
0
 /// <summary>
 /// Private constructor to force consumers to use the factory method
 /// </summary>
 private PassThruChannel(IPassThru implementation, UInt32 channelId)
 {
     this.implementation = implementation;
     this.channelId      = channelId;
 }