#[SOLVED] Disabling box turtle automatically if USB is unplugged on printer boot

1 messages · Page 1 of 1 (latest)

wise lake
#

Hi, I'm using USB to connect the AFC lite to my v0.1. I'd like to get it setup so that it can start without the box turtle being connected and operate like a vanilla single tool printer. Is that something which is possible to configure?

frail lynxBOT
#

<@&1304550334839918672>

digital minnow
#

Just comment out the include AFC line when you want to do this, otherwise it’s not possible in vanilla Klipper

wise lake
#

ok. So there's no way to have it be conditional on the serial device being present?

digital minnow
#

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

wise lake
#

ok, thanks. I'm running Vanilla Klipper but might look into Kalico then

fallow fable
#

can’t do non critical yet with canbus though, i think.

#

but usb; yes.

digital minnow
#

It was added in newest Kalico release, non critical is supported on CAN

wise lake
#

I'm on USB so I guess it's fine for my setup 🙂

digital minnow
fallow fable
digital minnow
#

Yeah, I had seen someone mention it elsewhere and misremembered it being merged

glacial palm
#

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.

wise lake
#

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

glacial palm
#

Sounds interesting 👍
Would be cool to have one (or more) switch for different options

fallow fable
#

could write a gcode shell command macro which swaps printer.cfg files and restarts klipper

wise lake
#

can you actually run shell scripts from gcode?

fallow fable
#

with the gcode shell command extension yes

#

that’s how klippain shake&tune works

#

think you can also run python natively

wise lake
#

interesting

wise lake
#

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.

frail lynxBOT
#

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'```
autumn fossil
#

No problem just makes it easier to read