Search code examples
j1939

Questions about addresses in SAE J1939 bus


I am developing a program to read and request parameters from a bus with J1939. I know that in order to request PGNs I need to have an address, which is claimed in the address claim procedure. I have some questions about this.

First, do the node addresses change often or are they static?

Second, does my program, as an external test equipment application, need to do the address claim procedure every time the bus is turned on, or can I store the ID that I get from the address claim procedure for my application forever?

As for the address claim procedure, what is a suitable NAME field for my application? What I'm trying to do is setup a monitoring system of different parameters of the bus, like speed, fuel, pedal position, etc. My guess is that there wont be enough ECUs to fill all the 255 available addresses, but I can't confirm how many there are so I may need a NAME. It is not a product, hence wont be mass produced and will only work in our facilities.


Solution

  • Alex

    First, what variables do you want to read? I mean, if you are trying to broadcast vehicle Speed, fuel, pedals... these are generical messages which are available on the bus without a request. Appling a digital filter (mask) on CAN might solve your problem in an efficient way. The request method is more for special ID (see more here J1939-71 ).

    Applying filters n Python:

    import can
    
    # CAN Setting
    can_interface = 'can0'
    bus.set_filters([{"can_id":0xCF00400, "can_mask": 0xFFFFFFF, "extended": True},
                     {"can_id":0x18fee927, "can_mask": 0xFFFFFFF, "extended": True}])
    bus = can.interface.Bus(can_interface, bustype='socketcan',can_filters=can_filters)
    
    while True:
         message = bus.recv()
         print(message)
    

    How filters/masks works:

    # The following just equals zero
    0xCF00400 & 0 == 0 # True
    
    # The following equals 0xCF00400 (217056256 in decimal) exactly
    0xCF00400 & 0xFFFFFFF == 0xCF00400 # True
    0xCF00400 & 0xFFFFFFF == 217056256 # True
    
    # The following can_id would not get through the filter + mask:
    0x18fee500 & 0xFFFFFFF == 0xCF00400 & 0xFFFFFFF # False
    
    # The following obviously would get through the filter + mask:
    0xCF00400 & 0xFFFFFFF == 0xCF00400 & 0xFFFFFFF # True
    

    Anyways, to be honest I never used the request method but maybe I can help.

    First, do the node addresses change often or are they static?

    Second, does my program, as an external test equipment application, need to do the address claim procedure every time the bus is turned on, or can I store the ID that I get from the address claim procedure for my application forever?

    The nodes work as a bridge ecu-ccu, so they will be always the same. But you need to always request the data again because they are not 'on line'.

    As for the address claim procedure, what is a suitable NAME field for my aplication?

    I truly didn't understand that question XD. But I think you mean you're developing a data J1939 reader/logger.