Prusa MINI Firmware overview
marlin_server.h File Reference
#include "marlin_events.h"
#include "marlin_vars.h"
#include "marlin_errors.h"
#include "marlin_host.h"

Go to the source code of this file.

Classes

struct  msg_stack
 

Macros

#define MARLIN_SFLG_STARTED   0x0001
 
#define MARLIN_SFLG_PROCESS   0x0002
 
#define MARLIN_SFLG_BUSY   0x0004
 
#define MARLIN_SFLG_PENDREQ   0x0008
 
#define MARLIN_UPDATE_PERIOD   100
 
#define MSG_STACK_SIZE   8
 
#define MSG_MAX_LENGTH   21
 

Typedefs

typedef void() marlin_server_idle_t(void)
 
typedef struct msg_stack msg_stack_t
 

Functions

void marlin_server_init (void)
 
int marlin_server_loop (void)
 
int marlin_server_processing (void)
 
void marlin_server_start_processing (void)
 
void marlin_server_stop_processing (void)
 
void marlin_server_update (uint64_t update)
 
void marlin_server_do_babystep_Z (float offs)
 
int marlin_server_enqueue_gcode (const char *gcode)
 
int marlin_server_inject_gcode (const char *gcode)
 
void marlin_server_settings_save (void)
 
void marlin_server_settings_load (void)
 
void marlin_server_manage_heater (void)
 
void marlin_server_quick_stop (void)
 
void marlin_server_print_abort (void)
 
void marlin_server_print_pause (void)
 
void marlin_server_print_resume (void)
 
void marlin_server_park_head (void)
 
int marlin_all_axes_homed (void)
 
int marlin_all_axes_known (void)
 

Variables

msg_stack_t msg_stack
 
marlin_server_idle_tmarlin_server_idle_cb
 

Macro Definition Documentation

◆ MARLIN_SFLG_STARTED

#define MARLIN_SFLG_STARTED   0x0001

◆ MARLIN_SFLG_PROCESS

#define MARLIN_SFLG_PROCESS   0x0002

◆ MARLIN_SFLG_BUSY

#define MARLIN_SFLG_BUSY   0x0004

◆ MARLIN_SFLG_PENDREQ

#define MARLIN_SFLG_PENDREQ   0x0008

◆ MARLIN_UPDATE_PERIOD

#define MARLIN_UPDATE_PERIOD   100

◆ MSG_STACK_SIZE

#define MSG_STACK_SIZE   8

◆ MSG_MAX_LENGTH

#define MSG_MAX_LENGTH   21

Typedef Documentation

◆ marlin_server_idle_t

typedef void() marlin_server_idle_t(void)

◆ msg_stack_t

typedef struct msg_stack msg_stack_t

Function Documentation

◆ marlin_server_init()

void marlin_server_init ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ marlin_server_loop()

int marlin_server_loop ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ marlin_server_processing()

int marlin_server_processing ( void  )
284  {
285  return (marlin_server.flags & MARLIN_SFLG_PROCESS) ? 1 : 0;
286 }
Here is the caller graph for this function:

◆ marlin_server_start_processing()

void marlin_server_start_processing ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ marlin_server_stop_processing()

void marlin_server_stop_processing ( void  )
293  {
295  //TODO: disable heaters and safe state
297 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ marlin_server_update()

void marlin_server_update ( uint64_t  update)
303  {
304  int client_id;
306  _server_update_vars(update);
307  for (client_id = 0; client_id < MARLIN_MAX_CLIENTS; client_id++)
308  if ((queue = marlin_client_queue[client_id]) != 0)
309  marlin_server.client_changes[client_id] &= ~_send_notify_changes_to_client(client_id, queue, update);
310  // _dbg0("UPDATE");
311 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ marlin_server_do_babystep_Z()

void marlin_server_do_babystep_Z ( float  offs)
313  {
315  babystep.task();
316 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ marlin_server_enqueue_gcode()

int marlin_server_enqueue_gcode ( const char *  gcode)
318  {
319  return queue.enqueue_one(gcode) ? 1 : 0;
320 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ marlin_server_inject_gcode()

int marlin_server_inject_gcode ( const char *  gcode)
322  {
324  return 1;
325 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ marlin_server_settings_save()

void marlin_server_settings_save ( void  )
327  {
328  (void)settings.save();
329 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ marlin_server_settings_load()

void marlin_server_settings_load ( void  )
331  {
332  (void)settings.load();
333 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ marlin_server_manage_heater()

void marlin_server_manage_heater ( void  )
335  {
337 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ marlin_server_quick_stop()

void marlin_server_quick_stop ( void  )
339  {
341 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ marlin_server_print_abort()

void marlin_server_print_abort ( void  )
343  {
344  wait_for_heatup = wait_for_user = false;
345  card.flag.abort_sd_printing = true;
347  // planner.quick_stop();
348  // marlin_server_park_head();
349  // planner.synchronize();
350  // queue.inject_P("M125");
351 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ marlin_server_print_pause()

void marlin_server_print_pause ( void  )
353  {
354  card.pauseSDPrint();
356  queue.inject_P("M125");
357 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ marlin_server_print_resume()

void marlin_server_print_resume ( void  )
359  {
360  wait_for_user = false;
362  queue.inject_P("M24");
363 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ marlin_server_park_head()

void marlin_server_park_head ( void  )
365  {
366  //homed check
367  if (all_axes_homed() && all_axes_known()) {
368  xyz_pos_t park_point = NOZZLE_PARK_POINT;
369  nozzle.park(2, park_point);
370  }
371 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ marlin_all_axes_homed()

int marlin_all_axes_homed ( void  )
373  {
374  return all_axes_homed() ? 1 : 0;
375 }
Here is the call graph for this function:

◆ marlin_all_axes_known()

int marlin_all_axes_known ( void  )
377  {
378  return all_axes_known() ? 1 : 0;
379 }
Here is the call graph for this function:

Variable Documentation

◆ msg_stack

◆ marlin_server_idle_cb

marlin_server_idle_t* marlin_server_idle_cb
MARLIN_MAX_CLIENTS
#define MARLIN_MAX_CLIENTS
Definition: config.h:96
MARLIN_VAR_MSK_DEF
#define MARLIN_VAR_MSK_DEF
Definition: marlin_vars.h:52
_marlin_server_t::mesh
marlin_mesh_t mesh
Definition: marlin_server.cpp:71
_server_update_vars
uint64_t _server_update_vars(uint64_t force_update_msk)
Definition: marlin_server.cpp:537
_marlin_server_t::notify_changes
uint64_t notify_changes
Definition: marlin_server.cpp:57
host_prompt_button_clicked
host_prompt_button_t host_prompt_button_clicked
Definition: marlin_server.cpp:128
_send_notify_changes_to_client
uint64_t _send_notify_changes_to_client(int client_id, osMessageQId queue, uint64_t var_msk)
Definition: marlin_server.cpp:504
osSemaphore
#define osSemaphore(name)
Definition: cmsis_os.h:709
queue
GCodeQueue queue
Definition: queue.cpp:28
settings
MarlinSettings settings
Definition: configuration_store.cpp:344
g29_auto.gcode
list gcode
Definition: g29_auto.py:44
marlin_server_task
osThreadId marlin_server_task
Definition: marlin_server.cpp:88
print_job_timer
Stopwatch print_job_timer
Definition: printcounter.cpp:63
_marlin_server_t::flags
uint16_t flags
Definition: marlin_server.cpp:55
MARLIN_SFLG_BUSY
#define MARLIN_SFLG_BUSY
Definition: marlin_server.h:13
MARLIN_EVT_MSK_DEF
#define MARLIN_EVT_MSK_DEF
Definition: marlin_events.h:43
babystep
Babystep babystep
marlin_server_queue
osMessageQId marlin_server_queue
Definition: marlin_server.cpp:89
Temperature::manage_heater
static void manage_heater() _O2
Definition: temperature.cpp:975
Stopwatch::stop
static bool stop()
Stop the stopwatch.
Definition: stopwatch.cpp:36
_marlin_mesh_t::xc
uint8_t xc
Definition: marlin_events.h:104
osThreadGetId
osThreadId osThreadGetId(void)
Return the thread ID of the current running thread.
Definition: cmsis_os.c:283
NULL
#define NULL
Definition: usbd_def.h:53
MarlinSettings::save
static bool save()
Definition: configuration_store.cpp:2198
wait_for_user
bool wait_for_user
Definition: Marlin.cpp:188
_marlin_server_t::client_changes
uint64_t client_changes[MARLIN_MAX_CLIENTS]
Definition: marlin_server.cpp:62
osMessageQId
QueueHandle_t osMessageQId
Definition: cmsis_os.h:303
marlin_server
marlin_server_t marlin_server
Definition: marlin_server.cpp:92
all_axes_known
FORCE_INLINE bool all_axes_known()
Definition: motion.h:45
_marlin_server_t
Definition: marlin_server.cpp:54
_send_notify_event
void _send_notify_event(uint8_t evt_id, uint32_t usr32, uint16_t usr16)
Definition: marlin_server.cpp:481
osSemaphoreCreate
osSemaphoreId osSemaphoreCreate(const osSemaphoreDef_t *semaphore_def, int32_t count)
Create and Initialize a Semaphore object used for managing resources.
Definition: cmsis_os.c:755
marlin_server_sema
osSemaphoreId marlin_server_sema
Definition: marlin_server.cpp:90
osSemaphoreDef
#define osSemaphoreDef(name)
Definition: cmsis_os.h:700
_marlin_server_t::notify_events
uint64_t notify_events
Definition: marlin_server.cpp:56
marlin_client_queue
osMessageQId marlin_client_queue[MARLIN_MAX_CLIENTS]
Definition: marlin_client.c:60
MARLIN_EVT_CommandEnd
#define MARLIN_EVT_CommandEnd
Definition: marlin_events.h:34
MARLIN_EVT_StopProcessing
#define MARLIN_EVT_StopProcessing
Definition: marlin_events.h:29
planner_settings_t::axis_steps_per_mm
float axis_steps_per_mm[XYZE_N]
Definition: planner.h:181
void
void
Definition: png.h:1083
Stopwatch::pause
static bool pause()
Pause the stopwatch.
Definition: stopwatch.cpp:52
GCodeQueue::enqueue_one
static bool enqueue_one(const char *cmd)
Definition: queue.cpp:157
uint8_t
const uint8_t[]
Definition: 404_html.c:3
_marlin_server_t::idle_cnt
uint8_t idle_cnt
Definition: marlin_server.cpp:65
Babystep::task
static void task()
MARLIN_SFLG_STARTED
#define MARLIN_SFLG_STARTED
Definition: marlin_server.h:11
Planner::quick_stop
static void quick_stop()
Definition: planner.cpp:1475
_marlin_mesh_t::yc
uint8_t yc
Definition: marlin_events.h:105
Z_AXIS
Definition: types.h:39
MARLIN_EVT_Ready
#define MARLIN_EVT_Ready
Definition: marlin_events.h:31
MARLIN_EVT_StartProcessing
#define MARLIN_EVT_StartProcessing
Definition: marlin_events.h:28
osMessageCreate
osMessageQId osMessageCreate(const osMessageQDef_t *queue_def, osThreadId thread_id)
Create and Initialize a Message Queue.
Definition: cmsis_os.c:1086
osMessageQ
#define osMessageQ(name)
Access a Message Queue Definition.
Definition: cmsis_os.h:829
MarlinSettings::load
static FORCE_INLINE bool load()
Definition: configuration_store.h:79
MARLIN_CMD_NONE
#define MARLIN_CMD_NONE
Definition: marlin_events.h:50
marlin_server_cycle
int marlin_server_cycle(void)
Definition: marlin_server.cpp:168
XYZval< float >
GCodeQueue::inject_P
static void inject_P(PGM_P const pgcode)
Definition: queue.cpp:206
HOST_PROMPT_BTN_Continue
Definition: marlin_host.h:27
wait_for_heatup
bool wait_for_heatup
Definition: Marlin.cpp:184
MARLIN_IDLE_CNT_BUSY
#define MARLIN_IDLE_CNT_BUSY
Definition: marlin_server.cpp:237
Planner::settings
static planner_settings_t settings
Definition: planner.h:251
nozzle
Nozzle nozzle
Definition: nozzle.cpp:29
_marlin_server_t::command
uint32_t command
Definition: marlin_server.cpp:70
MARLIN_SFLG_PROCESS
#define MARLIN_SFLG_PROCESS
Definition: marlin_server.h:12
thermalManager
Temperature thermalManager
Definition: temperature.cpp:89
Babystep::add_steps
static void add_steps(const AxisEnum axis, const int16_t distance)
planner
Planner planner
Definition: planner.cpp:111
all_axes_homed
FORCE_INLINE bool all_axes_homed()
Definition: motion.h:44
osMessageQDef
#define osMessageQDef(name, queue_sz, type)
Create a Message Queue Definition.
Definition: cmsis_os.h:818