If it's not a Leshan issue this is a bit out off topic, but
Instead of using schedule at fixed rate why not just running a new
task in 5s after each call of adjustDistance() ? (by running a
executor.shedule(yourtask, 5, TimeUnit.SECONDS).
Le 31/07/2017 à 15:48, Thong Q. Nguyen
a écrit :
Hi,
Thank you for your response. I tried a a random generating
sensor and it works perfectly as the example. So it is best
to say that the problem comes from my implementation of the
sensor. Let me explain a bit further about my scenario. I
use an ultrasonic sensor to collect the distance value
through the GPIO pin of the raspberry Pi. To access those
GPIO of the raspi, I have to use the library pi4j, so all
those gpio stuff comes from that library. The thread.sleep
in adjustDistance is to create the "rest time" between the
high pulse and the low pulse of the ultrasonic, so the
distance value can be calculated based on those pulses. As I
mentioned, the leshan server can read the value from the
ultrasonic, but only once because the adjustDistance method
seems not to loop inside the runable() of the main method
DistanceSensor. My best bet is that the runable() try to
initiate the new run when the adjustDistance() hasn't
finished yet, so I tried to increase the period time in
scheduler.scheduleAtFixedRate but it doesn't work either.
Best regards,
Thong Q. Nguyen
_______________________________________________
leshan-dev mailing list
leshan-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/leshan-dev
|