-
Notifications
You must be signed in to change notification settings - Fork 101
Description
to be able to implement diagnostic services with low-cost hardware (i.e., microcontrollers for embedded systems or machines exhibiting less than 28 cores in the cloud world), it is necessary to use a compiled language, most commonly C++ (or C, but IMO even for microcontrollers restricting oneself to this is pretty masochistic). The way odxtools could help on this front is to generate the c++ boiler plate code necssarry for encoding and decoding UDS telegrams which needs to be filled by the developer wishing to implement a diagnostic service. This is basically the same approach as cantools generate_c_source, but I'd warmly recommend to use a proper template engine such as jinja for this.
On the c++ side, this could look similar to:
#include <FunkyECU/SomersaultBaseService.hh>
namespace FunkyECU {
class SomersaultService : public SomersaultBaseService<SomersaultService>
{
public:
SomersaultService(IsoTpConnection& conn)
: SomersaultBaseService(conn)
, num_done_(0)
{}
void request_received(const SomersaultRequestParams& rq)
{
num_done_ += rq.param_NumLoops;
if (num_done_ < 10) {
SomersaultPositiveResponse resp;
resp.param_NumLeft = 10 - num_done_;
this->sendResponse(resp);
}
else {
// i am dizzy now!
this->sendResponse(SomersaultNegativeResponse);
}
}
private:
int num_done_;
};
}
int main()
{
IsoTpConnection conn(SomersaultService::receive_id(), SomersaultService::send_id());
FunkyECU::SommersaultService service(conn);
while (true) {
IsotpTelegram telegram = conn.recv()
if (service.applies(telegram))
service.handle(telegram);
}
return 0;
}Andreas Lauser <andreas.lauser@mercedes-benz.com>, on behalf of MBition GmbH.
Provider Information