-
Notifications
You must be signed in to change notification settings - Fork 714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can-j1939 - trying to emulate an entire truck #511
Comments
Hi @mihai-demian,
it is good to hear that some one is using the J1939 kernel stack :) Interesting project!
The kernel stack takes over some of management and filtering work, the only thing what user space need to do, is to use one socket per task/message type. It means, if you work with different message types like broadcast and "unicast"-ish, you need to use different sockets. It is a single threading application with multiple sockets and periodic tasks.
In general, if you wont to emulate different MCUs/Components of the truck, it will be best to have separate program per MCU. No need to create different VCAN interfaces per MCU. The sockets are already kind of software extension of CAN bus interfaces. Well, if you wont to do it the hard and secure way, you can put every MCU application isolated in the network name spaces with own V/CAN interfaces too: In case you need more examples, here is a server which receives HID events over CAN and injects it to kernel uinput devices. It was used for this demonstrator to play tetris over CAN:
In case you will make it more generic and reusable way (one application per MCU) it will be great to include your work to this repository. |
Hello, |
Hello, |
Can you please tell more about what you wont to make? Are you trying to implement TCP/UDP to J1939 bridge? |
Hello, |
Hello, now i have to make it work with my own code.... |
Hello, I wrote some code that you can find in my repository. I will not make it public until it is ready. |
@mihai-demian , Sorry I do not have enough experience with this part of the protocol. |
@olerem , The meaning of the SPN is not important right now. I cannot decode whatever the cluster is sending. |
can you please use candump and send the output of messages you send and receive? |
done |
What do you mean? |
there are 2 candump files here |
Ok, for protocol.
And, if I see it correctly, you are trying to interpret following message from cluster 18ECFF17#200E0002FFCAFE00. Correct? After kernel processing, you should get following payload in user space: 0xc0 - leds to be activated Hm, currently I can't extract plausible values of this message. |
What if you feed this message back to the cluster? Will it be able to decode it? You will need to replace source address from 0x17 to something different. The BAM message probably combines multiple SPNs. So, you can try to send only one of them. For example: |
Hello, |
I placed the output of a "program" for reading dm1 messages, together with some comments. Most of the SPN codes have a meaning, although not all of them display a message on the cluster's display. |
If I understand you comments correctly, this cluster is using SPN v1 message format. Correct? |
Yes, that is correct. The cluster seems to be using the SPN v1 message format. The seller said that it is a TGX cluster, but i think it is for TGA. |
@mihai-demian , if you need some extra parts for your track emulation project, here is one: olerem@188b83e |
hello, |
First of all, please allow me to thank you for the great work are doing.
I am trying to emulate a truck, meaning that I want to get the information from a game (namely ets2) and send it to a truck dashboard cluster. I managed to put together some parts on the application, where I can send 8byte packages at consistent time intervals, as stated in the j1939 standard (older, found for free online). The BAM message representing the engine configuration is sent correctly from testj1939, but it is not when sent from my application, although everything is the same. I have a BAM message every 5 seconds and some typical messages every 50ms, all happening at the same time. Can this be an issue?
How can I perform a read and write on the same socket without any issues? There is not much to read from the cluster, except for a BAM DM1 message (fault codes) and a reset message to the tachograph.
I have no filters set up. I did not understand how to use them yet, and also not found the reason to implement them since there is no message addressed the part of the application that I'm working on (engine at 0x00).
I attached the application part I wrote as far, but I have a lot more to do.
My plan to have a vcan interface for every controller involved (engine, transmission, retarder, main computer and tachograph), put all of them to the same can interface that is connected with the cluster. Is this approach worth implementing?
I am looking forward for any help.
Thank you.
engine.c.txt
engine.h.txt
The text was updated successfully, but these errors were encountered: