iwanders / OBD9141

A class to read an ISO 9141-2 port found in OBD-II ports.
MIT License
227 stars 70 forks source link

A special kind of communication with the ECU #46

Closed Vladislav-Lavrushkin closed 1 year ago

Vladislav-Lavrushkin commented 1 year ago

Hello, My control unit has special modes and PID, how can I work with this with your library? image This is a request from the CASCADE 0.9.4 program.

Vladislav-Lavrushkin commented 1 year ago

For information, 2 requests. The one on the right is understandable. The one on the left is not clear. image

Vladislav-Lavrushkin commented 1 year ago

I begin to understand. The request does not consist of 5 bytes, but of 6 bytes. 57 CRC.

Vladislav-Lavrushkin commented 1 year ago

Now you need to understand how to send a request of 6 bytes:)

Vladislav-Lavrushkin commented 1 year ago
bool OBD9141::getlongPID(uint8_t pid, uint8_t mode, uint8_t return_length){
    uint8_t message[6] = {0x68, 0x6A, 0xF1,0x22, mode, pid};
    // 

    bool res = this->request(&message, 6, return_length+6);
    // checksum is already checked, verify the PID.

    if (this->buffer[5] != pid){
        return false;
    }
    return res;
}

I added a function for a long request of 6 bytes. Also added a function for a long answer. I achieved what I wanted.

iwanders commented 1 year ago

I was away from my computer for a few weeks, glad you got it to work by yourself, looks great!

The request method is public, so you could also use a helper function outside of the object, if you want to use the library unmodified. You can retrieve the buffer with readBuffer, which is also public. This is the first time I've seen a longer request, so I don't think there's much value in adding it to the library.

@Vladislav-Lavrushkin , is this issue good to be closed?

Vladislav-Lavrushkin commented 1 year ago

Yes, the topic can be closed.