Code Monkey home page Code Monkey logo

Comments (7)

pylessard avatar pylessard commented on June 5, 2024

Can you show how you initialize the communication stack?
It's weird, according to your log, the isotp layer starts transmitting over 1 sec after send() is called.

from python-udsoncan.

caocheng7979 avatar caocheng7979 commented on June 5, 2024

Thank you for your reply!
uds5
uds6
My device is the ZLGCan,I turn on the Can device and start the receiving thread.

    if self.cmbUDSEnable.get() == 'YES':
        self.udsclient.open()
        self._terminated = False

After send() is called ,The msg has been put into the queue.
···
log info:send msg queue put
···
But rxthread_task seems to be blocked.
main thread TIMEOUT,rxthread_task start calling isotp_send().

    toIsoTPQueue queue size is now 0
    Sending xxxx
    Receiving:xxx
    fromIsoTPQueue queue size is now 1

something wrong with threading?

from python-udsoncan.

pylessard avatar pylessard commented on June 5, 2024

I suspect your zcan lib to takes ownership of the GIL and not release it. Preventing any thread to work during that time.
Can you make an experiment for me?

make a simple thread that prints to the console in a loop. And try calling your zcan function, See if it stops the thread.

import threading
import time
stop_event = threading.Event()

def func:
    while not stop_event.is_set():
        print("%s Thread: Still running" % time.time())
        time.sleep(0.1)

def main():
    t = threading.thread(target=func)
    t.start()
    time.sleep(0.5)
    try:
        printf("%s Main thread: Sending a zcan message" % time.time())
        zcan.Transmit(...)
        printf("%s Main thread: Sending a zcan message" % time.time())
        #...  Test each function.  Then see if the thread ever stops for a long time.
    finally:
        stop_event.set()
        t.join()

from python-udsoncan.

caocheng7979 avatar caocheng7979 commented on June 5, 2024

zcan lib
I found out why the problem happened.
I want to output log to textbox.

        self.logger = logging.getLogger('logger')
        # self.logger.setLevel(logging.DEBUG)
        udsLogHandler = TextboxHandler(self.text_log)
        self.logger.addHandler(udsLogHandler)

        # self.isotp_layer.logger.setLevel(logging.DEBUG)
        # isotpLogHandler = TextboxHandler(self.text_log)
        # self.isotp_layer.logger.addHandler(isotpLogHandler)

        # self.udsclient.conn.logger.setLevel(logging.DEBUG)
        # connLogHandler = TextboxHandler(self.text_log)
        # self.udsclient.conn.logger.addHandler(connLogHandler)

        self.udsclient.logger.setLevel(logging.DEBUG)
        clientLogHandler = TextboxHandler(self.text_log)
        self.udsclient.logger.addHandler(clientLogHandler)

If I uncomment isotp_layer.logger,problems are going to happen.

Thanks again for your reply!

from python-udsoncan.

pylessard avatar pylessard commented on June 5, 2024

Ohh, you are using a UI framework and it's the UI that takes ownership of the GIL.
You may want to consider running the isotp communication in a different process and use IPC mechanism to itnerract with the GUI

cheers

from python-udsoncan.

caocheng7979 avatar caocheng7979 commented on June 5, 2024

guilog.txt
pycharmlog.txt
CANdevicelog.asc.txt

Hi!After updating udsoncan to 1.21.2 and isotp to 2.0.3, I am now using PythonIsoTpV2Connection, but the Timeout is triggered again.Now I'm using a separate thread to log to ScrolledText.

In older versions, self.udsclient.logger was set to DEBUG and the flush was successful, but it was set to INFO and a Timeout occurred.

I even removed the srrollText to stop logging.But Timeout is still triggered.

Would you like to check the logs and see what you can find?Looking forward to your reply!

from python-udsoncan.

pylessard avatar pylessard commented on June 5, 2024

If I remember correctly, your GUI framework seemed to take ownership of the GIL. That blocks every threads.
If you configure your GUI to not do that, it would be ideal. Otherwise, maybe the cleanest way is to put the transmission part into a different process and make the GUI commnunicate through IPC.

from python-udsoncan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.