Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a new PID, struggling...., c# newbie #16

Open
MartinParis opened this issue Mar 4, 2020 · 2 comments
Open

Adding a new PID, struggling...., c# newbie #16

MartinParis opened this issue Mar 4, 2020 · 2 comments

Comments

@MartinParis
Copy link

I have created a new class for Odometer.
It needs a PID value of 3B6 (CAN message: 3B64597BF00). The whole technical architecture seems to be made around a PID of one byte so I need somehow to make AbstractOBDData.cs aware of this larger PID, but I fail because my knowledge of c# is not enough.
Can anyone give a pointer for this?
And I think I also need to convince AbstractPidsSupported.cs of this larger PID and adding it to the supported list.
I want to use this library to get Odometer from my Tesla Model 3 Vehicle Bus through the OBDLINK MX+.

`using OBD.NET.Common.DataTypes;

namespace OBD.NET.Common.OBDData
{
public class Odometer : AbstractOBDData
{
#region Properties & Fields

    public Kilometre Odom => new Kilometre((D + C << 8) + (B << 16) + (A << 24), 0, 0);

    #endregion

    #region Constructors

    public Odometer()
        : base(0x3B6, 4)
    { }

    #endregion

    #region Methods

    public override string ToString() => Odom.ToString();

    #endregion
}

}
`

@DarthAffe
Copy link
Owner

DarthAffe commented Mar 4, 2020

Hey,
assuming, that tesla isn't doing anything weird with their can-bus you have a misconception about the PID in the can message:
If 3B64597BF00 would be a OBD message it should normally be parsed as:

3B6   CAN-ID (not OBD-PID!)
45    number if data-bytes (this indicates, that you're not looking at OBD-data since it should be 01, 02, 03 or 04)
97    OBD SID (41 for a response)
BF    OBD PID
00    OBD Data

Since the amount of bytes and the SID doesn't look valid this doesn't seem to be OBD-data.
Parsing raw CAN-data isn't part of this library.

@MartinParis
Copy link
Author

Thanks for the reply!
Oh boy. I only need the CAN data 3B6, it is not OBD data. I do not know my CAN from OBD...
This CAN data is my number of kilometers in some Endian format, so I can parse it to real meters.
My idea was to filter the CAN data STFA so I would only get 3B6 messages, that is all I need in my C# code. Mixing up OBD with CAN made it possible in my world :-(.
So that would not be possible with this library? Bummer. I will search on, if you have a pointer it would be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants