just-oblivious / arduino-ibustrx

Arduino library for sending and receiving messages over the BMW infotainment bus (IBUS).
MIT License
56 stars 11 forks source link

Multiple ibusTrx.write() after one another #7

Open Diolum opened 1 year ago

Diolum commented 1 year ago

Hi,

I can't manage to get many message send one after another.

Example: I need to be able to Init a RLS sensor when needed. For that, 3 Write memory commands have to be send.

  uint8_t Init1[8] = { 0x3F, 0x07, 0xE8, 0x07, 0x01, 0x20, 0x01, 0xFF};
  uint8_t Init2[8] = { 0x3F, 0x07, 0xE8, 0x07, 0x01, 0x04, 0x01, 0xFF};
  uint8_t Init3[8] = { 0x3F, 0x07, 0xE8, 0x07, 0x01, 0x05, 0x01, 0xFF};

Each give a response : E8 03 3F A0 74

I can't manage to have the 3 commands sent one after another.

I only have the last one sent when I put it this way:

      ibusTrx.write(Init1); 
      ibusTrx.write(Init2); 
      ibusTrx.write(Init3); 

this way:

      ibusTrx.write(Init1); 
      IbusMessage message = ibusTrx.readMessage(); 
      ibusTrx.write(Init2); 
      message = ibusTrx.readMessage(); 
      ibusTrx.write(Init3); 
      message = ibusTrx.readMessage(); 

or this way

      ibusTrx.write(Init1); 
      ibusTrx.available();
      ibusTrx.write(Init2); 
      ibusTrx.available();
      ibusTrx.write(Init3); 
      ibusTrx.available();

I have tried the following logic with putting ibusTrx.available() or busMessage message = ibusTrx.readMessage(); as well and didn't work I only get Init 1 sent or Init 1 and 2 but not the third. (I can this this in NavCoder)

Send init1
if response command is A0
  send init2
  if response command is A0
    send init3

But in case of a command without response this code don't works.

Do you have any idea on what can cause that and code example to mitigate this issue ? (preferably like the first code example?

Thanks to your library I can already log to SD full Bus, Read fault, erase fault, live data and I'm only stuck with this problem

Hoping to hear from you soon

Thanks

Diolum