j1939_logger dumping messages

Issue #57 new
Olivier Bertrand created an issue

Hi all,

Many frames aren't captured by the J1939_logger when executed.. see attached; I'm using candump and wireshark for to highlighting this: Link Text Btw, the speed I'm putting between the cansend seems to influence the reception like: the faster I'm sending frames, the better they are received...

The behaviour is quite different when I try this in my own program, the 3 first messages are dumped, then they're all seen by terminal...

# coding: utf8
import can
from can.protocols import j1939
from can.interfaces.interface import *
from can import Message
import sys,os,operator

# create bus
bus = j1939.Bus(channel='vcan0', bustype='socketcan_ctypes')

message = bus.recv() 

#for message in Bus('vcan0'):

# close the bus

do you have any example available ?.. I know there is many TODO for J1939, but if you have any explanations...


Comments (9)

  1. Olivier Bertrand reporter


    I need to know if this is a bug.. If yes I have to create my own code brick above python-can for the J1939's bus management. Else, I must understand how this is working and what necessary to do for receiving the messages at the first sending.

    Thank you in advance guys. cheers

  2. David Miller Lowe

    I've been attempting to pick-up the j1939 protocol code to instrument j1939 testing with Robot Framework for our gauges

    If I enable the python INFO or DEBUG logging is see the j1939 bus receiving many more messages but they don't percolate to be received and returned by the recv() method.

    Currently I'm trying to issue DM13 commands, some examples would really be nice.

  3. Mike Molt

    Oliver have you tried the standard bus to get the messages? As I understand it J1939 is just mapped into the extended message frame of regular ole CAN.

  4. Brian Thorne repo owner

    The only interface that I've used the J1939 code with is Kvaser. Replicating your test Olivier using linux virtual socketcan I get the same results - the messages all appear in a raw can logger, but not the J1939 one. Wireshark isn't picking up the messages as J1939 for me though.

    We need to see if this just effects the socketcan interface.

    @milhead what interface are you using?

    This test J1939 send might be useful too:

    from __future__ import print_function
    from time import sleep
    import can
    from can.protocols import j1939
    def send_j1939():
        bus = j1939.Bus(channel='vcan0')
        node1 = j1939.Node(bus, j1939.NodeName(0), [0x01])
        node2 = j1939.Node(bus, j1939.NodeName(0), [0x42])
        pgn = j1939.PGN(reserved_flag=True,
        arbitration_id = j1939.ArbitrationID(pgn=pgn, source_address=0x01)
        msg = j1939.PDU(arbitration_id=arbitration_id,
                        data=[0x10, 0x20, 0x30])
            print("Message sent on {}".format(bus.channel_info))
        except can.CanError:
            print("Message NOT sent")
    if __name__ == "__main__":
  5. Olivier Bertrand reporter

    Hey guys, sorry for the late reply...

    @milhead : Dunno this framework, by curiosity when you say gauges are you talking about measuring instrument? Have you made some conclusive tests since your last post ?

    @M_Molt : yeah, I've tried the standard bus which works correctly. I've created my own J1939 class, my project must progress anyway..

    @hardbyte : Btw, you should use the last Wireshark via automated build ( https://www.wireshark.org/download/automated/ ) I've reported some bugs on J1939 wireshark dissector.. Otherwise, this fixed bug should be efficient on the next Wireshark's release. Does kvaser receive's functions are dumping the first messages in the same way ?... Do you advice me to use Kvaser's canlib ?

  6. David Miller Lowe

    My company makes gauges for motorcycles and other off road vehicles, Currently we don't have much automated test so I'm building a set of libraries that sit between your j1939 module and Robot Framework.

    I can now send periodic messages from the test harness quite well but am struggling a bit with some of the protocol interchages like a DM14 memory transfer.. I'm quite new to J1939.

    If you'd like I can shoot up some examples but they are premature for posting


  7. Remco Vink

    For some reason my J1939 code keeps skipping a message. I made a code which increments the data send over J1939:

    On the sending side when i print the MSG it looks like this:

    PRI= 0 PGN=0x0000 DST=0x00 SRC= 0x00 01 00 00 00 00

    PRI= 0 PGN=0x0000 DST=0x00 SRC= 0x00 02 00 00 00 00

    PRI= 0 PGN=0x0000 DST=0x00 SRC= 0x00 03 00 00 00 00

    PRI= 0 PGN=0x0000 DST=0x00 SRC= 0x00 04 00 00 00 00



    PRI= 0 PGN=0x0000 DST=0x00 SRC= 0x00 60 00 00 00 00

    on the receiving side I only receive the following:

    PRI= 0 PGN=0x0000 DST=0x00 SRC= 0x00 01 00 00 00 00

    PRI= 0 PGN=0x0000 DST=0x00 SRC= 0x00 03 00 00 00 00



    PRI= 0 PGN=0x0000 DST=0x00 SRC= 0x00 59 00 00 00 00

    for some reason I only receive exactly the uneven message everytime. I am using the test send j1939 code mentioned aboven and the J1939_logger code.

    anyone knows what could be wrong?

  8. Log in to comment