Struggling with my BMW IBUS projects. Serial.read related issues.

Still trying to read F series lin bus...
I got acces to an osciloscope, connected it to the car, as Ian suggested. I saw what looks like a typical lin signal. The 13 bits break and the sync byte (x55 or 01010101 binary) were there, i have included a picture of the signal.

However when i read the bus with an arduino i cant find any sync byte x55, i even dumped the data in binary format and looked for '01010101' with no results.

I'm lost right now, starting to think i have some hardware problem on the arduino side ?

Any clues what could be happening guys?

Obviously on line 42 of your sketch. :wink:

-dev:
Obviously on line 42 of your sketch. :wink:

I'm using the code from Arduino & BMW I/K Bus Interface – Programming – v0.1.0 beta » Curious-Ninja – IT, Cars, and Aviation

So not much of my own code to post, I only modified the Serials to suit an Arduino Mega instead of an UNO + usb-serial adapter, and modified IBusSerial.cpp at IbusSerial::readIbus() with:

    byte myByte = pSerial.read(1);
    for(byte mask = 0x80; mask; mask >>= 1){
      if(mask  & myByte)
       pIbusDebug.print('1');
      else
       pIbusDebug.print('0');
    }

to output binary data and analize it

cederron:
I'm using the code from Arduino & BMW I/K Bus Interface – Programming – v0.1.0 beta » Curious-Ninja – IT, Cars, and Aviation

I don't think you'll have much success with that code. It was written specifically to decode BMW iBus messages, not standard LIN frames.

Ian.

ian332isport:
I don't think you'll have much success with that code. It was written specifically to decode BMW iBus messages, not standard LIN frames.

Ian.

Yes, I started with that code but as it wasnt working im just using now to dump binary data with the little modification i posted.
Anyways i bought a 50$ Lin analyzer and hope it will clear all my doubts.
Thanks guys.

where i can find the current version of ibus library?

harryberlin:
where i can find the current version of ibus library?

Try this:

iBus Library

Ian.

Thank you

How is working the send buffer? Can handle the buffer more than one ibus message?
I can't figure out, where the buffer differences between two messages, because of the pause between two messages.

harryberlin:
Thank you

How is working the send buffer? Can handle the buffer more than one ibus message?
I can't figure out, where the buffer differences between two messages, because of the pause between two messages.

Hi,

It uses a circular buffer on both send and receive. You can send several messages, and the library will buffer them and send them out with a gap of 10mS between each message.

Ian.

ok, i will try to strip the library for basic functionality and replace my current ibus transceiver functions.

What are you trying to achieve ?

Ian.

At the moment have connected the nano with mcp2025 to ibus and do some things (cdc emu, welcome/leaving light, comfort blink, flash to pass, fog turn light, DRL, mirror folding) directly in the arduino. all messages forwarded as string via serial to the raspberry. and it is possible to receive messages from serial to transmit to ibus. and some other commands for config the arduino.
but the ibus part of the program needs lot of memory.

If memory is tight, you may want to consider something like a Teensy 3.2 instead of the Nano. My library was originally written for the Teensy, so no problems with compatibility.

What is the Raspberry Pi doing ?

Ian.

the memory of the nano is ok, but i think with the library i can reduce some bytes.
on the pi runs osmc with my addon ibuscommunicatur.

the full playlist about the addon:

harryberlin:
At the moment have connected the nano with mcp2025 to ibus and do some things (cdc emu, welcome/leaving light, comfort blink, flash to pass, fog turn light, DRL, mirror folding) directly in the arduino. all messages forwarded as string via serial to the raspberry. and it is possible to receive messages from serial to transmit to ibus. and some other commands for config the arduino.
but the ibus part of the program needs lot of memory.

Hi Harry, interesting to see others doing the same stuff!

You say you created an option for welcome lights, this is what I'm trying to get working on my E46.
I used navcoder for testing, works great! I then started with some short hex messages such as turning on the light under the rearview mirror and Opening windows. These commands work fine.

However for the lights (outside) the messages are much longer. These won't work for some reason.
Sometimes the messages show up split in Navcoder. When sending them more often at some point the whole message will show up correctly. However nothing happens!

None of the modules or only some of them respond. When I send the exact same message with navcoder, it works fine!?

NavCoder sent:
2018-05-18 17:02:56.684	3F 12 D0 0C 00 00 FF FF 62 3E 00 80 00 80 80 00 00 00 00 2D	DIA	LCM	Set IO status	Data="00 00 FF FF 62 3E 00 80 00 80 80 00 00 00 00"    [  ÿÿb> € €€    ]
2018-05-18 17:02:56.701	D0 03 3F A0 4C							LCM	DIA	Diagnostic command acknowledged	Data=""    []

arduino sent:
2018-05-18 17:03:57.184	50 04 68 32 11 1F						MFL	RAD	Volume Control	Increase 1 step
2018-05-18 17:03:57.232	12												WARNING: Discarded data
2018-05-18 17:03:57.279	D0 0C 00 00 FF FF 62 3E 00 80 00 80 80 00			LCM	GM	Cmd_0x00	Data="FF FF 62 3E 00 80 00 80 80"
2018-05-18 17:03:57.296	00 00 00 2D											WARNING: Discarded data
2018-05-18 17:03:57.343	50 04 68 32 11 1F						MFL	RAD	Volume Control	Increase 1 step
2018-05-18 17:03:57.367	50 04 68 32 11 1F						MFL	RAD	Volume Control	Increase 1 step
2018-05-18 17:03:57.500	3F 12 D0 0C 00 00 FF FF 62 3E 00 80 00 80 80 00 00 00 00 2D	DIA	LCM	Set IO status	Data="00 00 FF FF 62 3E 00 80 00 80 80 00 00 00 00"    [  ÿÿb> € €€    ]
2018-05-18 17:03:57.552	50 04 68 32 11 1F						MFL	RAD	Volume Control	Increase 1 step
2018-05-18 17:03:57.691	3F 12 D0 0C 00 00 FF FF 62 3E 00 80 00 80 80 00 00 00 00 2D	DIA	LCM	Set IO status	Data="00 00 FF FF 62 3E 00 80 00 80 80 00 00 00 00"    [  ÿÿb> € €€    ]
2018-05-18 17:03:57.736	50 04 68 32 11 1F						MFL	RAD	Volume Control	Increase 1 step

What are your thoughts about this?
I read you are using an mcp2025
Maybe this would solve my problem?

Many thanks!

Luck

i don't use the ibus library at the moment. i use use my own ino code. but i have seen, the library don't check the echo.
is the delay between two chars short enough?
otherwise, i have no idea what goes wrong in your case.
what hardware do you use?

Ah I see!

I'm using the Melexis TH3122.4

About the delay, I'm not entirely sure where the delay for sending messages is located in the code. If there even is a delay..

If I'd guess I'd say it's not "static const byte packetGap = 10;" That seems to be the time to wait before sending a message after the bus becomes available.

I haven't found anything else indicating a delay between sending chars.

Would you mind taking a look and see If you are able to find it?
Many thanks!

IbusGlobals.h (32.4 KB)

IbusSerial.cpp (22.5 KB)

sorry, i don't understand really good such c code.

Ah oke, no problem.
Would you share your code? Maybe that works for me?

No i don't share my full code. There is only the basic program on github.