Dear @seya さん,
I am using your patch to run webiopi on a Pi3 and patching has worked flawlessly. Thank you so much for providing the patch for everyone of us! I think i speak for everyone when I say: THANK you so much!
However while experimenting with webiopi (sadly not supported by its maker anymore) i found a bug/flaw with the PWM slider implementation. I am not much of a programmer and far from understanding JAVA. I however believe this needs only minor tweaking and I was hoping that you could maybe integrate a fix for it in your patch?
This is what I found out:
When using the Java function webiopi().createAngleSlider(gpio)
a slider is generated on the GUI that is supposed to move a servo between -45 and +45 degrees.
This however does not work reliably with either Firefox / Chrome or Safari... BUT it does work using IE11 (sort of as we will find out later).
I decided to do some debugging:
I started the webiopi server in console mode to see some debug output. Every time I drag the PWM slider on the GUI I see a POST request of the follwing form on the debug output (where 18 is the gpio and -45 defines the target angle in this case):
2018-02-08 15:00:58 - HTTP - DEBUG - "POST /GPIO/18/pulseAngle/-45 HTTP/1.1" - 200 OK (Client: ::ffff:192.168.1.1 <Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0>)
I then noticed a difference between all the other browsers and IE11.
Whereas all the other browsers only send a single Post request once you let go of the slider (so to say they only send a single post request for the sliders target degree) IE11 all the time sends POST updates while dragging the slider:
Here is an example of Firefox/Chrome/Safari behavior when changing angle from -45° to -35°:
... POST /GPIO/18/pulseAngle/-45 ...
... POST /GPIO/18/pulseAngle/-35 ...
Here is how IE11 deals with the same task:
... POST /GPIO/18/pulseAngle/-45 ...
... POST /GPIO/18/pulseAngle/-44 ...
... POST /GPIO/18/pulseAngle/-43 ...
... POST /GPIO/18/pulseAngle/-42 ...
... POST /GPIO/18/pulseAngle/-40 ...
... POST /GPIO/18/pulseAngle/-39 ...
... POST /GPIO/18/pulseAngle/-38 ...
... POST /GPIO/18/pulseAngle/-37 ...
... POST /GPIO/18/pulseAngle/-36 ...
... POST /GPIO/18/pulseAngle/-35 ...
Quite interesting.
The next thing I noticed: Whereas the servo is supposed to travel in a single motion to the destination angle upon a POST request it will only move a tiny bit (much like only 1°).
So lets assume the current position of the servo is -45° and I want to move it to 0°:
I send ... POST /GPIO/18/pulseAngle/0 ...
However the servo will just move a tad into the desired direction .... say to approx -44°
I have to repeat the command ... POST /GPIO/18/pulseAngle/0 ...
another 44 times until the servo has finally reached it's destination (in 1° increments). From there it won't move any further on repeated commands which is okay.
Also IE11 suffers from that bug when not dragging the slider to it's destination (which results in continuous POST updates) but clicking(!) the slider right to the desired destination.
This is clearly a bug in the implementation of the slider and I wonder if you can include a fix with your patch? I am not much of a programmer and unfortunately I can not really help here but I think many people would be very thankful for that!
Thank you so much in advance!
Best regards
Thomas