nodesign / weio

weio
http://we-io.net
128 stars 35 forks source link

pulseIn timeout #266

Closed manuio closed 8 years ago

manuio commented 8 years ago

if the value of pulseIn timeout is superior to 1 second the function returns -1.

Console message: pulseIn( 23 , 0 , 1100000 ) PulseIn duration = -1

ks156 commented 8 years ago

pulseIn timeout parameter seems to be in microseconds instead of milliseconds

Indeed, timeout parameter is expressed in micro-seconds. Is it a problem ?

moreover if the value of timeout is superior to 1 second the function returns -1.

All UPER commands that requires a return value (like pulseIn) are blocking. To avoid to block the server if something goes wrong, there's a timeout of 1 sec (https://github.com/nodesign/weio/blob/master/IoTPy/pyuper/ioboard.py#L216)

You opened a ticket for that, but I don't understand if something must be changed in the code. For my point of view, this part of code is OK and works as expected, but the 1 sec timeout + param in microseconds must be documented.

manuio commented 8 years ago

Indeed, timeout parameter is expressed in micro-seconds. Is it a problem ?

timeout paramater unit is not a problem, I've done a mistake... I've edited the issue just while your comment.

You opened a ticket for that, but I don't understand if something must be changed in the code. For my point of view, this part of code is OK and works as expected, but the 1 sec timeout + param in microseconds must be documented.

IMHO the 1 sec parameter is very limiting, specially to do understandable examples. For example in Arduino this function works on pulses from 10 microseconds to 3 minutes in length. Moreover if timeout is superior to 1 sec the board enter in a strange state , the examples can't be stopped and the board needs to be restarted.

ks156 commented 8 years ago

IMHO the 1 sec parameter is very limiting, specially to do understandable examples. For example in Arduino this function works on pulses from 10 microseconds to 3 minutes in length.

Indeed, it's a bit short. This timeout is not a problem only for pulseIn, but also for other commands. This is unfortunately something we must keep due to IoTPy architecture. It's a big job to change it in IoTPy. Anyway, this lib will probably change soon, and I want to see the new library more asynchronous.

Moreover if timeout is superior to 1 sec the board enter in a strange state , the examples can't be stopped and the board needs to be restarted.

Either the LPC firmware or IoTPy crash when this occurs. Some works need to be done both side to be more robust. This is also in the TODO list.

For now, I suggest to leave it as is, and wait for further improvement of the firmware and IoTPy. I think it's OK to live with its limitations for now, imho.

@drasko, @ukicar : your opinion please :smile: