# question about "\_\_getattribute\_\_"

**URL:** <https://forums.digi.com/t/question-about-getattribute/2788>\
**Category:** Python\
**Created:** [June 15, 2011, 10:08pm UTC](https://forums.digi.com/t/question-about-getattribute/2788 "2011-06-15T22:08:51Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![propelit](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@propelit](https://forums.digi.com/u/propelit)\
**Post date:** [June 15, 2011, 10:08pm UTC](https://forums.digi.com/t/question-about-getattribute/2788/1 "2011-06-15T22:08:51Z")

</div>

Hi everyone,

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](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?

Thanks,  
Wenzhou

---

<div class="post-metadata">

**Author:** ![lynnl](https://avatars.discourse-cdn.com/v4/letter/l/22d042/32.png) [@lynnl](https://forums.digi.com/u/lynnl)\
**Post date:** [June 16, 2011, 1:15pm UTC](https://forums.digi.com/t/question-about-getattribute/2788/2 "2011-06-16T13:15:43Z")

</div>

What error message are you seeing?

---

<div class="post-metadata">

**Author:** ![propelit](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@propelit](https://forums.digi.com/u/propelit)\
**Post date:** [June 16, 2011, 3:16pm UTC](https://forums.digi.com/t/question-about-getattribute/2788/3 "2011-06-16T15:16:10Z")

</div>

Actually there is no error message, just cannot print the attribute’s value

---

<div class="post-metadata">

**Author:** ![propelit](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@propelit](https://forums.digi.com/u/propelit)\
**Post date:** [June 16, 2011, 5:39pm UTC](https://forums.digi.com/t/question-about-getattribute/2788/4 "2011-06-16T17:39:29Z")

</div>

Can anyone help?

---

<div class="post-metadata">

**Author:** ![lynnl](https://avatars.discourse-cdn.com/v4/letter/l/22d042/32.png) [@lynnl](https://forums.digi.com/u/lynnl)\
**Post date:** [June 16, 2011, 5:50pm UTC](https://forums.digi.com/t/question-about-getattribute/2788/5 "2011-06-16T17:50:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![propelit](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@propelit](https://forums.digi.com/u/propelit)\
**Post date:** [June 16, 2011, 6:04pm UTC](https://forums.digi.com/t/question-about-getattribute/2788/6 "2011-06-16T18:04:27Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![lynnl](https://avatars.discourse-cdn.com/v4/letter/l/22d042/32.png) [@lynnl](https://forums.digi.com/u/lynnl)\
**Post date:** [June 16, 2011, 6:48pm UTC](https://forums.digi.com/t/question-about-getattribute/2788/7 "2011-06-16T18:48:48Z")

</div>

That was one of my concerns as well!

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.

I assume PDU is supposed to be of class J1939\_PDU - see [http://www.digi.com/wiki/developer/index.php/Module:digicanbus](http://www.digi.com/wiki/developer/index.php/Module:digicanbus)

---

<div class="post-metadata">

**Author:** ![propelit](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@propelit](https://forums.digi.com/u/propelit)\
**Post date:** [June 16, 2011, 7:06pm UTC](https://forums.digi.com/t/question-about-getattribute/2788/8 "2011-06-16T19:06:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![propelit](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@propelit](https://forums.digi.com/u/propelit)\
**Post date:** [June 17, 2011, 3:44pm UTC](https://forums.digi.com/t/question-about-getattribute/2788/9 "2011-06-17T15:44:40Z")

</div>

Can anyone help?

---

<div class="post-metadata">

**Author:** ![lynnl](https://avatars.discourse-cdn.com/v4/letter/l/22d042/32.png) [@lynnl](https://forums.digi.com/u/lynnl)\
**Post date:** [June 17, 2011, 10:41pm UTC](https://forums.digi.com/t/question-about-getattribute/2788/10 "2011-06-17T22:41:37Z")

</div>

Everyone I’ve asked says the sample code appears to be wrong. But no one’s stepped to offer a solution.

You could call Digi tech support and try to get a ‘case’ opened to have someone fix it. Otherwise it might take a while to get a fix.
