예제 #1
0
        public void _0001_MALT132_TesterPresent()
        {
            UInt32 txId     = 0x15510403;
            UInt32 rxId     = 0x15520403;
            UInt32 baudRate = 250000;
            var    canLink  = new NiCanInterface("CAN0", true, txId, rxId, baudRate);

            canLink.Connect();
            canLink.BusTerminationEnable = true;
            canLink.Open();

            Iso15765NetwrorkLayer network = new Iso15765NetwrorkLayer(canLink);

            try
            {
                byte[] response;
                network.Transport(new byte[] { 0x3E, 0x00 }, out response);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                //network.SaveFrameLog("D:\\" + this.GetType().FullName + ".csv");
                canLink.Close();
                canLink.Disconnect();
            }
        }
예제 #2
0
        private void ButtonWrite_Click(object sender, EventArgs e)
        {
            byte address = MainForm.Address;

            UInt32 txId     = (UInt32)0x600 | address;
            UInt32 rxId     = (UInt32)0x700 | address;
            UInt32 baudRate = 250000;

            NiCanInterface = new NiCanInterface("CAN0", false, txId, rxId, baudRate);
            NiCanInterface.Connect();
            NiCanInterface.BusTerminationEnable = true;
            NiCanInterface.Open();


            MainForm.WriteEnabled = false;

            var network = new Iso15765NetwrorkLayer(NiCanInterface);

            network.ReadTimeoutMs    = 1000;
            network.Log              = Settings.Default.LogEnable;
            Settings.Default.LogPath = AppConstants.LogPath + "_" + DateTime.Now.ToString(AppConstants.FileNameTimestampFormat) + ".txt";
            network.LogPath          = Settings.Default.LogPath;

            var dfu = new AppDfu(network);


            dfu.ProgressChange += (o, ev) =>
            {
                MainForm.PoregressValue = ev.ProgressPercentage;
                MainForm.LabelStatus    = ev.UserState.ToString();
            };


            byte[] firmware = Tools.OpenFile(Settings.Default.LastPath);
            dfu.Begin(firmware);

            Action syncCompleted = () => {
            };

            dfu.Completed += (o, ev) =>
            {
                NiCanInterface.Close();
                MainForm.WriteEnabled = true;

                if (App.SyncContext != null)
                {
                    App.SyncContext.Post((e1) => { syncCompleted(); }, null);
                }

                if (ev.Result is Exception)
                {
                    MessageBox.Show((ev.Result as Exception).Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            };
        }
예제 #3
0
        private void MainForm_DeviceRestart(object sender, EventArgs e)
        {
            UInt32 baudRate = 250000;

            NiCanInterface = new NiCanInterface("CAN0", baudRate);
            NiCanInterface.Connect();
            NiCanInterface.BusTerminationEnable = true;
            NiCanInterface.Open();
            NiCanInterface.RestartCard(MainForm.Address);
            NiCanInterface.Close();
        }
예제 #4
0
        public void _0002_Bxxx_TesterPresent()
        {
            UInt32         txId     = 0x714;
            UInt32         rxId     = 0x734;
            UInt32         baudRate = 500000;
            NiCanInterface canLink  = new NiCanInterface("CAN0", false, txId, rxId, baudRate);

            canLink.Connect();
            canLink.BusTerminationEnable = true;
            canLink.Open();

            Iso15765NetwrorkLayer network = new Iso15765NetwrorkLayer(canLink);

            try
            {
                byte[] response;

                Console.WriteLine("Tester Present:");
                network.Transport(new byte[] { 0x3E, 0x00 }, out response);
                Assert.AreEqual(new byte[] { 0x7E, 0x00 }, response);

                Console.WriteLine("Diag Session:");
                network.Transport(new byte[] { 0x10, 0x03 }, out response);
                Assert.AreEqual(new byte[] { 0x50, 0x03, 0x00, 0x32, 0x01, 0xF4 }, response);

                Console.WriteLine("Read Dtc:");
                network.Transport(new byte[] { 0x19, 0x02, 0x08 }, out response);
                Console.WriteLine("Dtc:");
                Console.WriteLine(Tools.ByteArrayToCStyleString(response));
                Assert.AreEqual(new byte[] { 0x59, 0x02, 0xCA, 0x90, 0xB5, 0x15, //6
                                             0x0A, 0x90, 0xB6, 0x15,             //4
                                             0x0A, 0x90, 0xB9, 0x12,             //4
                                             0x0A, 0x9A, 0x61, 0x15,             //4
                                             0x0A, 0x9A, 0x63, 0x15,             //4
                                             0x0A, 0x9A, 0x64, 0x15,
                                             0x0A, 0xC1, 0x40, 0x00,
                                             0x0A, 0xC1, 0x55, 0x00,             //
                                             0x0A }, response);                  //Szum: 35
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                //network.SaveFrameLog("D:\\" + this.GetType().FullName + ".csv");
                canLink.Close();
                canLink.Disconnect();
            }
        }
예제 #5
0
        public void _0003_Tachograph_TesterPresent()
        {
            UInt32 txId     = 0x38DAEEFB;
            UInt32 rxId     = 0x38DAFBEE;
            UInt32 baudRate = 250000;

            NiCanInterface canLink = new NiCanInterface("CAN0", true, txId, rxId, baudRate);

            canLink.Connect();
            canLink.BusTerminationEnable = true;
            canLink.Open();

            Iso15765NetwrorkLayer network = new Iso15765NetwrorkLayer(canLink);

            try
            {
                byte[] response;

                Console.WriteLine("Tester Present:");
                network.Transport(new byte[] { 0x3E, 0x00 }, out response);
                Assert.AreEqual(new byte[] { 0x7E, 0x00 }, response);

                Console.WriteLine("DiagnosticSession:");
                network.Transport(new byte[] { 0x10, 0x7E }, out response);
                Assert.AreEqual(new byte[] { 0x50, 0x7E }, response);

                Console.WriteLine("CloseRemoteAuthentication:");
                network.Transport(new byte[] { 0x31, 0x01, 0x01, 0x80, 0x09 }, out response);
                Assert.AreEqual(new byte[] { 0x71, 0x01, 0x01, 0x80, 0x0A }, response);

                Console.WriteLine("RemoteCompanyCardReady:");
                network.Transport(new byte[] { 0x31, 0x01, 0x01, 0x80, 0x01, 0x3B, 0x3B, 0x9A,
                                               0x96, 0xC0, 0x10, 0x31, 0xFE, 0x5D, 0x00, 0x64,
                                               0x05, 0x7B, 0x01, 0x02, 0x31, 0x80, 0x90, 0x00,
                                               0x76 }, out response); //25:Length
                Assert.AreEqual(new byte[] { 0x71, 0x01, 0x01, 0x80, 0x02 }, response);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                //network.SaveFrameLog("D:\\" + this.GetType().FullName + ".csv");
                canLink.Close();
                canLink.Disconnect();
            }
        }