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 breaking klipper change #5

Closed
wants to merge 1 commit into from
Closed

Fix breaking klipper change #5

wants to merge 1 commit into from

Conversation

thetic
Copy link

@thetic thetic commented Oct 2, 2024

Fix #4

Copy link

@sudo-su-root sudo-su-root left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not working for me, I manually updated src/virtual_leds.py on my machine with your change and no joy :(

@thetic
Copy link
Author

thetic commented Oct 3, 2024

Not working for me, I manually updated src/virtual_leds.py on my machine with your change and no joy :(

Do you have a log?

@sudo-su-root
Copy link

sudo-su-root commented Oct 3, 2024

[neopixel top]
pin: PD2
chain_count: 15
color_order: GRB
initial_RED: 0.0
initial_GREEN: 0.0
initial_BLUE: 0.0

[virtual_leds top_left]
leds: neopixel:top (1,2,3,4,5,6,7,8)

[virtual_leds top_right]
leds: neopixel:top (8,9,10,11,12,13,14,15)

[led_effect top_left]
autostart: true
frame_rate: 24
leds:
virtual_leds:top_left
layers:
comet -0.5 1.0 top (1, 0.0, 0.0),(0.5, 0.0, 0.0),(0.3, 0.0, 0.0),(0.1, 0.0, 0.0)
[led_effect top_right]
autostart: true
frame_rate: 24
leds:
virtual_leds:top_right
layers:
comet 0.5 1.0 top (1, 0.0, 0.0),(0.5, 0.0, 0.0),(0.3, 0.0, 0.0),(0.1, 0.0, 0.0)

    
import logging
from .led import LEDHelper

class PrinterVirtualLeds:
    def __init__(self, config):
        self.printer = printer = config.get_printer()
        name = config.get_name().split()[1]

        # Initialize color data
        self.configChains = [self.parse_chain(line) for line in config.get('leds').split('\n') if line.strip()]
        self.led_helper = LEDHelper(config, self.update_leds, 1)

        # Register commands
cat klipper/klippy/extras/virtual_leds.py | grep LEDHelper
from .led import LEDHelper
        self.led_helper = LEDHelper(config, self.update_leds, 1)

cat klipper-virtual_leds/src/virtual_leds.py  | grep LEDHelper
from .led import LEDHelper
        self.led_helper = LEDHelper(config, self.update_leds, 1)

Config error
Traceback (most recent call last):
File "/home/alexh/klipper/klippy/klippy.py", line 130, in _connect
self._read_config()
File "/home/alexh/klipper/klippy/klippy.py", line 123, in _read_config
self.load_object(config, section_config.get_name(), None)
File "/home/alexh/klipper/klippy/klippy.py", line 112, in load_object
self.objects[section] = init_func(config.getsection(section))
File "/home/alexh/klipper/klippy/extras/virtual_leds.py", line 103, in load_config_prefix
return PrinterVirtualLeds(config)
File "/home/alexh/klipper/klippy/extras/virtual_leds.py", line 41, in init
self.configChains = [self.parse_chain(line) for line in config.get('leds').split('\n') if line.strip()]
File "/home/alexh/klipper/klippy/klippy.py", line 111, in load_object
raise self.config_error("Unable to load module '%s'" % (section,))
configparser.Error: Unable to load module 'led'

@thetic
Copy link
Author

thetic commented Oct 3, 2024

are you on the latest klipper?

@sudo-su-root
Copy link

Yer latest, that's what blew everything up. If I comment out anything using virtual_leds then everything works fine.

image

@thetic
Copy link
Author

thetic commented Oct 4, 2024

Yer latest, that's what blew everything up. If I comment out anything using virtual_leds then everything works fine.

image

That doesn't show that you're using my changes.

@sudo-su-root
Copy link

Yer latest, that's what blew everything up. If I comment out anything using virtual_leds then everything works fine.
image

That doesn't show that you're using my changes.

Shows I’m using latest, I edited the file manually with your changes as shown posts up. After a couple of restarts the files are checked and Up-To-Date changes to Dirty.

@thetic
Copy link
Author

thetic commented Oct 4, 2024

I have a very similar config and cannot reproduce your failure.

@sudo-su-root
Copy link

sudo-su-root commented Oct 4, 2024

OK I had a spare pi zero with usb network connection to play with to ensure your change works or not so it seems. The list below is absolutely everything that has been done on a blank vanilla install. With no actual printer connected.

Is it possible you have done a little more somewhere else other than in your change on this one file?

Rasberry pi imager v1.8.5 - > Mainsail OS 1.3.2 flashed to 8GB SD card.
32bit this time due to pi version, my main printer is 64bit version.
Insert card and boot
Created printer.cfg using template but changed nothing... https://github.com/Klipper3d/klipper/blob/master/config/generic-bigtreetech-skr-mini-e3-v3.0.cfg
Firmware restart
image

Let the update manager spin for a while then once it knew where it was up to clicked the "Update all components" option, takes ages updating OS stuff as well as klipper and so on.
Just to be sure...
sudo apt-get update
sudo apt-get upgrade
Firmware restart
image

Now install lipper-led_effect

cd ~
git clone https://github.com/julianschill/klipper-led_effect.git
cd klipper-led_effect
./install-led_effect.sh

and add a neopixel to printer.cfg

[neopixel ledchain]
pin: PD2
chain_count: 1

Firmware restart just to be sure
image

Now install  klipper-virtual_leds
cd ~
git clone https://github.com/MapleLeafMakers/klipper-virtual_leds.git
cd klipper-virtual_leds
./install-virtual_leds.sh

Firmware restart just to be sure
image

Add the virtual LED block to printer.cfg

[virtual_leds top_right]
leds:
  neopixel:ledchain (1)

Firmware restart just to be sure
image

OK expected issue now showing so nano src/virtual_leds.py
Added the import, removed the two lines and added the replacement self.led_helper = ... line
image
Firmware restart just to be sure
image

echo "" > ~/printer_data/logs/klippy.log
Firmware restart

=======================


Attempting MCU 'mcu' reset
Unhandled exception during post run
Traceback (most recent call last):
  File "/home/alexh/klippy-env/lib/python3.9/site-packages/serial/serialposix.py", line 265, in open
    self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
FileNotFoundError: [Errno 2] No such file or directory: '/dev/serial/by-id/usb-Klipper_Klipper_firmware_12345-if00'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alexh/klipper/klippy/klippy.py", line 193, in run
    self.send_event("klippy:firmware_restart")
  File "/home/alexh/klipper/klippy/klippy.py", line 223, in send_event
    return [cb(*params) for cb in self.event_handlers.get(event, [])]
  File "/home/alexh/klipper/klippy/klippy.py", line 223, in <listcomp>
    return [cb(*params) for cb in self.event_handlers.get(event, [])]
  File "/home/alexh/klipper/klippy/mcu.py", line 955, in _firmware_restart
    self._restart_arduino()
  File "/home/alexh/klipper/klippy/mcu.py", line 915, in _restart_arduino
    serialhdl.arduino_reset(self._serialport, self._reactor)
  File "/home/alexh/klipper/klippy/serialhdl.py", line 380, in arduino_reset
    ser = serial.Serial(serialport, 2400, timeout=0, exclusive=True)
  File "/home/alexh/klippy-env/lib/python3.9/site-packages/serial/serialutil.py", line 240, in __init__
    self.open()
  File "/home/alexh/klippy-env/lib/python3.9/site-packages/serial/serialposix.py", line 268, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/serial/by-id/usb-Klipper_Klipper_firmware_12345-if00: [Errno 2] No such file or directory: '/dev/serial/by-id/usb-Klipper_Klipper_firmware_12345-if00'
Restarting printer
Start printer at Fri Oct  4 10:54:58 2024 (1728035698.2 7846.7)
===== Config file =====
[neopixel ledchain]
pin = PD2
chain_count = 1

[virtual_leds top_right]
leds = 
	neopixel:ledchain (1)

[stepper_x]
step_pin = PB13
dir_pin = !PB12
enable_pin = !PB14
microsteps = 16
rotation_distance = 40
endstop_pin = ^PC0
position_endstop = 0
position_max = 235
homing_speed = 50

[tmc2209 stepper_x]
uart_pin = PC11
tx_pin = PC10
uart_address = 0
run_current = 0.580
stealthchop_threshold = 999999

[stepper_y]
step_pin = PB10
dir_pin = !PB2
enable_pin = !PB11
microsteps = 16
rotation_distance = 40
endstop_pin = ^PC1
position_endstop = 0
position_max = 235
homing_speed = 50

[tmc2209 stepper_y]
uart_pin = PC11
tx_pin = PC10
uart_address = 2
run_current = 0.580
stealthchop_threshold = 999999

[stepper_z]
step_pin = PB0
dir_pin = PC5
enable_pin = !PB1
microsteps = 16
rotation_distance = 8
endstop_pin = ^PC2
position_endstop = 0.0
position_max = 250

[tmc2209 stepper_z]
uart_pin = PC11
tx_pin = PC10
uart_address = 1
run_current = 0.580
stealthchop_threshold = 999999

[extruder]
step_pin = PB3
dir_pin = !PB4
enable_pin = !PD1
microsteps = 16
rotation_distance = 33.500
nozzle_diameter = 0.400
filament_diameter = 1.750
heater_pin = PC8
sensor_type = EPCOS 100K B57560G104F
sensor_pin = PA0
control = pid
pid_kp = 21.527
pid_ki = 1.063
pid_kd = 108.982
min_temp = 0
max_temp = 250

[tmc2209 extruder]
uart_pin = PC11
tx_pin = PC10
uart_address = 3
run_current = 0.650

[heater_bed]
heater_pin = PC9
sensor_type = EPCOS 100K B57560G104F
sensor_pin = PC4
control = pid
pid_kp = 54.027
pid_ki = 0.770
pid_kd = 948.182
min_temp = 0
max_temp = 130

[heater_fan heatbreak_cooling_fan]
pin = PC7

[heater_fan controller_fan]
pin = PB15

[fan]
pin = PC6

[mcu]
serial = /dev/serial/by-id/usb-Klipper_Klipper_firmware_12345-if00

[printer]
kinematics = cartesian
max_velocity = 300
max_accel = 3000
max_z_velocity = 5
max_z_accel = 100

[board_pins]
aliases = 
	
	EXP1_1=PB5,  EXP1_3=PA9,   EXP1_5=PA10, EXP1_7=PB8, EXP1_9=<GND>,
	EXP1_2=PA15, EXP1_4=<RST>, EXP1_6=PB9,  EXP1_8=PD6, EXP1_10=<5V>
=======================
Config error
Traceback (most recent call last):
  File "/home/alexh/klipper/klippy/klippy.py", line 130, in _connect
    self._read_config()
  File "/home/alexh/klipper/klippy/klippy.py", line 123, in _read_config
    self.load_object(config, section_config.get_name(), None)
  File "/home/alexh/klipper/klippy/klippy.py", line 112, in load_object
    self.objects[section] = init_func(config.getsection(section))
  File "/home/alexh/klipper/klippy/extras/virtual_leds.py", line 103, in load_config_prefix
    return PrinterVirtualLeds(config)
  File "/home/alexh/klipper/klippy/extras/virtual_leds.py", line 41, in __init__
    self.configChains = [self.parse_chain(line) for line in config.get('leds').split('\n') if line.strip()]
  File "/home/alexh/klipper/klippy/klippy.py", line 111, in load_object
    raise self.config_error("Unable to load module '%s'" % (section,))
configparser.Error: Unable to load module 'led'
webhooks client 3040160976: New connection
webhooks client 3040160976: Client info {'program': 'Moonraker', 'version': 'v0.9.3-0-g71f9e67'}

@sudo-su-root
Copy link

Figured out the native led_effect support for splitting the chains so I can live without this anyway. neopixel:top (1-8)


[led_effect on_active_1]
autostart:              true
frame_rate:             24
leds:
    neopixel:top (1-8)
layers:
  comet  -0.5 1.0 top (1, 0.0, 0.0),(0.5, 0.0, 0.0),(0.3, 0.0, 0.0),(0.1, 0.0, 0.0)

[led_effect on_active_2]
autostart:              true
frame_rate:             24
leds:
    neopixel:top (8-15)
layers:
    comet  0.5 1.0 top (1, 0.0, 0.0),(0.5, 0.0, 0.0),(0.3, 0.0, 0.0),(0.1, 0.0, 0.0)

[led_effect on_active_3]
autostart:              true
frame_rate:             24
leds:
    neopixel:left
    neopixel:right
layers:
    progress -1 0 add (0,0,1),(0,0.1,0.6)
    static    0 0 top (0,0,0.1)

[led_effect on_active_4]
autostart:              true
frame_rate:             24
leds:
    neopixel:bed
    neopixel:extruder
layers:
    static  1 0 top (.1,.1,.1)

@thetic
Copy link
Author

thetic commented Oct 7, 2024

I've tested these changes on three machines now. It seems to require restarting a few components (moonraker, klipper. etc) to take, so I recommend rebooting the system instead.

cd ~/klipper-virtual_leds
git remote set-url origin https://github.com/thetic/klipper-virtual_leds.git
git pull
sudo reboot

@thetic thetic closed this by deleting the head repository Oct 15, 2024
@rahulvij
Copy link

rahulvij commented Nov 5, 2024

Excellent work @thetic , i manually updated the file and rebooted the pi & it resolved the issue. This should be merged into the main branch.

@thetic
Copy link
Author

thetic commented Nov 5, 2024

I ran into some bugs that I haven't had time to look into. This is not a complete fix.

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

Successfully merging this pull request may close these issues.

klipper 0.12.0-315-g8f361a15 breakage
3 participants