nlef / moonraker-telegram-bot

Telegram bot to interact with Moonraker (Klipper Web API Server)
Creative Commons Zero v1.0 Universal
245 stars 65 forks source link

[Bug]: Not fully functioning if macro name is longer than 32 letters #120

Closed radaiko closed 2 years ago

radaiko commented 2 years ago

What happened and in what context?

Since the update on 1.4.0 or higher the bot has lost many functions.

  1. I can request a status with /status but there is will be no temperatures and progress and co is always 0.
  2. /cancel is not process. I get the message if I really want it but there will be no execution on the Klipper side.
  3. If any error appears I get no notification
  4. I have a process_notification in my cfg but no notification will be send.

I remove the bot completely via KIAUH and installed it now. Then it worked for about a week. Today directly after a print finished I got the message "Printer Online" (I didn't request a restart and the PI also didn't restart) and now I have the same problems as mention above.

Only solution is completely delete and reinstall.

If needed, paste the relevant bot log contents here.

2022-03-05 08:32:47,044 - camera - DEBUG - General configuration for OpenCV 3.2.0 ===================================== Version control: unknown

Extra modules: Location (extra): /build/opencv-tragD2/opencv-3.2.0+dfsg/contrib/modules Version control (extra): unknown

Platform: Timestamp: 2019-02-12T11:26:31Z Host: Linux 4.9.0-8-arm64 aarch64 CMake: 3.13.4 CMake generator: Unix Makefiles CMake build tool: /usr/bin/make Configuration: Release

C/C++: Built as dynamic libs?: YES C++ Compiler: /usr/bin/c++ (ver 8.2.0) C++ flags (Release): -g -O2 -fdebug-prefix-map=/build/opencv-tragD2/opencv-3.2.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O2 -fdebug-prefix-map=/build/opencv-tragD2/opencv-3.2.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -DNDEBUG C++ flags (Debug): -g -O2 -fdebug-prefix-map=/build/opencv-tragD2/opencv-3.2.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG C Compiler: /usr/bin/cc C flags (Release): -g -O2 -fdebug-prefix-map=/build/opencv-tragD2/opencv-3.2.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fvisibility=hidden -g -O2 -fdebug-prefix-map=/build/opencv-tragD2/opencv-3.2.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -DNDEBUG C flags (Debug): -g -O2 -fdebug-prefix-map=/build/opencv-tragD2/opencv-3.2.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG Linker flags (Release): -Wl,-z,relro -Wl,-z,now -Wl,-z,relro -Wl,-z,now Linker flags (Debug): -Wl,-z,relro -Wl,-z,now ccache: NO Precompiled headers: NO Extra dependencies: /usr/lib/aarch64-linux-gnu/libwebp.so gdcmMSFF /usr/lib/aarch64-linux-gnu/libImath.so /usr/lib/aarch64-linux-gnu/libIlmImf.so /usr/lib/aarch64-linux-gnu/libIex.so /usr/lib/aarch64-linux-gnu/libHalf.so /usr/lib/aarch64-linux-gnu/libIlmThread.so /usr/lib/libgdal.so gtk-3 gdk-3 pangocairo-1.0 pango-1.0 atk-1.0 cairo-gobject cairo gdk_pixbuf-2.0 gio-2.0 gobject-2.0 glib-2.0 gthread-2.0 dc1394 avcodec avformat avutil swscale avresample gphoto2 gphoto2_port /usr/lib/aarch64-linux-gnu/hdf5/serial/libhdf5.so /usr/lib/aarch64-linux-gnu/libpthread.so /usr/lib/aarch64-linux-gnu/libsz.so /usr/lib/aarch64-linux-gnu/libdl.so /usr/lib/aarch64-linux-gnu/libm.so vtkRenderingOpenGL vtkImagingHybrid vtkIOImage vtkCommonDataModel vtkCommonMath vtkCommonCore vtksys vtkCommonMisc vtkCommonSystem vtkCommonTransforms vtkCommonExecutionModel vtkDICOMParser vtkIOCore /usr/lib/aarch64-linux-gnu/libz.so vtkmetaio /usr/lib/aarch64-linux-gnu/libjpeg.so /usr/lib/aarch64-linux-gnu/libpng.so /usr/lib/aarch64-linux-gnu/libtiff.so vtkImagingCore vtkRenderingCore vtkCommonColor vtkFiltersExtraction vtkFiltersCore vtkFiltersGeneral vtkCommonComputationalGeometry vtkFiltersStatistics vtkImagingFourier vtkalglib vtkFiltersGeometry vtkFiltersSources vtkInteractionStyle vtkRenderingLOD vtkFiltersModeling vtkIOPLY vtkIOGeometry vtkFiltersTexture vtkRenderingFreeType /usr/lib/aarch64-linux-gnu/libfreetype.so vtkftgl vtkIOExport vtkRenderingAnnotation vtkImagingColor vtkRenderingContext2D vtkRenderingGL2PS vtkRenderingContextOpenGL /usr/lib/aarch64-linux-gnu/libgl2ps.so vtkRenderingLabel tesseract lept dl m pthread rt tbb 3rdparty dependencies:

OpenCV modules: To be built: core flann hdf imgproc ml photo reg surface_matching video viz freetype fuzzy imgcodecs shape videoio highgui objdetect plot superres ts xobjdetect xphoto bgsegm bioinspired dpm face features2d line_descriptor saliency text calib3d ccalib datasets rgbd stereo stitching videostab ximgproc aruco optflow phase_unwrapping structured_light java python2 python3 Disabled: world contrib_world Disabled by dependency: tracking Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cnn_3dobj cvv dnn matlab sfm

GUI: QT: NO GTK+ 3.x: YES (ver 3.24.5) GThread : YES (ver 2.58.3) GtkGlExt: NO OpenGL support: NO VTK support: YES (ver 6.3.0)

Media I/O: ZLib: /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.11) JPEG: /usr/lib/aarch64-linux-gnu/libjpeg.so (ver ) WEBP: /usr/lib/aarch64-linux-gnu/libwebp.so (ver encoder: 0x020e) PNG: /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.6.36) TIFF: /usr/lib/aarch64-linux-gnu/libtiff.so (ver 42 - 4.0.10) JPEG 2000: NO OpenEXR: /usr/lib/aarch64-linux-gnu/libImath.so /usr/lib/aarch64-linux-gnu/libIlmImf.so /usr/lib/aarch64-linux-gnu/libIex.so /usr/lib/aarch64-linux-gnu/libHalf.so /usr/lib/aarch64-linux-gnu/libIlmThread.so (ver 2.2.1) GDAL: /usr/lib/libgdal.so GDCM: YES (ver 2.8.8)

Video I/O: DC1394 1.x: NO DC1394 2.x: YES (ver 2.2.5) FFMPEG: YES avcodec: YES (ver 58.35.100) avformat: YES (ver 58.20.100) avutil: YES (ver 56.22.100) swscale: YES (ver 5.3.100) avresample: YES (ver 4.0.0) GStreamer: NO OpenNI: NO OpenNI PrimeSensor Modules: NO OpenNI2: NO PvAPI: NO GigEVisionSDK: NO Aravis SDK: NO UniCap: NO UniCap ucil: NO V4L/V4L2: NO/YES XIMEA: NO Xine: NO gPhoto2: YES

Parallel framework: TBB (ver 2018.0 interface 10006)

Other third-party libraries: Use IPP: NO Use VA: NO Use Intel VA-API/OpenCL: NO Use Lapack: NO Use Eigen: YES (ver 3.3.7) Use Cuda: NO Use OpenCL: YES Use OpenVX: NO Use custom HAL: NO

OpenCL: Include path: /usr/include/CL Use AMDFFT: NO Use AMDBLAS: NO

Python 2: Interpreter: /usr/bin/python2.7 (ver 2.7.15) Libraries: /usr/lib/aarch64-linux-gnu/libpython2.7.so (ver 2.7.15+) numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.16.1) packages path: lib/python2.7/dist-packages

Python 3: Interpreter: /usr/bin/python3 (ver 3.7.2) Libraries: /usr/lib/aarch64-linux-gnu/libpython3.7m.so (ver 3.7.2+) numpy: /usr/lib/python3/dist-packages/numpy/core/include (ver 1.16.1) packages path: lib/python3.7/dist-packages

Python (for build): /usr/bin/python2.7

Java: ant: /usr/bin/ant (ver 1.10.5) JNI: /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include/linux /usr/lib/jvm/default-java/include Java wrappers: YES Java tests: NO

Matlab: Matlab not found or implicitly disabled

Documentation: Doxygen: /usr/bin/doxygen (ver 1.8.13)

Tests and samples: Tests: NO Performance tests: YES C/C++ Examples: YES

Install path: /usr

cvconfig.h is in: /build/opencv-tragD2/opencv-3.2.0+dfsg/obj-aarch64-linux-gnu

2022-03-05 08:32:47,070 - apscheduler.scheduler - INFO - Scheduler started 2022-03-05 08:32:47,072 - apscheduler.scheduler - DEBUG - Looking for jobs to run 2022-03-05 08:32:47,073 - apscheduler.scheduler - DEBUG - No jobs; waiting until a job is added 2022-03-05 08:32:47,277 - apscheduler.scheduler - INFO - Scheduler started 2022-03-05 08:32:47,279 - apscheduler.scheduler - DEBUG - Looking for jobs to run 2022-03-05 08:32:47,281 - apscheduler.scheduler - DEBUG - No jobs; waiting until a job is added 2022-03-05 08:32:47,525 - main - ERROR - Uncaught exception Traceback (most recent call last): File "/home/pi/moonraker-telegram-bot/bot/main.py", line 919, in greeting_message() File "/home/pi/moonraker-telegram-bot/bot/main.py", line 512, in greeting_message bot_updater.bot.set_my_commands(commands=commands) File "/home/pi/moonraker-telegram-bot-env/lib/python3.7/site-packages/telegram/bot.py", line 130, in decorator result = func(*args, kwargs) File "/home/pi/moonraker-telegram-bot-env/lib/python3.7/site-packages/telegram/bot.py", line 5488, in set_my_commands result = self._post('setMyCommands', data, timeout=timeout, api_kwargs=api_kwargs) File "/home/pi/moonraker-telegram-bot-env/lib/python3.7/site-packages/telegram/bot.py", line 296, in _post f'{self.base_url}/{endpoint}', data=data, timeout=effective_timeout File "/home/pi/moonraker-telegram-bot-env/lib/python3.7/site-packages/telegram/utils/request.py", line 366, in post urlopen_kwargs, File "/home/pi/moonraker-telegram-bot-env/lib/python3.7/site-packages/telegram/utils/request.py", line 279, in _request_wrapper raise BadRequest(message) telegram.error.BadRequest: Command length must not exceed 32 Stack (most recent call last): File "/home/pi/moonraker-telegram-bot/bot/main.py", line 55, in handle_exception logger.error("Uncaught exception", exc_info=(exc_type, exc_value, exc_traceback), stack_info=True)

If needed, paste the relevant bot journal contents here.

Mar 04 20:09:31 BedSlinger python[609]: logger.error("Uncaught exception", exc_info=(exc_type, exc_value, exc_traceback), stack_info=True) Mar 04 20:09:31 BedSlinger python[609]: File "/home/pi/moonraker-telegram-bot/bot/main.py", line 55, in handle_exception Mar 04 20:09:31 BedSlinger python[609]: Stack (most recent call last): Mar 04 20:09:31 BedSlinger python[609]: telegram.error.BadRequest: Command length must not exceed 32 Mar 04 20:09:31 BedSlinger python[609]: raise BadRequest(message) Mar 04 20:09:31 BedSlinger python[609]: File "/home/pi/moonraker-telegram-bot-env/lib/python3.7/site-packages/telegram/utils/request.py", line 279, in _request_wrapper Mar 04 20:09:31 BedSlinger python[609]: *urlopen_kwargs, Mar 04 20:09:31 BedSlinger python[609]: File "/home/pi/moonraker-telegram-bot-env/lib/python3.7/site-packages/telegram/utils/request.py", line 366, in post Mar 04 20:09:31 BedSlinger python[609]: f'{self.base_url}/{endpoint}', data=data, timeout=effective_timeout Mar 04 20:09:31 BedSlinger python[609]: File "/home/pi/moonraker-telegram-bot-env/lib/python3.7/site-packages/telegram/bot.py", line 296, in _post Mar 04 20:09:31 BedSlinger python[609]: result = self._post('setMyCommands', data, timeout=timeout, api_kwargs=api_kwargs) Mar 04 20:09:31 BedSlinger python[609]: File "/home/pi/moonraker-telegram-bot-env/lib/python3.7/site-packages/telegram/bot.py", line 5488, in set_my_commands Mar 04 20:09:31 BedSlinger python[609]: result = func(args, **kwargs) Mar 04 20:09:31 BedSlinger python[609]: File "/home/pi/moonraker-telegram-bot-env/lib/python3.7/site-packages/telegram/bot.py", line 130, in decorator Mar 04 20:09:31 BedSlinger python[609]: bot_updater.bot.set_my_commands(commands=commands) Mar 04 20:09:31 BedSlinger python[609]: File "/home/pi/moonraker-telegram-bot/bot/main.py", line 512, in greeting_message Mar 04 20:09:31 BedSlinger python[609]: greeting_message() Mar 04 20:09:31 BedSlinger python[609]: File "/home/pi/moonraker-telegram-bot/bot/main.py", line 919, in Mar 04 20:09:31 BedSlinger python[609]: Traceback (most recent call last): Mar 04 20:09:31 BedSlinger python[609]: 2022-03-04 20:09:31,201 - main - ERROR - Uncaught exception Mar 04 20:09:30 BedSlinger python[609]: 2022-03-04 20:09:30,835 - apscheduler.scheduler - INFO - Scheduler started Mar 04 20:09:30 BedSlinger python[609]: 2022-03-04 20:09:30,635 - apscheduler.scheduler - INFO - Scheduler started Mar 04 20:09:20 BedSlinger systemd[1]: Started Starts Moonraker Telegram Bot on startup.

What branch does this occur on?

master

Reports only on latest master or development branches!

radaiko commented 2 years ago

This is what it looks before it broke: CleanShot 2022-03-04 at 21 10 11

This is after: CleanShot 2022-03-04 at 21 10 39

The second pictures was forced with /status. The first one was automatically updated.

radaiko commented 2 years ago

@nlef: found the problem. Only 32 commands are allowed but I got to many custom macros (because of custom MMU).

So to fix this problem I had to add "include_macros_in_command_list: false" to my config. In the bot/main.py the limit is set to 100, so maybe this should be changed to 32.

nlef commented 2 years ago

@nlef: found the problem. Only 32 commands are allowed but I got to many custom macros (because of custom MMU).

So to fix this problem I had to add "include_macros_in_command_list: false" to my config. In the bot/main.py the limit is set to 100, so maybe this should be changed to 32. @radaiko could you provide a link to the documentation where the limit is 32 commands? I found a limit of 100 commands. please provide a list of macro names, perhaps they contain symbols that lead to errors

radaiko commented 2 years ago

@nlef: found the problem. Only 32 commands are allowed but I got to many custom macros (because of custom MMU).

So to fix this problem I had to add "include_macros_in_command_list: false" to my config. In the bot/main.py the limit is set to 100, so maybe this should be changed to 32. @radaiko could you provide a link to the documentation where the limit is 32 commands? I found a limit of 100 commands. please provide a list of macro names, perhaps they contain symbols that lead to errors

@nlef : I read it wrong. It's not 32 commands in the length of the command. So only 32 char per name. I got a macro which was called "ERCF_UNLOAD_FILAMENT_IN_EXTRUDER_WITH_TIP_FORMING" after cutting it to 32 characters it was working. The reason why it worked sometimes was I was starting the telegram bot without that macro in the cfg and added it later to the printer.cfg. When only restarting the firmware without a telegram bot it was working.

Maybe a check for the length of a macro would be good.

nlef commented 2 years ago

@radaiko please try the new version.

radaiko commented 2 years ago

@nlef tested with 1.4.2 still the same problem

2022-03-09 20:21:14,976 - __main__ - ERROR - Uncaught exception Traceback (most recent call last): File "/home/pi/moonraker-telegram-bot/bot/main.py", line 1349, in <module> greeting_message() File "/home/pi/moonraker-telegram-bot/bot/main.py", line 906, in greeting_message bot_updater.bot.set_my_commands(commands=commands) File "/home/pi/moonraker-telegram-bot-env/lib/python3.7/site-packages/telegram/bot.py", line 130, in decorator result = func(*args, **kwargs) File "/home/pi/moonraker-telegram-bot-env/lib/python3.7/site-packages/telegram/bot.py", line 5488, in set_my_commands result = self._post('setMyCommands', data, timeout=timeout, api_kwargs=api_kwargs) File "/home/pi/moonraker-telegram-bot-env/lib/python3.7/site-packages/telegram/bot.py", line 296, in _post f'{self.base_url}/{endpoint}', data=data, timeout=effective_timeout File "/home/pi/moonraker-telegram-bot-env/lib/python3.7/site-packages/telegram/utils/request.py", line 366, in post **urlopen_kwargs, File "/home/pi/moonraker-telegram-bot-env/lib/python3.7/site-packages/telegram/utils/request.py", line 279, in _request_wrapper raise BadRequest(message) telegram.error.BadRequest: Command length must not exceed 32 Stack (most recent call last): File "/home/pi/moonraker-telegram-bot/bot/main.py", line 54, in handle_exception stack_info=True,

nlef commented 2 years ago

@radaiko it's my fault, didn't test well. checked and pushed a small update

nlef commented 2 years ago

@radaiko is the error still present?

radaiko commented 2 years ago

@nlef

Sorry for the late response. Was a little busy with printing V2.4 parts.

With 1.4.2-1 this is fixed.