Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiple connects causing erratic plots #195

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

alexrudd2
Copy link
Collaborator

See alexrudd2#113. Closes #194. Closes #131

summary

saxi is usually OK on a fast laptop, but can cause erratic and jerky plots on smaller devices like a Raspberry Pi. This PR smooths things out.

details

0.0.15 code creates up to 5 duplicate WebSocket connections, as an unintended side effort of adding WebSerial. They occur even when WebSerial isn't being used.
image

This PR removes the duplicates with two ways:

  • The event listeners for drag-n-drop don't need to be called multiple times, so pass [] as the second argument to useEffect.
  • Wrap the SaxiDriver.connect() call in a flag so it doesn't get called multiple times in Root().

@alexrudd2
Copy link
Collaborator Author

@osresearch @lostPixels @edouard-gillet @jimmykl @ostwilkens @julienes (and @oskay for good measure 😃 )

You had all reported erratic plots with saxi 0.15.0, generally on a Raspberry Pi. Can you try out this fix and let me know if it helps?

You can install from this pull request, or the fork (which adds brushless servo support too).

@nornagon nornagon merged commit 6923fe9 into nornagon:main Oct 26, 2023
4 checks passed
@nornagon
Copy link
Owner

Nice, good catch.

@alexrudd2 alexrudd2 deleted the fix-multiple-connects-origin branch October 26, 2023 17:44
@julienes
Copy link

Thank you very much for your feedback. I took a break from the plotter, I hadn't had a chance to try it out. So I updated Saxi today with this new version, and my servo motor doesn't respond at all. I can launch a drawing, the arm moves, but no up and down. I don't know if it worked for anyone else.

@alexrudd2
Copy link
Collaborator Author

Thank you very much for your feedback. I took a break from the plotter, I hadn't had a chance to try it out. So I updated Saxi today with this new version, and my servo motor doesn't respond at all. I can launch a drawing, the arm moves, but no up and down. I don't know if it worked for anyone else.

Strange, I've not seen that fail. Are you on a brushed or brushless motor? You might want to try https://github.com/alexrudd2/saxi, since that has an option to switch between both.

@julienes
Copy link

Yes, I have the brushless motor. I've tried it on my mac and on the raspberry, but in both cases, I can just launch the plot, but the servo motor doesn't work. I'll try again to install version 0.14 to see if it works like before already. I'll tell you again quickly.

@alexrudd2
Copy link
Collaborator Author

Yes, I have the brushless motor. I've tried it on my mac and on the raspberry, but in both cases, I can just launch the plot, but the servo motor doesn't work. I'll try again to install version 0.14 to see if it works like before already. I'll tell you again quickly.

Ah, yeah that explains it. 0.14 never worked with brushless, so you manually modified the code per #136. The modifications got replaced when you switched.

Use the fork: https://github.com/alexrudd2/saxi. It works well for several people, and we intend to merge back here when @nornagon gets some time. :)

There's a new checkbox to switch between brushed and brushless.
Screenshot 2023-11-12 at 10 09 56 AM
Alternatively, run saxi --hardware brushless.

@julienes
Copy link

Yes, I installed this version and uninstalled version 0.14. I have the checkbox, but the Servo motor doesn't respond. But if it works for the others, I'll try to find out why. I tested with inkscape to see if the Servo worked, and yes, it does.

@alexrudd2
Copy link
Collaborator Author

Strange. Does it work with --hardware brushless instead of the checkbox?

@julienes
Copy link

No, nothing happens. it identifies the connection correctly. when I start the drawing, the arm moves, but there's no action on the servo, either with the settings or during the drawing. No error in the console either
Capture d’écran 2023-11-12 à 21 24 17

@jedahan
Copy link
Contributor

jedahan commented Nov 13, 2023

that looks like its npm start - if you start that way, try npm start -- --hardware brushless. The double -- is to make sure npm script runner passes that to the script, and doesn't try to apply to npm itself.

It is possible the runtime checkbox is not fully working, I should test again.

@julienes
Copy link

Ok, this way it works for both, mac and raspberry PI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants