ljean / modbus-tk

Create Modbus app easily with Python
Other
568 stars 213 forks source link

Error de comunicación #65

Closed sistemasmc1986 closed 7 years ago

sistemasmc1986 commented 7 years ago

Estuve intentando comunicar con un arduino MEGA pero simpre me tiraba un error: modbus_tk.exceptions.ModbusInvalidResponseError: Response length is invalid 0 al depurar el error, comunicaba totalmente sin ninguna falla, solucione el bug, añadiendo tiemos en la rutina:

def threadsafe_function(fcn): """decorator making sure that the decorated function is thread safe""" lock = threading.RLock() time.sleep(0.02) ## tiempo añadido

def new(*args, **kwargs):
    """lock and call the decorated function"""
    lock.acquire()
    time.sleep(0.02)## tiempo añadido
    try:
        ret = fcn(*args, **kwargs)
        time.sleep(0.02)## tiempo añadido
    except Exception as excpt:
        raise excpt
    finally:
        lock.release()
    return ret
return new
ljean commented 7 years ago

Can you please explain the problems in english?

2016-10-05 6:07 GMT+02:00 sistemasmc1986 notifications@github.com:

Estuve intentando comunicar con un arduino MEGA pero simpre me tiraba un error: modbus_tk.exceptions.ModbusInvalidResponseError: Response length is invalid 0 al depurar el error, comunicaba totalmente sin ninguna falla, solucione el bug, añadiendo tiemos en la rutina:

def threadsafe_function(fcn): """decorator making sure that the decorated function is thread safe""" lock = threading.RLock() time.sleep(0.02) ## tiempo añadido

def new(_args, _kwargs): """lock and call the decorated function""" lock.acquire() time.sleep(0.02)## tiempo añadido try: ret = fcn(_args, _kwargs) time.sleep(0.02)## tiempo añadido except Exception as excpt: raise excpt finally: lock.release() return ret return new

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ljean/modbus-tk/issues/65, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQNOw0sDq3Z4gIksapNMyRZ09Fo6m5Qks5qwyJ1gaJpZM4KOZqQ .

sistemasmc1986 commented 7 years ago

I try to communicate Arduino with python using his Librarie, but allways stay in error, the interpreter says: modbus_tk.exceptions.ModbusInvalidResponseError: Response length is invalid 0,

Solve it by adding time to the function you mentioned.