Closed rk00523476 closed 4 years ago
Hi,
You need to install python-can (the specific branch to pick is in the python-j1939 readme).
Here is a simple DM1 sender (You may be able to minimize it further as I cut it down from a more complex tool). You could also pile up some of the statements like python folks prefer to do... Your choice! You should be able to have a DLC up to your 1700 or so. If you chose a 0xff dest it will send a BAM but if you send to an actual address it will send an RTS and require a handshake to continue.
Take a look at the python-can documentation to see how to configure 'channel' and 'bustype' if running on a PC and PCAN adapter. In the case that I'm running here I have a PCAN adapter but Linux recognizes it and puts a socketcan layer on top of it automatically.
Good luck!
import time import j1939
if name == "main":
# code to broadcast a DM1 message at 1 Hz
# 18FECAFE#FFFF00000000FFFF
channel = 'can0'
bustype = 'socketcan'
sourceaddr = 0xFE
destaddr = 0xFF
bus = j1939.Bus(channel=channel, bustype=bustype, timeout=0.01, broadcast=False)
data = [0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF]
pgn = j1939.PGN()
pgn.value = 0xFECA # DM1
aid = j1939.ArbitrationID(pgn=pgn, source_address=sourceaddr, destination_address=destaddr)
pdu = j1939.PDU(timestamp=0.0, arbitration_id=aid, data=data, info_strings=None)
while True:
bus.send(pdu)
time.sleep(1)
From: rk00523476 notifications@github.com Sent: Monday, May 25, 2020 9:47 PM To: milhead2/python-j1939 python-j1939@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [milhead2/python-j1939] Python J1939 library usage (#11)
Hi all, I am new to Python and have good knowledge in J1939 protocol. We have some J1939 modules developed in LabVIEW and using them in our project, but we are looking to automate the same module using Python, I have gone through Python J1939 library, and I could see there are some functions which can be used to send or receive messages I believe, just for push up I am looking for following code:
Please help me in getting this code so that it will help me in getting into it and start analyzing more on code.
I have installed J1939 library and using Python 3.8.3 32-bit version of software.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/milhead2/python-j1939/issues/11, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEWRWUYVATWPRLBV6WJWME3RTNCWXANCNFSM4NJ65UPA.
CONFIDENTIAL: The information contained in this email communication is confidential information intended only for the use of the addressee. Unauthorized use, disclosure or copying of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us immediately by return email and destroy all copies of this communication, including all attachments.
I've added this tiny sender to the examples directory.
Hi all, I am new to Python and have good knowledge in J1939 protocol. We have some J1939 modules developed in LabVIEW and using them in our project, but we are looking to automate the same module using Python, I have gone through Python J1939 library, and I could see there are some functions which can be used to send or receive messages I believe, just for push up I am looking for following code:
1) Connect to PCAN hardware to transmit J1939 messages. 2) Transmit a basic J1939 frame with 8 bytes of data or should be more helpful if could be able to transfer 1785 bytes of data (Large message).
Please help me in getting this code so that it will help me in getting into it and start analyzing more on code.
I have installed J1939 library and using Python 3.8.3 32-bit version of software.