Another question… Since I am new to the company and nobody ever has experience about python or the device, I need help here. I am trying to read canbus data using Connectport X5, I find the J1939 sample code here: http://www.digi.com/wiki/developer/index.php/J1939_Sample. When I run the program, the screen can print “====PDU received====” and the opt in the program. However, I cannot get the attribute of one message by using “print opt + " = " + str(PDU.getattribute(opt))”. Does anyone has this kind of problem?
Unfortunately, I don’t have an X5 or J1939 device.
I also don’t understand your comment “there is no error message, just cannot print the attribute’s value”. Do you mean your fingers just can’t press the right keys or something
The Wiki page you referecnce is called “code samples”, so it might not even run as-is.
If you are new to Python and the X5 (and J1939/Vehcile Bus) then diving into this is like trying to learn to ski on a triple-diamond death ski-run! You may want to try simplier things first, get a feel for running Python on the X5 first.
I can run “hello world” on the device. And I need to change my word, actually there is no error message. However, I think there is an exception when the program runs at the code “print opt + " = " + str(PDU.getattribute(opt))”. I even cannot find the documentation about what PDU class is…
Even though I have 9 years of Python experience, I didn’t see where PDU comes from either. Also, the callback_1 may be called by a seperate task/thread, so one should do some form of context protection. Plus the callbak_1 seems to send, not receive/parse.
It should be.When I delete the words “+ " = " + str(PDU.getattribute(opt))” in the sentence, it can prints ‘DA’, ‘DP’, ‘EDP’, ‘GE’, ‘PF’, ‘PGN’, ‘PS’, ‘SA’, ‘priority’, ‘payload’. So the device should receive the message I send to. However, I cannot print the attribute of these parameters. I really need to see if the message is sent correctly to the device.