CW-B-W / ESP32-openLIN

open-LIN-c implementation on ESP32
MIT License
8 stars 2 forks source link

Making Slave and Master work at the same time. Creation of a LIN Gateway. #1

Open Uvamosk opened 9 months ago

Uvamosk commented 9 months ago

Don't know if you will read this or not. I can't seem to find a way to directly contact you. I have been looking through the code and trying to familiarize my self with it. I am wanting to institute a ability to run the Slave and Master on the same ESP32 and have it function as a gate way between a LIN master and a LIN slave. Sorta of like a man in the middle.

I have got it partially functional, but can never get it to fully work with Master to "Master/Slave AKA: gateway" the "Master/Slave AKA: gateway" will always work in the Slave though.

I can't fully tell if the issue is with Open LIN or the adaptation to ESP32 you created. Would be very interested in helping make this a reality. I have a few projects that require a LIN gateway to take messages from a Master and alter them to be sent to slaves. Thank you.

CW-B-W commented 5 months ago

Hello @Uvamosk ,

That's really a good idea. But unfortunately I don't have spare time to work on this.

In my opinion, to make Master and Slave coexist on the same ESP32, we will have to adapt the architecture of OpenLIN. As the present design of OpenLIN is based on global state machines, it's hard to allow a single module to act as Master and Slave at the same time.

To make it possible, I think we have to adapt OpenLIN to an object-oriented architecture. So that when you need a new LIN bus frame handler, be it Master or Slave, we will just need to instantiate a new object.

But I am currently unavailable for this improvement.

Thanks for your precious advice.

Maximize0987 commented 3 months ago

I hope this is allowed...

https://github.com/jbschooley/ToyotaLinInterceptor/tree/main

I am working with this and it acts like a "gateway" it works on a arduino mega2560.

I have been trying to get it to work on a esp32, but I was having crashes on the "writebreak" on LinController.h on this line

ser->begin(19200, >> 1); (line 54 serial half speed)

Since I haven't been able to get it to work on a esp32 so far. I too am using a mega2560, and on serial3 I have a esp32 connected sending/receiving with the mega and doing BLE and espnow tasks.

I have just come back to this as I don't like the mega. it's a pig and hard to design a mating pcb

maybe you can figure out how to make the gateway and break work together on a esp32

I also found this today that doesn't use the halfspeed to get the 13 byte breakfield, but ( *9 /13)

https://esp32.com/viewtopic.php?f=13&t=8181

I hope this helps... maybe you can update if you figure something out.