On Thu, Jul 19, 2018 at 12:31:36PM +0100, Fran Terry wrote:
I am in the process of getting the smart ED (451) working on v3, have not had an issue getting data out via normal PID requests. However I am having issues with talking to the BMS & Charger, it might me being a noob, but I can't work out the best way to do UDS/ISO-TP.
For instance I need to send the following packet to: 0x7E7 03 22 02 08 FF FF FF FF
I need to then pick up the following from 0x7EF: 11 93 62 02 08 0E A7 0E
I also need to send flow control frames, basically speak ISO-TP. I can see in the TR code how to send a frame via CAN, however not sure how to pick up the response and talk ISO-TP
I recently cleaned up support for two ISO-TP requests used by the Nissan Leaf; maybe looking at that code would help? There is a table-driven mechanism to send requests at regular intervals that also takes care of the flow control frames for you: static const OvmsVehicle::poll_pid_t obdii_polls[] = { { 0x797, 0x79a, VEHICLE_POLL_TYPE_OBDIIGROUP, 0x81, { 0,999,999 } }, // VIN [19] { 0x79b, 0x7bb, VEHICLE_POLL_TYPE_OBDIIGROUP, 0x01, { 0, 61, 61 } }, // bat [39] { 0, 0, 0x00, 0x00, { 0, 0, 0 } } }; ... PollSetPidList(m_can2,obdii_polls); The interval (in seconds) is represented by three numbers, e.g. { 0, 61, 61 }. You can change which of the three intervals to use with PollSetState(n). You must declare a function to be notified as each reply frame arrives: void OvmsVehicleNissanLeaf::IncomingPollReply(canbus* bus, uint16_t type, uint16_t pid, uint8_t* data, uint8_t length, uint16_t remain) That function could just directly interpret the partial frames, but I thought it was less confusing to make it a general routine to reassemble the pieces in to a big buffer, then I could write simpler functions to process each type of request only when it was fully complete: void OvmsVehicleNissanLeaf::PollReply_Battery(uint16_t reply_id, uint8_t reply_data[], uint16_t reply_len) void OvmsVehicleNissanLeaf::PollReply_VIN(uint16_t reply_id, uint8_t reply_data[], uint16_t reply_len) I imagine that other vehicles might also benefit from such reassembly by moving it up to the class function, but someone more familiar with the big picture might want to make the decision on how best to do that.