Prusa MINI Firmware overview
|
#include "marlin_client.h"
#include <stdarg.h>
#include <string.h>
#include "dbg.h"
#include "app.h"
#include "bsod.h"
#include "cmsis_os.h"
#include "stm32f4xx_hal.h"
◆ DBG
◆ DBG_REQ
◆ DBG_EVT
◆ DBG_EVT_MSK
◆ DBG_VAR
◆ marlin_client_t
◆ _wait_server_started()
◆ _send_request_to_server()
572 int len = strlen(request);
583 for (
i = 0;
i < len;
i++)
585 if ((
i > 0) && (request[
i - 1] !=
'\n'))
596 DBG_REQ(
"CL%c: REQ %s",
'0' + client_id, request);
◆ _wait_ack_from_server()
uint32_t _wait_ack_from_server |
( |
uint8_t |
client_id | ) |
|
◆ _process_client_message()
618 client->
changes |= ((uint64_t)1 <<
id);
621 if (DBG_VAR_MSK & ((uint64_t)1 <<
id))
626 client->
events |= ((uint64_t)1 <<
id);
687 (msg.
ui32 >> 16) & 0xff, msg.
ui32 & 0xffff);
◆ _client_ptr()
◆ marlin_client_init()
97 client->
id = client_id;
111 return (client) ? &(client->
vars) : 0;
◆ marlin_client_shdn()
◆ marlin_client_loop()
135 *(((uint32_t *)(&msg)) + 1) = ose.
value.
v;
139 *(((uint32_t *)(&msg)) + 0) = ose.
value.
v;
◆ marlin_processing()
int marlin_processing |
( |
void |
| ) |
|
◆ marlin_busy()
◆ marlin_command()
uint32_t marlin_command |
( |
void |
| ) |
|
◆ marlin_stop_processing()
◆ marlin_start_processing()
◆ marlin_motion()
int marlin_motion |
( |
void |
| ) |
|
184 return (vars->
motion) ? 1 : 0;
◆ marlin_wait_motion()
int marlin_wait_motion |
( |
uint32_t |
timeout | ) |
|
192 return (vars->
motion) ? 1 : 0;
◆ marlin_gcode()
200 strcpy(request,
"!g ");
201 strcat(request,
gcode);
◆ marlin_gcode_printf()
int marlin_gcode_printf |
( |
const char * |
format, |
|
|
|
... |
|
) |
| |
212 strcpy(request,
"!g ");
214 va_start(ap, format);
215 ret = vsprintf(request + 3, format, ap);
◆ marlin_gcode_push_front()
void marlin_gcode_push_front |
( |
const char * |
gcode | ) |
|
◆ marlin_event()
235 uint64_t msk = (uint64_t)1 << evt_id;
237 ret = (client->
events & msk) ? 1 : 0;
◆ marlin_event_set()
int marlin_event_set |
( |
uint8_t |
evt_id | ) |
|
244 uint64_t msk = (uint64_t)1 << evt_id;
246 ret = (client->
events & msk) ? 1 : 0;
◆ marlin_event_clr()
int marlin_event_clr |
( |
uint8_t |
evt_id | ) |
|
255 uint64_t msk = (uint64_t)1 << evt_id;
257 ret = (client->
events & msk) ? 1 : 0;
◆ marlin_events()
uint64_t marlin_events |
( |
void |
| ) |
|
265 return (client) ? client->
events : 0;
◆ marlin_change()
int marlin_change |
( |
uint8_t |
var_id | ) |
|
271 uint64_t msk = (uint64_t)1 << var_id;
273 ret = (client->
changes & msk) ? 1 : 0;
◆ marlin_change_set()
int marlin_change_set |
( |
uint8_t |
var_id | ) |
|
280 uint64_t msk = (uint64_t)1 << var_id;
282 ret = (client->
changes & msk) ? 1 : 0;
◆ marlin_change_clr()
int marlin_change_clr |
( |
uint8_t |
var_id | ) |
|
291 uint64_t msk = (uint64_t)1 << var_id;
293 ret = (client->
changes & msk) ? 1 : 0;
◆ marlin_changes()
uint64_t marlin_changes |
( |
void |
| ) |
|
301 return (client) ? client->
changes : 0;
◆ marlin_error()
307 uint64_t msk = (uint64_t)1 << err_id;
309 ret = (client->
errors & msk) ? 1 : 0;
◆ marlin_error_set()
int marlin_error_set |
( |
uint8_t |
err_id | ) |
|
316 uint64_t msk = (uint64_t)1 << err_id;
318 ret = (client->
errors & msk) ? 1 : 0;
◆ marlin_error_clr()
int marlin_error_clr |
( |
uint8_t |
err_id | ) |
|
327 uint64_t msk = (uint64_t)1 << err_id;
329 ret = (client->
errors & msk) ? 1 : 0;
◆ marlin_errors()
uint64_t marlin_errors |
( |
void |
| ) |
|
337 return (client) ? client->
errors : 0;
◆ marlin_get_var()
◆ marlin_set_var()
◆ marlin_vars()
364 return &(client->
vars);
◆ marlin_update_vars()
375 sprintf(request,
"!update %" PRIu64, msk);
378 return &(client->
vars);
◆ marlin_get_gqueue()
◆ marlin_get_gqueue_max()
◆ marlin_get_pqueue()
◆ marlin_get_pqueue_max()
◆ marlin_set_target_nozzle()
float marlin_set_target_nozzle |
( |
float |
val | ) |
|
◆ marlin_set_target_bed()
float marlin_set_target_bed |
( |
float |
val | ) |
|
◆ marlin_set_z_offset()
float marlin_set_z_offset |
( |
float |
val | ) |
|
◆ marlin_set_fan_speed()
◆ marlin_set_print_speed()
uint16_t marlin_set_print_speed |
( |
uint16_t |
val | ) |
|
◆ marlin_set_flow_factor()
uint16_t marlin_set_flow_factor |
( |
uint16_t |
val | ) |
|
◆ marlin_set_wait_heat()
◆ marlin_set_wait_user()
◆ marlin_do_babysteps_Z()
void marlin_do_babysteps_Z |
( |
float |
offs | ) |
|
438 sprintf(request,
"!babystep_Z %.4f", (
double)offs);
◆ marlin_settings_save()
◆ marlin_settings_load()
◆ marlin_manage_heater()
◆ marlin_quick_stop()
◆ marlin_print_abort()
◆ marlin_print_pause()
◆ marlin_print_resume()
◆ marlin_park_head()
◆ marlin_message_received()
◆ marlin_host_prompt_type()
◆ marlin_host_button_count()
◆ marlin_host_button_type()
537 if (client && (index < client->prompt.button_count))
◆ marlin_host_button_click()
547 sprintf(request,
"!hclick %d", (
int)button);
◆ marlin_reheating()
int marlin_reheating |
( |
void |
| ) |
|
◆ marlin_client_task
◆ marlin_client_queue
◆ marlin_client
◆ marlin_clients
◆ marlin_server_task
◆ marlin_server_queue
◆ marlin_server_sema
#define MARLIN_MAX_CLIENTS
Definition: config.h:96
uint16_t flags
Definition: marlin_client.c:41
#define MARLIN_ERR_MSK(e_id)
Definition: marlin_errors.h:13
uint32_t osMessageAvailableSpace(osMessageQId queue_id)
Get the available space in a message queue.
Definition: cmsis_os.c:1658
variant8_t variant8_ui8(uint8_t ui8)
Definition: variant8.c:18
const char * marlin_vars_get_name(uint8_t var_id)
Definition: marlin_vars.c:36
uint32_t _wait_ack_from_server(uint8_t client_id)
Definition: marlin_client.c:601
TaskHandle_t osThreadId
Definition: cmsis_os.h:283
#define DBG_VAR(...)
Definition: marlin_client.c:23
int32_t osSemaphoreWait(osSemaphoreId semaphore_id, uint32_t millisec)
Wait until a Semaphore token becomes available.
Definition: cmsis_os.c:822
GCodeQueue queue
Definition: queue.cpp:28
variant8_t marlin_vars_get_var(marlin_vars_t *vars, uint8_t var_id)
Definition: marlin_vars.c:50
list gcode
Definition: g29_auto.py:44
uint16_t ui16
Definition: variant8.h:34
#define MARLIN_VAR_FLOWFACT
Definition: marlin_vars.h:26
#define MARLIN_VAR_MOTION
Definition: marlin_vars.h:8
host_prompt_button_t button[HOST_PROMPT_MAX_BUTTONS]
Definition: marlin_host.h:49
osThreadId marlin_server_task
Definition: marlin_server.cpp:88
uint8_t ui8
Definition: variant8.h:36
#define MARLIN_VAR_FANSPEED
Definition: marlin_vars.h:24
variant8_t marlin_get_var(uint8_t var_id)
Definition: marlin_client.c:340
void marlin_vars_value_to_str(marlin_vars_t *vars, uint8_t var_id, char *str)
Definition: marlin_vars.c:183
#define VARIANT8_USER
Definition: variant8.h:16
uint8_t i
Definition: screen_test_graph.c:72
uint8_t type
Definition: variant8.h:25
#define MARLIN_VAR_TTEM_BED
Definition: marlin_vars.h:22
uint8_t reheating
Definition: marlin_client.c:51
host_prompt_type_t type
Definition: marlin_host.h:47
#define DBG_EVT
Definition: marlin_client.c:18
const char * marlin_events_get_name(uint8_t evt_id)
Definition: marlin_events.c:40
uint32_t command
Definition: marlin_client.c:49
uint8_t xc
Definition: marlin_events.h:104
void marlin_client_loop(void)
Definition: marlin_client.c:118
osThreadId osThreadGetId(void)
Return the thread ID of the current running thread.
Definition: cmsis_os.c:283
uint16_t usr16
Definition: variant8.h:27
#define NULL
Definition: usbd_def.h:53
marlin_client_t marlin_client[MARLIN_MAX_CLIENTS]
Definition: marlin_client.c:62
QueueHandle_t osMessageQId
Definition: cmsis_os.h:303
#define MARLIN_USR8_VAR_FLG
Definition: marlin_vars.h:59
#define MARLIN_CFLG_LOWHIGH
Definition: marlin_client.h:14
osEvent osMessageGet(osMessageQId queue_id, uint32_t millisec)
Get a Message or Wait for a Message from a Queue.
Definition: cmsis_os.c:1145
osStatus osDelay(uint32_t millisec)
Wait for Timeout (Time Delay)
Definition: cmsis_os.c:365
Definition: marlin_host.h:18
osMessageQId marlin_server_queue
Definition: marlin_server.cpp:89
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
Definition: stm32f4xx_hal.c:339
variant8_t variant8_ui16(uint16_t ui16)
Definition: variant8.c:30
#define MARLIN_VAR_WAITUSER
Definition: marlin_vars.h:28
#define MARLIN_EVT_Reheat
Definition: marlin_events.h:37
#define MARLIN_USR8_MSK_ID
Definition: marlin_vars.h:60
Definition: cmsis_os.h:395
Definition: variant8.h:24
#define DBG_REQ(...)
Definition: marlin_client.c:16
void marlin_host_prompt_decode(uint32_t ui32, marlin_host_prompt_t *prompt)
Definition: marlin_host.c:56
Definition: marlin_host.h:26
float flt
Definition: variant8.h:31
variant8_t marlin_set_var(uint8_t var_id, variant8_t val)
Definition: marlin_client.c:345
#define MARLIN_EVT_CommandEnd
Definition: marlin_events.h:34
uint8_t button_count
Definition: marlin_host.h:48
#define MARLIN_MAX_REQUEST
Definition: config.h:97
Definition: marlin_client.c:39
#define MARLIN_VAR_PQUEUE
Definition: marlin_vars.h:10
void _process_client_message(marlin_client_t *client, variant8_t msg)
Definition: marlin_client.c:612
#define MARLIN_EVT_StopProcessing
Definition: marlin_events.h:29
#define MARLIN_EVT_CommandBegin
Definition: marlin_events.h:33
osThreadId marlin_client_task[MARLIN_MAX_CLIENTS]
Definition: marlin_client.c:59
#define MARLIN_VAR_GQUEUE
Definition: marlin_vars.h:9
osStatus osMessagePut(osMessageQId queue_id, uint32_t info, uint32_t millisec)
Put a Message to a Queue.
Definition: cmsis_os.c:1113
function completed; message event occurred.
Definition: cmsis_os.h:237
#define MARLIN_EVT_Message
Definition: marlin_events.h:36
#define MARLIN_VAR_WAITHEAT
Definition: marlin_vars.h:27
void marlin_vars_set_var(marlin_vars_t *vars, uint8_t var_id, variant8_t var)
Definition: marlin_vars.c:105
#define MARLIN_CFLG_STARTED
Definition: marlin_client.h:11
marlin_client_t * _client_ptr(void)
Definition: marlin_client.c:703
uint64_t events
Definition: marlin_client.c:42
#define osWaitForever
wait forever timeout value
Definition: cmsis_os.h:230
#define MARLIN_CFLG_BUSY
Definition: marlin_client.h:13
uint64_t errors
Definition: marlin_client.c:47
marlin_vars_t * marlin_update_vars(uint64_t msk)
Definition: marlin_client.c:368
#define MARLIN_EVT_MeshUpdate
Definition: marlin_events.h:24
variant8_t variant8_empty(void)
Definition: variant8.c:10
const uint8_t[]
Definition: 404_html.c:3
float z[MARLIN_MAX_MESH_POINTS]
Definition: marlin_events.h:103
#define MARLIN_VAR_MSK(v_id)
Definition: marlin_vars.h:35
marlin_host_prompt_t prompt
Definition: marlin_client.c:50
#define MARLIN_VAR_PRNSPEED
Definition: marlin_vars.h:25
#define MARLIN_EVT_HostPrompt
Definition: marlin_events.h:26
void _send_request_to_server(uint8_t client_id, const char *request)
Definition: marlin_client.c:570
uint32_t ack
Definition: marlin_client.c:45
uint64_t changes
Definition: marlin_client.c:43
uint8_t yc
Definition: marlin_events.h:105
osSemaphoreId marlin_server_sema
Definition: marlin_server.cpp:90
uint8_t id
Definition: marlin_client.c:40
static status_t status
Definition: filament_sensor.c:37
marlin_vars_t vars
Definition: marlin_client.c:44
#define MARLIN_EVT_Ready
Definition: marlin_events.h:31
uint8_t marlin_clients
Definition: marlin_client.c:63
Definition: marlin_vars.h:77
#define MARLIN_EVT_StartProcessing
Definition: marlin_events.h:28
void _wait_server_started(void)
Definition: marlin_client.c:564
osMessageQId osMessageCreate(const osMessageQDef_t *queue_def, osThreadId thread_id)
Create and Initialize a Message Queue.
Definition: cmsis_os.c:1086
#define osMessageQ(name)
Access a Message Queue Definition.
Definition: cmsis_os.h:829
uint8_t usr8
Definition: variant8.h:26
#define MARLIN_CMD_NONE
Definition: marlin_events.h:50
#define MARLIN_CFLG_MESSAGE
Definition: marlin_client.h:15
#define MARLIN_EVT_Error
Definition: marlin_events.h:32
#define MARLIN_EVT_MSK(e_id)
Definition: marlin_events.h:42
#define DBG_EVT_MSK
Definition: marlin_client.c:20
#define MARLIN_VAR_TTEM_NOZ
Definition: marlin_vars.h:21
union osEvent::@54 value
event value
uint32_t ui32
Definition: variant8.h:32
#define MARLIN_EVT_Busy
Definition: marlin_events.h:30
#define MARLIN_EVT_Acknowledge
Definition: marlin_events.h:38
variant8_t variant8_flt(float flt)
Definition: variant8.c:48
#define MARLIN_CFLG_PROCESS
Definition: marlin_client.h:12
uint16_t last_count
Definition: marlin_client.c:46
uint32_t v
message as 32-bit value
Definition: cmsis_os.h:398
marlin_mesh_t mesh
Definition: marlin_client.c:48
osMessageQId marlin_client_queue[MARLIN_MAX_CLIENTS]
Definition: marlin_client.c:60
#define MARLIN_VAR_Z_OFFSET
Definition: marlin_vars.h:23
uint8_t motion
Definition: marlin_vars.h:78
osStatus osSemaphoreRelease(osSemaphoreId semaphore_id)
Release a Semaphore token.
Definition: cmsis_os.c:862
#define osMessageQDef(name, queue_sz, type)
Create a Message Queue Definition.
Definition: cmsis_os.h:818