Sending commands from CB1 terminal to printer

I am using CB1 , manta M8P. I am right now using mainsail web interface to move printers. But I need to give commands in CB1 linux terminal or some python code that can give commands to klipper directly without moonraker or mainsail. I try typing gcodes in CB1 terminal directly and also after activating klippy env.

LIKE THIS:

(klippy-env) biqu@BTT-CB1:~$ G28
G28: command not found

CAN SOMEONE PLEASE TELL HOW TO SEND COMMANDS DIRECTLY FROM TERMINAL?

THANKS IN ADVANCE.

You can use the /tmp/printer pseudo tty, e.g.

echo G28 > /tmp/printer

I tried the same.

biqu@BTT-CB1:~$ echo G28 > /tmp/printer
biqu@BTT-CB1:~$ echo G28
G28

But it unfortunatley it did not home the printer. While using Mainsail its actually working but not through terminal.

Depending on your settings and way of installation, the pseudo tty could also be located at ~/printer_data/comms/klippy.serial

It worked with this command.

(klippy-env) biqu@BTT-CB1:~$ echo G28 > ~/printer_data/comms/klippy.serial

Thank you so much.

Hi! This is a follow-up question to the topic (Im working together with the OP):
As we now can control it from within the terminal (Woob Woob:-) !) , the next step would be to control it via USB and later via Ethernet. So far, we are sending said commands (‘echo “G28 Y” > ~/printer_data/comms/klippy.serial’) via serial connection from the client through USB Serial (thus → this kind of works already). However, this seems to me kind of creative, rather than efficient.
What is the recommended way to prepare custom G Code commands on a client and then send it to klipper via USB Serial or Ethernet? We want to prepare short GCODE commands on the client side (in Python), to use the printer as traversing system. Basically, a python script is running on the client handling the “main task” and tells the Printer to move from time to time.

I’m assuming to use Moonraker is the right choice, but i’m not sure.

Cheers!
PiMaV

Yes, Moonraker is the right interface process for such. See Remote API - Moonraker for the documentation.
Also see Announcing klipper-repl: the missing Klipper command line → you might find it useful

THX Mate!
Thus we will dig into moonraker and the repl sounds very much like the weapon of choice for our further approaches.

Thx again :+1:

Thanks, Sineos. Yours answer works for me. Now I can do homing (and other coomands) on my BTT Manta M8P + CB1 + klipper with:

biqu@BTT-CB1:~$ echo G28 Y > ~/printer_data/comms/klippy.serial

But I have another question: How can I collect the returned value from GCode command like ‘M114’, which provides the head positions? (P.S.I can tell the M114 is successfully excuted from the screen attached to the printer. There are XYZ readings under the console.)

biqu@BTT-CB1:~$ echo M114 > ~/printer_data/comms/klippy.serial

biqu@BTT-CB1:~$ echo GET_POSITION > ~/printer_data/comms/klippy.serial

Usually only possible when you use some daemon to listen on this endpoint and AFAIK there is no Linux shell command that would allow this directly.

You could work with some socat magic to listen on the PTY, but I have never tried.

Hi Sineos, thanks you very much. I will reopen a new thread to explain my project with more details and list some bypass methods.