BrianHumlicek / J2534-Sharp

A .Net interface for J2534 vehicle communications.
Other
41 stars 13 forks source link

Sending a message give timeout error and can't set different txaddress adnd rxaddress #34

Open jwdsoft opened 5 months ago

jwdsoft commented 5 months ago

I'm trying to send a message using this library but I get an error on Channel.SendMessage() even though I don't have a read command the library is waiting for a response and i'm getting an error the second problem is how to set the txAddress and rxAddress because I need to specify a particular 29bit address

here is the message I got while sending the message



SAE.J2534.J2534Exception: The PassThru device was unable to read the specified number of messages from the vehicle network within the specified time.

à SAE.J2534.API.CheckResult(ResultCode Result) dans J2534-Sharp-master\src\API.cs:ligne 122

à SAE.J2534.Channel.SendMessages(HeapMessageArray hJ2534MessageArray_Local) dans J2534-Sharp-master\src\Channel.cs:ligne 150

à SAE.J2534.Channel.SendMessage(IEnumerable`1 Message) dans J2534-Sharp-master\src\Channel.cs:ligne 104

à J2534_Test.Form1.button1_Click(Object sender, EventArgs e) dans J2534 Test\Form1.cs:ligne 42

OK

here is the code I used

`

        MessageFilter FlowControlFilter = new MessageFilter()
        {
            FilterType = Filter.FLOW_CONTROL_FILTER,
            Mask = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF },
            Pattern = new byte[] { 0x00, 0x00, 0x07, 0xE8 },
            FlowControl = new byte[] { 0x00, 0x00, 0x07, 0xE0 }
        };
        if (comboBox1.Text == "")
            return;
        string DllFileName = APIFactory.GetAPIinfo().FirstOrDefault(x => x.Name == comboBox1.Text).Filename;

        using (API API = APIFactory.GetAPI(DllFileName))
        using (Device Device = API.GetDevice())
        using (Channel Channel = Device.GetChannel(Protocol.ISO15765, Baud.ISO15765, ConnectFlag.NONE))
        {
            try
            {
                Channel.StartMsgFilter(FlowControlFilter);
                textBox1.Text += $"Voltage is {Channel.MeasureBatteryVoltage() / 1000}" + Environment.NewLine;
                Channel.SendMessage(new byte[] { 0x01, 0x02, 0x07, 0xE0, 0x01, 0x03 });
                //GetMessageResults Response = Channel.GetMessage();
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex);
            }
        }

`

Thank you for your help

BrianHumlicek commented 3 months ago

So, the exception message is the description that the driver sends back, or it’s the generic error code description if there is no description from the driver. If you examine the exception object, I believe it will show what the return code was. I would check that because it seems like the driver might not be returning the correct error description.

Brian