richClubb / python-uds

A uds library for python
MIT License
95 stars 54 forks source link

exception in threading #46

Open francosax opened 5 years ago

francosax commented 5 years ago

hi all, I'm using the lib with vn1610 vector hardware , during a scan of service 22 xx yy I got this exception: self.recvBuffer.append(msg.data[self.pduStartIndex:]) AttributeError: 'CanTp' object has no attribute '_CanTp__recvBuffer' in file ....python_uds-1.0.2-py3.7.egg\uds\uds_communications\TransportProtocols\Can\CanTp.py

My script continue to run, but slowly: it sends 1 msg per second and not every 10 msec

richClubb commented 5 years ago

Hi Franco.

Can you send me your script? I've got access to a 1630 which should be similar enough to test this problem.

Rich

francosax commented 5 years ago

yes, at the moment I cannot acces to the pc, please take a look on the exceptions chain that I've already saved: Exception in thread can.notifier for bus "Application testApp: CAN 1": Traceback (most recent call last): File "D:\users\xxxxx\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 917, in _bootstrap_inner self.run() File "D:\users\xxxxx\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 865, in run self._target(*self._args, **self._kwargs) File "D:\users\xxxxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\python_can-3.2.0-py3.7.egg\can\notifier.py", line 102, in _rx_thread self._on_message_received(msg) File "D:\users\xxxxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\python_can-3.2.0-py3.7.egg\can\notifier.py", line 119, in _on_message_received res = callback(msg) File "D:\users\xxxxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\python_can-3.2.0-py3.7.egg\can\listener.py", line 54, in call return self.on_message_received(msg) File "D:\users\xxxxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\python_uds-1.0.2-py3.7.egg\uds\uds_communications\TransportProtocols\Can\CanTp.py", line 371, in callback_onReceive self.recvBuffer.append(msg.data[self.pduStartIndex:]) AttributeError: 'CanTp' object has no attribute '_CanTp__recvBuffer'

richClubb commented 5 years ago

Hi Franco.

I'm not having any problems communicating with a CANcaseXL or 1630. Have you tried a very simple comms test?

from uds import Uds
a = Uds(reqId=0x600, resId=0x650, interface="vector", appName="pythonUds")
b = a.send([0x22, 0xf1, 0x8c])
print(b)
[98, 241, 140, 48, 48, 48, 48, 52, 57, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32]

You'll need to replace the "reqId" "resId" and "appName" as appropriate to your config. But otherwise I'm going to need the script you're using to debug further.

I also tried the following script on one of our test ECUs scanning all 65535 possible DIDs and it worked with the same setup.

from uds import Uds

if __name__ == "__main__":
    a = Uds(reqId=0x600, resId=0x650, interface="vector", appName="pythonUds")

    for i in range(0x00, 0x100):
        for j in range(0x00, 0x100):
            try:
                b = a.send([0x22, i, j])
            except:
                print("Nothing found on 0x{:02X}{:02X}".format(i,j))
            if(b[0] == 0x7F):
                print("Nothing found on 0x{:02X}{:02X}".format(i,j))
            else:
                print("Found ", b ," on 0x{:02X}{:02X}".format(i,j))
francosax commented 5 years ago

Hi Rich, my configuration is OK, the problem is that after some time (maybe near 10 minutes) the exception appear and my script goes forward but very slowly (1 mesg per second). I'm running my script on python 3.7 32 bit on win10 and win7 I do the same you did: scan of all possible and also not allowed DID. It is possible that the exception appears if I try not allowed DIDs? I tried to attach my source file but seems that with firefox browser it not work well...

richClubb commented 5 years ago

Hi Franco.

Please email it to richard.clubb@embeduk.com and I'll have a look.

francosax commented 5 years ago

Hi Rich, please close the issue. I fixed the issue. It was a memory issue due to my fault in use of Uds lib.

richClubb commented 5 years ago

Hi Franco.

Could you explain. I'd like to see if there is any way to improve the quality of the code.

Sincerely

Rich

On Fri, 5 Jul 2019, 16:50 franco, notifications@github.com wrote:

Hi Rich, please close the issue. I fixed the issue. It was a memory issue due to my fault in use of Uds lib.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/richClubb/python-uds/issues/46?email_source=notifications&email_token=AAMQRVG45PX2EWD6PV3SMXLP55UUBA5CNFSM4HPQ26D2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZJ232A#issuecomment-508800488, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMQRVHL7EZFLDSMNK7WGHDP55UUBANCNFSM4HPQ26DQ .

francosax commented 5 years ago

Hi Rich, I was wrong in a for loop in wich I don't destroy the uds object at the end, so when the script was runnig it accumulates more and more uds objects in memory...so.... Was my fault.

richClubb commented 5 years ago

Hi Franco.

Thanks for explaining this.

Let me know if there is anything else you need.

Sincerely,

Rich.

On Tue, 9 Jul 2019 at 09:50, franco notifications@github.com wrote:

Hi Rich, I was wrong in a for loop in wich I don't destroy the uds object at the end, so when the script was runnig it accumulates more and more uds objects in memory...so.... Was my fault.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/richClubb/python-uds/issues/46?email_source=notifications&email_token=AAMQRVBAIVWNCBFZCP3DXQ3P6RGNBA5CNFSM4HPQ26D2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZPSRHQ#issuecomment-509552798, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMQRVHBBKSXBMLO5AZABZDP6RGNBANCNFSM4HPQ26DQ .