-
Notifications
You must be signed in to change notification settings - Fork 80
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
USB cam bandwidth requirements causing CAN bus timeouts #202
Comments
Hey thank for the issue and the provided ideas,
A small Google search gave me some results of a few possibilities to reduce the requested bandwidth. If you want to read yourself into it and make a PR, go for it. I will not implement such a thing myself at this point of time. Especially as there will be a rewrite of Crowsnest in Python first.
As I already mentioned the rewrite, currently Crowsnest is written in bash. Trust me if I say to you, that you don't want to implement such a thing in bash. If we have a good working Python implementation this might be something we would have to think about again, but atm this doesn't sound like something that is even possible.
This sounds like the best option out of those three. Currently there won't be such a thing like the timelapse support for the same reason as above. Currently you could add a macro with the gcode_shell_command script. Then just run So for now this won't be something we will add, as it's just not feasible for us to do so. |
Thanks for the pointers, and your reasoning makes a lot of sense to me. I will use the stop-gap solutions you suggested in the interim, and then hold off on doing anything else until the rewrite is complete and then consider if something could be done in crowsnest itself to handle this sort of situation more automatically! |
Hi, I would like to report the same issue. |
@czechbol The release notes from the release of last week. |
This seems to have done the trick! I have been able to successfully perform a few full probing sequences without any issues. |
@czechbol Can you describe your setup further? How many cams? The used Pi? What USB devices are connected beside the cams? Which USB port is each device connected (2.0/3.0)? @dflemstr please try to set |
@mryel00 Sure! My situation is very similar. I also have a Voron 2.4, with a Pi 4 2GB. I also use the EBB SB2209 CAN bus board on my toolhead. I only use a single Raspberry Pi Camera 3 Wide connected via the ribbon cable. I should probably also note that I don't run Mainsail OS, I flashed the official Raspberry Pi OS Lite 64bit and installed everything else with KIAUH, and I use Fluidd, but that shouldn't make any difference. I'm pretty confident in my linuxing skills after a few years of using it on my desktop. |
My recommendation get the BTT U2C and the octopus on the 2 USB2 ports and the cams on the USB3 port(s) |
Thanks, I will take a look at it during the week and report back later. |
Anecdotally the issue hasn't happened any more since enabling |
I'm readding the bug label. We already got confirmation of 2 other users with a Voron 2.4. So it's most likely something about that parameter and most likely something about the stepper motor count. We will revert that parameter soon, as it's a bit harder to see the connection between the timer too close and the cams than something affecting the stream directly. |
RPI4B with Pi Cam v2 over interface flat cable also giving me grief since the update where you added some stuff.. Right now running blind since i can't home or do anything on the V2.4 (u2c, ebb36, 2x skr1.4's) with crowsnest active. |
Like I wrote before, the only thing affecting anything is this one parameter. Everything else in the changelogs is just QOL and installer stuff.
@LAP87 Please elaborate on that further. I think this doesn't only happen with the idling printer as this would sound pretty weird. To give some idea of how we test updates. I'm testing this stuff on 3 different Pis. The Pi3B, Pi4B and the Pi0.2 with a picam v3, picam v2 and/or multiple USB cams. I use the updates for quite some time to identify issues that could happen. Besides me some members of the mainsail-crew are testing these changes too, especially something like that parameter change. This change also got tested from 3 or more members of the community. No one of us run into any problems. |
To clearly some here. In a multi home scenario run time of the signals are important. As I already mentioned on a PI4 (and honestly any V2 running multi board homing via CAN should use a PI4 and CAN setup set to 1MHz) should connect both mcu (your printer board and you und board) at the 2 USB2 ports and any cam on the USB3 port. |
@dflemstr is my assumption correct that you connect your x and z end stop/probe to the toolhead board? |
Yes |
Video clip of the stream in action, it behaved exactly the same before and after adding the custom flag (rebooted klipper, firmware, host, no changes) Host(aarch64, 64bit) I have not used ustreamer since crowsnest camera-streamer was released, i do not know if it behaves the same. |
You can just go back to an earlier version if you want. Go into the directory and use the |
About the video: |
Ran some more "scientific" experiments now. I'll do a full home, then QGL, then 15x15 bed mesh, just to see how far it gets. I would really need many samples for each experiment to get anything representative, but maybe this is some indication at least. Each run below uses the same config as in the original issue description above (2 cameras 720p 30fps) unless otherwise noted. I have one browser window open showing both streams. I already had my cameras connected to the USB 3 ports, and controllers (CAN bus, BTT octopus) connected to the USB 2 ports, prior to creating this issue ticket.
|
CrowsNest 2 seems to be contributing, I did have very few problems with V1 but since updating to V2 homing fails almost always. Not viewing any stream seems to reduce the load (checked with top), homing works reliable then. While printing timing seems less critical, usually OK to turn on the camera view then. With V1 I regularly was having video streams visible on a couple devices without issues (laptop next to the printer, desktop in the other room). Pi4, wired. |
@gknops pls doublecheck your crowsnest version number... we are right now in version 4. |
Of course. Until a couple months ago I had been on an ancient version due to the OS requirements of more recent builds. Just updated from 4.0.2 (IIRC) to the latest, will check if that makes a difference. |
Hello guys, I just stumbled over this thread. My issues started when I ran a full system update a few weeks ago, and as I didnt find a fix I first bought a new raspberry, then a new EBB42 and last but not least a new usb cable. Nothing helped. Unlike to the other reports here, my issues were not a 100% reproducible, but very sporadic. Sometimes I could print for 2-3 days without issues, then it would fail with a timeout during probing again. In the klipper discord, I found the tip to add "custom_flags: --camera-force_active=0". Will try that tomorrow. Please let me know if I can contribute to your analysis somehow. Regards! |
@SebastianMusser pls double-check your Crowsnest version number or update Crowsnest. This setting was revent to 0 in version v4.1.0. |
I was on 4.1.0.1 and just ran an update to 4.1... |
Hello i have the same problem with crowsnest v4. I get an overload by printing or timeout by probing. If i stop the crowsnest service i have no problems and the printer runs fine. Setup: |
@daTobi1 An exact version of Crowsnest would be good. You can find it at the top of your crowsnest.log. The main problem of this issue is already fixed, so if you don't use v4.1.0 and didn't update yet, we cannot do anything about it right now. As an overall note and not targeted at you. It doesn't help us, if people don't bring new informations to the table. Also I might add a feature to conveniently stop crowsnest for the probing, but currently it's not possible and I would have to think about a good solution for such a feature. |
my case I used the USB to CAN bus bridge to connect my Raspberry Pi 4 and spider2.3, the camera had frame loss problems. |
@JunyuMu FYI: the CANHAT is not recommended by Klipper because of the small buffer. |
Hey, I switched to a Raspberry Pi 5 now, and anecdotally I haven't had any issues with CANbus timeouts yet. On rpi4 I had to run with:
... as mentioned above, but so far I haven't needed that change on rpi5. Only unfortunate thing is that camera-streamer doesn't support rpi5 yet, but I'm happy using MJPEG and a working printer compared to WebRTC and a non-working printer :) |
I switched the CAN-hat to a Canable 1.0 board via USB and also had no issues since (with limited testing). |
For the record I use Canable Pro 2.0 as mentioned in the original post, and in my experience switching CAN transceiver board hasn't been helpful for me. |
I am having this issue as well. Crowsnest v4.1.4-1-gba0ac8fb. Changing TRSYNC_TIMEOUT from 0.025 to 0.05 in /home/pi/klipper/klippy/mcu.py cause my klipper install to be dirty and mainsail makes me soft or hard recover before updating. Any fix for this yet? Setup: |
No, we don't provide features to stop the cam during your homing. You can see the status of this issue at the top of your page. As long as it says opened, we didn't implement that feature. I'm already thinking of locking this post down and open a new FR, as the initial issue got already fixed. The issue about a specific parameter. Everything else is nothing we can fix, we can only provide workarounds that people can use. But we will still need a long time before this can work, as it's impossible with the current codebase.
Exactly. We cannot provide fixes for limited HW capabilities. We also can only provide bandaid fixes, like stopping the cam during homing (the initial issue). This bandaid fix won't come in the near future.
Your issue seems to be related to processing power and not USB bandwidth and that's nothing we can fix either ofc. You shouldn't set arcs too low as this will create a lot of load. Default is a Overall a Pi5 isn't a good alternative for camera streaming as it is missing H264 HW encoding. Therefore you won't get WebRTC support. CSI cam support isn't possible too atm, but might come in a future update. As an overall reminder: |
@mryel00 you were right, it turns out I didn't understand what the arc resolution means and out of fear of seeing resolution artefacts in my prints I set it way too low. There was nothing wrong with Crowsnest or CAN bus in my case |
Since it sounds like you are not recommending Pi5 what should we get to have this running correctly? Thanks |
Like I said, it's not a good alternative for camera streaming. You can ofc use a Pi5 for your printer, but I cannot say anything about it, if it will be good or bad for the printing use case, especially on those setups. I'm only certain of the fact that the Pi5 is by far overspecced for the printing use case. |
So when I uninstall Crowsnest it works just fine. No issues. I will read into alexz tests. Thanks |
@mryel00 We can probably close this issue so that folks don't go through and try all the other silly suggestions that do not work. Simply, the solution suggested by Alexz works. What you actually want to do is limit the cameras from saturating the USB channel. On the pi4 there is a built in USB 3.0 hub that forwards both USB 2.0 and 3.0 traffic. The USB 2.0 ports share a common root port via an integrated USB 2.0 4-port hub, so the total USB 2.0 bandwidth across all the ports is 480Mbps. You can use this bandwidth limit to prevent the cameras from saturating the upstream USB 3.0 hub by keep all your cameras on the USB 2.0 ports. Using a USB 2.0 hub connected to the USB 3.0 port works the same. Better yet, get an old USB 2.0 hub and you'll be able to connect it to any ports. See the known pi USB issues. I ran 4 15x15 bed mesh torture tests with 3 cameras running at 1920x1080. The timeout went away if you isolate the cameras away from the CAN. The easiest thing to do is connect all your USB cameras to a USB 2.0 hub and free up all the other ports for your other devices. Check your USB tree setup with
|
Thanks for the long explanation. As I said earlier I wanted to keep it up as some tracker for some other feature, but after this wonderful explanation, I will close it without locking it for now. Thanks again for your time and research on this. |
What happened
On my modded Voron 2.4, when having cameras enabled with high resolution (in my case, a chamber and a nozzle camera, each running at 720p), any devices that use CAN bus for communication regularly time out. For example, Z or X homing times out, or doing bed probing/quad gantry leveling/...
Disabling the crowsnest service during homing/probing of the printer makes the operation succeed every time. Turning crowsnest back on once the printer has started printing doesn't cause any issues, and print jobs can complete successfully.
I'm using "modern" v4 crowsnest with camera-streamer and webrtc, but this issue also used to occur with v3, or mjpeg streaming.
What did you expect to happen
I would expect homing/probing to succeed without having to disable the crowsnest service.
How to reproduce
Communication timeout while homing Z
Additional information
One possible solution could be for crowsnest to somehow control the priority of USB traffic when interacting with webcams, but I'm not sure if that's possible with current Linux APIs?
Another option could be to have crowsnest detect timing sensitive operations like homing/bed probing in Klipper and pause streaming/reducing resolution/... during that time
A third option could be to add crowsnest g-code accessible commands that lets e.g. a
PRINT_START
macro pause crowsnest during homing; similar to how the current timelapse support is working.The text was updated successfully, but these errors were encountered: