linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Questions about using multiple sockets
       [not found] <CAD1tVCN7-T=FHNQEz3Bp-0Kt3H6M1RokyUuw=e9sTLdXNWB=DQ@mail.gmail.com>
@ 2020-09-03  5:47 ` Oleksij Rempel
  2020-09-05  6:47   ` Tom Evans
  0 siblings, 1 reply; 5+ messages in thread
From: Oleksij Rempel @ 2020-09-03  5:47 UTC (permalink / raw)
  To: henrique ricardo figueira; +Cc: linux-can

Hi Henrique,

On Wed, Sep 02, 2020 at 03:15:13PM -0300, henrique ricardo figueira wrote:
> Hi, I would like to know if it is possible for me to use multiple sockets
> with different protocols, a CAN_RAW socket and another CAN_J1939. Because I
> need to receive messages from an ECU that does not follow J1939.

Yes, you can combine it as you wish. You can even use CAN_RAW to
communicate with CAN_J1939 on same or remote machine.

Regards,
Oleksij
-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Questions about using multiple sockets
  2020-09-03  5:47 ` Questions about using multiple sockets Oleksij Rempel
@ 2020-09-05  6:47   ` Tom Evans
  2020-09-07  6:55     ` Oliver Hartkopp
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Evans @ 2020-09-05  6:47 UTC (permalink / raw)
  To: henrique ricardo figueira; +Cc: linux-can

On 3/9/20 3:47 pm, Oleksij Rempel wrote:
> Hi Henrique,
> 
> On Wed, Sep 02, 2020 at 03:15:13PM -0300, henrique ricardo figueira wrote:
>> Hi, I would like to know if it is possible for me to use multiple sockets
>> with different protocols, a CAN_RAW socket and another CAN_J1939. Because I
>> need to receive messages from an ECU that does not follow J1939.
> 
> Yes, you can combine it as you wish. You can even use CAN_RAW to
> communicate with CAN_J1939 on same or remote machine.

Yes, as long as you open the sockets on DIFFERENT CAN Buses. One for the J1939 and a different bus 
for the ECU.

On the same bus?

CAN buses are usually "All J1939" or "All Something Else". The J1939 protocol uses all of the CAN ID 
field to mean a whole range of different things that are important to the protocol.

I'd suggest you look at the Wilipedia "SAE J1939" web page, and open the "Introduction to J1939 
(Vector Informatik)" link. It shows you how J1939 uses the CAN bus addresses.

It would be difficult to guarantee that the messages from the ECU won't upset one or more devices on 
the CAN bus.

Do you have full control of the ECU? Can you reprogram it to change the CAN IDs of all the messages 
it sends, or was that decided by someone else? If you can't change them then it is unlikely you 
could make it "compatible".

Then ask Google. This one says:

     If you are a CAN bus system design veteran (and only then),
     it is theoretically possible to combine them. It is a really
     bad idea but it can be done.

https://electronics.stackexchange.com/questions/467932/is-it-possible-to-use-j1939-and-canopen-on-the-same-bus

This one says "yes, but you have to do all of this...":

http://www.microcontrol.net/download/mmc_2013_koppe_2.pdf

The above also suggests that you should use a GATEWAY device between the two CAN buses. Or in your 
case, two buses on the computer.

I would say "yes, try this in an educational or hobby setup, but don't do it in a real vehicle".

Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Questions about using multiple sockets
  2020-09-05  6:47   ` Tom Evans
@ 2020-09-07  6:55     ` Oliver Hartkopp
  2020-09-07 12:33       ` Kurt Van Dijck
  0 siblings, 1 reply; 5+ messages in thread
From: Oliver Hartkopp @ 2020-09-07  6:55 UTC (permalink / raw)
  To: tom_usenet, henrique ricardo figueira; +Cc: linux-can


On 05.09.20 08:47, Tom Evans wrote:
> On 3/9/20 3:47 pm, Oleksij Rempel wrote:
>> Hi Henrique,
>>
>> On Wed, Sep 02, 2020 at 03:15:13PM -0300, henrique ricardo figueira 
>> wrote:
>>> Hi, I would like to know if it is possible for me to use multiple 
>>> sockets
>>> with different protocols, a CAN_RAW socket and another CAN_J1939. 
>>> Because I
>>> need to receive messages from an ECU that does not follow J1939.
>>
>> Yes, you can combine it as you wish. You can even use CAN_RAW to
>> communicate with CAN_J1939 on same or remote machine.
> 
> Yes, as long as you open the sockets on DIFFERENT CAN Buses. One for the 
> J1939 and a different bus for the ECU.
> 
> On the same bus?
> 
> CAN buses are usually "All J1939" or "All Something Else". The J1939 
> protocol uses all of the CAN ID field to mean a whole range of different 
> things that are important to the protocol.

Hi Tom,

AFAICS the question was not whether you run J1939 protocol on a specific 
bus or not.

To me the question was if a programmer can open multiple sockets from 
(potentially) different applications on a single CAN interface (on Linux).

And yes, you can do so - as we have a multi-user system on Linux and the 
'SocketCAN' approach is designed for it.

E.g. You can open different J1939 sockets for J1939 protocol traffic and 
- in parallel - you can open different CAN_RAW sockets, e.g. to read and 
store the CAN traffic with candump.

At the end you are completely right that any traffic *sent* to a J1939 
CAN interface must not interfere with the J1939 protocol expected by the 
ECUs on this bus.

The reception of 'messages from an ECU that does not follow J1939' via 
CAN_RAW sockets, as asked by Henrique, should therefore be no problem.

The 'problem' seems to be already introduced by that specific ECU ;-)

Best,
Oliver

> 
> I'd suggest you look at the Wilipedia "SAE J1939" web page, and open the 
> "Introduction to J1939 (Vector Informatik)" link. It shows you how J1939 
> uses the CAN bus addresses.
> 
> It would be difficult to guarantee that the messages from the ECU won't 
> upset one or more devices on the CAN bus.
> 
> Do you have full control of the ECU? Can you reprogram it to change the 
> CAN IDs of all the messages it sends, or was that decided by someone 
> else? If you can't change them then it is unlikely you could make it 
> "compatible".
> 
> Then ask Google. This one says:
> 
>      If you are a CAN bus system design veteran (and only then),
>      it is theoretically possible to combine them. It is a really
>      bad idea but it can be done.
> 
> https://electronics.stackexchange.com/questions/467932/is-it-possible-to-use-j1939-and-canopen-on-the-same-bus 
> 
> 
> This one says "yes, but you have to do all of this...":
> 
> http://www.microcontrol.net/download/mmc_2013_koppe_2.pdf
> 
> The above also suggests that you should use a GATEWAY device between the 
> two CAN buses. Or in your case, two buses on the computer.
> 
> I would say "yes, try this in an educational or hobby setup, but don't 
> do it in a real vehicle".
> 
> Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Questions about using multiple sockets
  2020-09-07  6:55     ` Oliver Hartkopp
@ 2020-09-07 12:33       ` Kurt Van Dijck
  2020-09-07 13:07         ` Tom Evans
  0 siblings, 1 reply; 5+ messages in thread
From: Kurt Van Dijck @ 2020-09-07 12:33 UTC (permalink / raw)
  To: Oliver Hartkopp; +Cc: tom_usenet, henrique ricardo figueira, linux-can

> 
> The 'problem' seems to be already introduced by that specific ECU ;-)

In my experience, it's hard to use 29bit CAN id's mixed with J1939.
But the 11bit CAN id range is free to use without any conflict with
j1939.
I've seen some uses of this 11bit id's.

Kurt

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Questions about using multiple sockets
  2020-09-07 12:33       ` Kurt Van Dijck
@ 2020-09-07 13:07         ` Tom Evans
  0 siblings, 0 replies; 5+ messages in thread
From: Tom Evans @ 2020-09-07 13:07 UTC (permalink / raw)
  To: Oliver Hartkopp, henrique ricardo figueira, linux-can

On 7/9/20 10:33 pm, Kurt Van Dijck wrote:
>>
>> The 'problem' seems to be already introduced by that specific ECU ;-)
> 
> In my experience, it's hard to use 29bit CAN id's mixed with J1939.
> But the 11bit CAN id range is free to use without any conflict with
> j1939.
> I've seen some uses of this 11bit id's.

Just as long as all other devices on the bus are perfect and fully tested, and don't do what was in 
one of the links I sent previously:

https://electronics.stackexchange.com/questions/467932/is-it-possible-to-use-j1939-and-canopen-on-the-same-bus

     Certain CAN nodes don't distinguish between 11 or 29 bit
     internally.

There are a lot of CAN devices out there that work well enough in the limited environment they've 
been tested in. But add anything else to the bus and change the traffic or addresses in use and you 
might find they can't handle that. They might be demonstrably buggy, but it will still be your 
fault. Especially if they throw a DTC and don't work until the vehicle gets back to the dealer to 
clear it. BeenThereDoneThat.

Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-07 13:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAD1tVCN7-T=FHNQEz3Bp-0Kt3H6M1RokyUuw=e9sTLdXNWB=DQ@mail.gmail.com>
2020-09-03  5:47 ` Questions about using multiple sockets Oleksij Rempel
2020-09-05  6:47   ` Tom Evans
2020-09-07  6:55     ` Oliver Hartkopp
2020-09-07 12:33       ` Kurt Van Dijck
2020-09-07 13:07         ` Tom Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).