Reply To: Webserver

HomeForumsMonoBrick EV3 FirmwareWebserverReply To: Webserver

#5155
Author Image
Jacek S
Participant

Hi

The starting time is the next thing that I don’t like.
Yes I’m sure, I did many tests yesterday. My test program is configured to send ajax posts with 250ms breaks (when the position of joystick is changed). This means that Nancy on the brick have problem with handling 4 requests per second.

handler code:


            Post["/joypos"] = x => 
            {
                JoyPos pos = this.Bind();
                LcdConsole.WriteLine("X:{0} Y:{1}",pos.X,pos.Y);
                var speed = (sbyte) (pos.Y > 100 ? 100 : pos.Y < -100 ? 100 : pos.Y);
                if (speed == 0) 
                    motor.Off();
                else 
                    motor.SetSpeed(speed);
                return Response.AsJson(pos);
            };

poster code:


var timer = $.timer(function () {
    if (Math.abs(x - lastx) > 5 || Math.abs(y - lasty) > 5) {
        lastx = x;
        lasty = y;
        $.post("/truck/joypos", { X: x, Y: y});
    }
});
timer.set({ time: 250, autostart: true });
  • This reply was modified 2 years, 6 months ago by Author Image Jacek S.
Posted in

Make a donation