#[SOLVED] Disabling box turtle automatically if USB is unplugged on printer boot
1 messages · Page 1 of 1 (latest)
<@&1304550334839918672>
Just comment out the include AFC line when you want to do this, otherwise it’s not possible in vanilla Klipper
ok. So there's no way to have it be conditional on the serial device being present?
Not in Vanilla Klipper, if you’re running Kalico it can be a non-critical MCU and you can use the bypass functionality to disable the AFC software stuff
ok, thanks. I'm running Vanilla Klipper but might look into Kalico then
It was added in newest Kalico release, non critical is supported on CAN
I'm on USB so I guess it's fine for my setup 🙂
I’m sorry, this is false, the PR is still open.
i knew it was coming. 🙂 but not there yet
Yeah, I had seen someone mention it elsewhere and misremembered it being merged
Non-critical mcu is not always working flawless. Sometimes it still kick you out. Too much stuff around the USB comunication with klipper/(Kevin😆)/calico/linux
For me the bypass is the best solution, but yes, it needs to stay connected in this case.
I'm considering having a boot cron job or something create a intermediate config file which either loads the AFC ones or not based on serial presence ... will share if that ends up working
Sounds interesting 👍
Would be cool to have one (or more) switch for different options
could write a gcode shell command macro which swaps printer.cfg files and restarts klipper
can you actually run shell scripts from gcode?
with the gcode shell command extension yes
that’s how klippain shake&tune works
think you can also run python natively
interesting
So using vanilla Klipper the following seems to work:
/etc/systemd/system/should-load-afc.service
Description=Determine if AFC configuration should be loaded by Klipper based on serial presence
Before=klipper.service
[Service]
Type=simple
StandardOutput=journal
User=antoine
WorkingDirectory=/home/antoine/printer_data/config/AFC/
ExecStart=/home/antoine/printer_data/config/AFC/should-load-afc.sh
[Install]
WantedBy=klipper.service```
~/printer_data/config/AFC/should-load-afc.sh
```#!/usr/bin/env sh
set -e
set -x
afc_serial=$(grep "^serial:" AFC_Turtle_1.cfg| sed 's/serial: *//')
afc_load_cfg=should_load_AFC.cfg
echo "# Looking for $afc_serial" > $afc_load_cfg
if [ -e "$afc_serial" ]; then
# assumes the script is run from the config/AFC/ folder
echo "[include AFC*.cfg]" >> $afc_load_cfg
else
echo "# Didn't find serial. will not load AFC config files" >> $afc_load_cfg
fi```
~/printer_data/config/printer.cfg
```[include AFC/should_load_AFC.cfg]```
also added conditionals around the PRINT_START macro AFC specifics:
gcode:
{% set BED_TEMP = params.BED|default(60)|float %}
{% set EXTRUDER_TEMP = params.EXTRUDER|default(195)|float %}
{% set initial_tool = params.TOOL|default("0")|int %}
LIGHTS_ON
G90 ; set absolute positioning
G28 ; home all axes
{% if printer['gcode_macro _AFC_GLOBAL_VARS'] is defined %}
# Only run AFC specifics if AFC is actually enabled
AFC_PARK
M140 S{BED_TEMP} # Set bed temp
M109 S{EXTRUDER_TEMP} # wait for extruder temp
T{initial_tool} #Load Initial Tool
{% endif %}
G1 Z20 F3000 ; move nozzle away from bed
{% if printer.extruder.can_extrude|lower == 'true' %}
G92 E0 ; reset extruder length
G1 E4 F60 ; extrude filament
G92 E0 ; reset extruder length
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}```
seems to be working nicely so far.
When posting configs, logs, or any other sort of code, please surround the text with code fences (```) to make it easier to read. Example:
```
[AFC_BoxTurtle Turtle_1]
type: 'Box Turtle'
```
type: 'Box Turtle'```
fixed. sorry
No problem just makes it easier to read