Prusa MINI Firmware overview
|
Go to the documentation of this file.
24 #include "../inc/MarlinConfig.h"
26 #define BINARY_STREAM_COMPRESSION
28 #if ENABLED(BINARY_STREAM_COMPRESSION)
29 #include "../libs/heatshrink/heatshrink_decoder.h"
36 case 1:
return MYSERIAL1.available();
46 case 1:
return MYSERIAL1.read();
52 #if ENABLED(BINARY_STREAM_COMPRESSION)
60 struct [[gnu::packed]]
Open {
66 return *reinterpret_cast<Open*>(buffer);
77 static bool file_open(
char* filename) {
78 if (!dummy_transfer) {
80 card.openFile(filename,
false);
81 if (!card.isFileOpen())
return false;
83 transfer_active =
true;
85 #if ENABLED(BINARY_STREAM_COMPRESSION)
91 static bool file_write(
char* buffer,
const size_t length) {
92 #if ENABLED(BINARY_STREAM_COMPRESSION)
94 size_t total_processed = 0, processed_count = 0;
97 while (total_processed <
length) {
99 total_processed += processed_count;
102 data_waiting += processed_count;
115 return (dummy_transfer || card.write(buffer,
length) >= 0);
118 static bool file_close() {
119 if (!dummy_transfer) {
120 #if ENABLED(BINARY_STREAM_COMPRESSION)
123 if (card.write(
decode_buffer, data_waiting) < 0)
return false;
130 #if ENABLED(BINARY_STREAM_COMPRESSION)
133 transfer_active =
false;
137 static void transfer_abort() {
138 if (!dummy_transfer) {
140 card.removeFile(card.filename);
142 #if ENABLED(BINARY_STREAM_COMPRESSION)
146 transfer_active =
false;
152 static size_t data_waiting, transfer_timeout, idle_timeout;
153 static bool transfer_active, dummy_transfer, compression;
160 if (transfer_active &&
ELAPSED(ms, idle_timeout)) {
162 if (
ELAPSED(ms, transfer_timeout)) transfer_abort();
168 switch (static_cast<FileTransfer>(packet_type)) {
169 case FileTransfer::QUERY:
171 #if ENABLED(BINARY_STREAM_COMPRESSION)
177 case FileTransfer::OPEN:
183 compression = packet.compression_enabled();
184 dummy_transfer = packet.dummy_transfer();
185 if (file_open(packet.filename())) {
193 case FileTransfer::CLOSE:
194 if (transfer_active) {
202 case FileTransfer::WRITE:
203 if (!transfer_active)
205 else if (!file_write(buffer,
length))
208 case FileTransfer::ABORT:
234 struct [[gnu::packed]] {
249 struct [[gnu::packed]] {
282 uint16_t cs_low = (((cs & 0xFF) + value) % 255);
283 return ((((cs >> 8) + cs_low) % 255) << 8) | cs_low;
300 template<const
size_t buffer_size>
305 #if ENABLED(SDSUPPORT)
309 #pragma GCC diagnostic push
310 #pragma GCC diagnostic ignored "-Warray-bounds"
346 SERIAL_ECHOLNPAIR(
"ss",
sync,
",", buffer_size,
",",
VERSION_MAJOR,
".",
VERSION_MINOR,
".",
VERSION_PATCH);
446 #pragma GCC diagnostic pop
454 card.flag.binary_mode =
false;
bool compression_enabled()
Definition: binary_protocol.h:68
#define WITHIN(N, L, H)
Definition: macros.h:195
#define PENDING(NOW, SOON)
Definition: millis_t.h:28
T z
Definition: types.h:286
#define GET_TEXT(MSG)
Definition: multi_language.h:72
void incremental_LSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z)
Definition: least_squares_fit.h:72
#define SERIAL_CHAR(x)
Definition: serial.h:69
float delta_segments_per_second
#define NOLESS(v, n)
Definition: macros.h:127
#define PORT_REDIRECT(p)
Definition: serial.h:66
#define X_CENTER
Definition: Conditionals_post.h:76
#define sq(x)
Definition: wiring_constants.h:83
Header header
Definition: binary_protocol.h:256
T z
Definition: types.h:383
static void synchronize()
Definition: planner.cpp:1556
#define _O2
Definition: macros.h:45
static float z_correction_for_y_on_vertical_mesh_line(const float &ry0, const int xi, const int y1_i)
Definition: ubl.h:206
#define SERIAL_ECHO(x)
Definition: serial.h:70
int bs_read_serial(const uint8_t index)
Definition: binary_protocol.h:42
static float mesh_index_to_ypos(const uint8_t i)
Definition: ubl.h:290
static void adjust_mesh_to_mean(const bool cflag, const float value)
T x
Definition: types.h:286
#define DEPLOY_PROBE()
Definition: probe.h:60
static matrix_3x3 create_look_at(const vector_3 &target)
Definition: vector_3.cpp:114
static const uint16_t IDLE_PERIOD
Definition: binary_protocol.h:218
void reset()
Definition: binary_protocol.h:274
constexpr xyz_pos_t probe_offset
Definition: probe.h:58
#define MYSERIAL0
Definition: HAL.h:89
static float z_correction_for_x_on_horizontal_mesh_line(const float &rx0, const int x1_i, const int yi)
Definition: ubl.h:177
#define PROGMEM
Definition: pgmspace.h:29
uint16_t header_checksum
Definition: binary_protocol.h:259
MarlinSettings settings
Definition: configuration_store.cpp:344
static void display_map(const int) _O0
#define RECIPROCAL(x)
Definition: macros.h:273
list gcode
Definition: g29_auto.py:44
static void report_state()
#define DEBUG_EOL()
Definition: debug_out.h:86
#define DEBUG_ECHOLNPGM(...)
Definition: debug_out.h:79
HSD_finish_res heatshrink_decoder_finish(heatshrink_decoder *hsd)
Definition: heatshrink_decoder.cpp:325
static bool buffer_segment(const float &a, const float &b, const float &c, const float &e, const feedRate_t &fr_mm_s, const uint8_t extruder, const float &millimeters=0.0)
Definition: planner.cpp:2568
#define _MAX(V...)
Definition: macros.h:346
void do_blocking_move_to_z(const float &rz, const feedRate_t &fr_mm_s)
Definition: motion.cpp:450
void incremental_LSF_reset(struct linear_fit_data *lsf)
Definition: least_squares_fit.h:47
static bool leveling_active
Definition: planner.h:276
static uint8_t decode_buffer[512]
Definition: binary_protocol.h:54
static bool access_finish()
#define SERIAL_ECHOPAIR(V...)
Definition: serial.h:114
uint8_t packet_retries
Definition: binary_protocol.h:474
void do_blocking_move_to_xy_z(const xy_pos_t &raw, const float &z, const feedRate_t &fr_mm_s)
Definition: motion.cpp:461
uint8_t type
Definition: UsbCore.h:184
void do_blocking_move_to_xy(const float &rx, const float &ry, const feedRate_t &fr_mm_s)
Definition: motion.cpp:454
start
Definition: g29_auto.py:150
#define DEBUG_ECHO_F(...)
Definition: debug_out.h:76
vector_3 get_normal() const
Definition: vector_3.cpp:61
uint8_t data[8]
Definition: masstorage.h:49
#define PGM_P
Definition: pgmspace.h:30
T e
Definition: types.h:383
static const uint16_t VERSION_MAJOR
Definition: binary_protocol.h:473
static bool access_start()
static const uint16_t PACKET_MAX_WAIT
Definition: binary_protocol.h:473
uint8_t sync
Definition: binary_protocol.h:474
#define HYPOT2(x, y)
Definition: macros.h:100
void print_hex_byte(const uint8_t b)
Definition: hex_print_routines.cpp:77
uint8_t i
Definition: screen_test_graph.c:72
#define SERIAL_ECHOLNPAIR_F(V...)
Definition: serial.h:177
static int8_t storage_slot
Definition: ubl.h:106
#define STRINGIFY(M)
Definition: macros.h:73
bool stream_read(uint8_t &data)
Definition: binary_protocol.h:289
xyze_pos_t destination
Definition: motion.cpp:110
static void line_to_destination_cartesian(const feedRate_t &scaled_fr_mm_s, const uint8_t e)
uint32_t millis(void)
Definition: wiring_time.c:29
static void restore_ubl_active_state_and_leave()
Definition: least_squares_fit.h:39
#define LIMIT(v, n1, n2)
Definition: macros.h:139
void reset()
Definition: binary_protocol.h:263
xy_float_t xy_pos_t
Definition: types.h:159
bool dummy_transfer()
Definition: binary_protocol.h:69
#define DEBUG_ECHOLNPAIR(...)
Definition: debug_out.h:82
static float mesh_index_to_xpos(const uint8_t i)
Definition: ubl.h:287
#define IS_KINEMATIC
Definition: Conditionals_LCD.h:545
static void idle()
Definition: binary_protocol.h:157
#define SERIAL_ECHO_START()
Definition: serial.h:179
static const uint16_t VERSION_MINOR
Definition: binary_protocol.h:473
Definition: heatshrink_decoder.h:19
float feedRate_t
Definition: types.h:80
#define KEEPALIVE_STATE(N)
Definition: gcode.h:365
#define pgm_read_ptr(addr)
Definition: pgmspace.h:113
static void process(uint8_t packet_type, char *buffer, const uint16_t length)
Definition: binary_protocol.h:166
static bool sanity_check()
#define DEBUG_ECHOPGM(...)
Definition: debug_out.h:78
#define POW(x, y)
Definition: macros.h:280
Definition: vector_3.h:73
T pos[2]
Definition: types.h:187
HSD_poll_res
Definition: heatshrink_decoder.h:17
#define NOMORE(v, n)
Definition: macros.h:133
end
Definition: createSpeedLookupTable.py:33
#define DEBUG_ECHOLNPAIR_F(...)
Definition: debug_out.h:83
#define DEBUG_DELAY(...)
Definition: debug_out.h:89
#define UBL_OK
Definition: ubl.h:32
HSD_poll_res heatshrink_decoder_poll(heatshrink_decoder *hsd, uint8_t *out_buf, size_t out_buf_size, size_t *output_size)
Definition: heatshrink_decoder.cpp:134
Definition: binary_protocol.h:221
#define ABS(a)
Definition: macros.h:266
BinaryStream binaryStream[NUM_SERIAL]
static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const xy_pos_t &, const bool=false, MeshFlags *done_flags=nullptr) _O0
#define Y_CENTER
Definition: Conditionals_post.h:77
uint16_t buffer_next_index
Definition: binary_protocol.h:475
#define pgm_read_byte(addr)
Definition: pgmspace.h:95
uint32_t checksum(uint32_t cs, uint8_t value)
Definition: binary_protocol.h:281
HSD_sink_res heatshrink_decoder_sink(heatshrink_decoder *hsd, uint8_t *in_buf, size_t size, size_t *input_size)
Definition: heatshrink_decoder.cpp:98
#define SERIAL_ECHO_MSG(S)
Definition: serial.h:183
#define PSTR(str)
Definition: pgmspace.h:31
void set_bed_leveling_enabled(const bool enable=true)
struct BinaryStream::Packet packet
xyze_pos_t current_position
Definition: motion.cpp:102
FI void set(const T px)
Definition: types.h:189
bool position_is_reachable(const float &rx, const float &ry)
Definition: motion.h:325
static FORCE_INLINE void apply_modifiers(xyze_pos_t &pos, bool leveling=false)
Definition: planner.h:499
Definition: heatshrink_decoder.h:46
#define LROUND(x)
Definition: macros.h:285
void receive(char(&buffer)[buffer_size])
Definition: binary_protocol.h:301
#define Z_CLEARANCE_BETWEEN_PROBES
Definition: Configuration_A3ides_2209_MINI.h:893
static FORCE_INLINE bool leveling_active_at_z(const float &)
Definition: planner.h:447
#define LOGICAL_Y_POSITION(POS)
Definition: motion.h:279
Protocol
Definition: binary_protocol.h:223
FI T magnitude() const
Definition: types.h:192
void apply_rotation_xyz(const matrix_3x3 &matrix, float &_x, float &_y, float &_z)
Definition: vector_3.cpp:88
#define Y_MIN_BED
Definition: Conditionals_post.h:83
#define COUNT(a)
Definition: macros.h:200
StreamState stream_state
Definition: binary_protocol.h:477
#define X_HOME_POS
Definition: Conditionals_post.h:156
void do_blocking_move_to(const float rx, const float ry, const float rz, const feedRate_t &fr_mm_s)
Definition: motion.cpp:344
StreamState
Definition: binary_protocol.h:227
#define isnan
Definition: Arduino.h:55
static const uint16_t VERSION_PATCH
Definition: binary_protocol.h:218
#define FLOOR(x)
Definition: macros.h:284
#define Y_HOME_POS
Definition: Conditionals_post.h:172
void onMeshUpdate(const uint8_t xpos, const uint8_t ypos, const float zval)
Definition: marlin_server.cpp:945
FORCE_INLINE bool position_is_reachable_by_probe(const xy_int_t &pos)
Definition: motion.h:358
#define X_BED_SIZE
Definition: Configuration_A3ides_2209_MINI.h:980
void
Definition: png.h:1083
float probe_min_x()
Definition: probe.h:103
static mesh_index_pair find_furthest_invalid_mesh_point() _O0
uint32_t bytes_received
Definition: binary_protocol.h:258
T x
Definition: types.h:383
static xy_int8_t cell_indexes(const float &x, const float &y)
Definition: ubl.h:137
#define constrain(amt, low, high)
Definition: wiring_constants.h:79
#define SERIAL_ECHO_F(V...)
Definition: serial.h:71
#define WRITE(IO, V)
Definition: fastio.h:96
#define SERIAL_ECHOPGM(S)
Definition: serial.h:173
Footer footer
Definition: binary_protocol.h:257
static bool buffer_line(const float &rx, const float &ry, const float &rz, const float &e, const feedRate_t &fr_mm_s, const uint8_t extruder, const float millimeters=0.0)
Definition: planner.cpp:2663
#define NUM_SERIAL
Definition: HAL.h:100
#define SERIAL_ECHOLNPAIR(V...)
Definition: serial.h:144
list a
Definition: createSpeedLookupTable.py:29
#define MESH_X_DIST
Definition: mesh_bed_leveling.h:35
void debug(PGM_P const title)
Definition: vector_3.cpp:139
float probe_max_x()
Definition: probe.h:104
#define HEATSHRINK_STATIC_LOOKAHEAD_BITS
Definition: heatshrink_config.h:19
static float get_z_correction(const float &rx0, const float &ry0)
Definition: ubl.h:238
#define SQRT(x)
Definition: macros.h:281
static const uint16_t TIMEOUT
Definition: binary_protocol.h:218
T x
Definition: types.h:185
FI XYval< float > asLogical() const
Definition: types.h:204
static const uint16_t VERSION_MINOR
Definition: binary_protocol.h:218
static char * filename()
Definition: binary_protocol.h:70
static const uint16_t VERSION_PATCH
Definition: binary_protocol.h:473
#define ELAPSED(NOW, SOON)
Definition: millis_t.h:29
#define MESH_Y_DIST
Definition: mesh_bed_leveling.h:36
float probe_min_y()
Definition: probe.h:105
const uint8_t[]
Definition: 404_html.c:3
void heatshrink_decoder_reset(heatshrink_decoder *hsd)
Definition: heatshrink_decoder.cpp:83
#define HYPOT(x, y)
Definition: macros.h:287
int finish_incremental_LSF(struct linear_fit_data *lsf)
Definition: least_squares_fit.cpp:43
Definition: binary_protocol.h:60
T y
Definition: types.h:286
static Open & decode(char *buffer)
Definition: binary_protocol.h:64
#define Y_MAX_BED
Definition: Conditionals_post.h:84
#define DEBUG_ECHOPAIR_F(...)
Definition: debug_out.h:81
Definition: binary_protocol.h:57
static bool read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing=true)
#define SERIAL_FLUSH()
Definition: serial.h:76
#define Y_BED_SIZE
Definition: Configuration_A3ides_2209_MINI.h:981
static void set_all_mesh_points_to_value(const float value)
#define DEBUGGING(F)
Definition: serial.h:47
void report_current_position()
Definition: motion.cpp:199
#define isinf
Definition: Arduino.h:58
static void report_current_mesh()
#define SERIAL_ECHOPAIR_F(S, V...)
Definition: serial.h:176
static void smart_fill_wlsf(const float &) _O2
static heatshrink_decoder hsd
Definition: binary_protocol.h:53
#define ABORT(fs, res)
Definition: ff.c:455
static FORCE_INLINE float fade_scaling_factor_for_z(const float &)
Definition: planner.h:445
static volatile int encoder_diff
Definition: ubl.h:116
void print_hex_word(const uint16_t w)
Definition: hex_print_routines.cpp:78
MeshPointType
Definition: ubl.h:35
#define SERIAL_EOL()
Definition: serial.h:181
uint8_t axes_need_homing(uint8_t axis_bits)
Definition: motion.cpp:1041
#define STOW_PROBE()
Definition: probe.h:61
#define KILL_PIN
Definition: pins_CHEAPTRONICv2.h:106
#define DEBUG_ECHOPAIR(...)
Definition: debug_out.h:80
static bool validate(char *buffer, size_t length)
Definition: binary_protocol.h:61
Definition: vector_3.h:47
#define TEST(n, b)
Definition: macros.h:81
#define LOGICAL_X_POSITION(POS)
Definition: motion.h:278
T y
Definition: types.h:185
PersistentStore persistentStore
Definition: persistent_store_api.cpp:28
uint16_t checksum
Definition: binary_protocol.h:259
millis_t timeout
Definition: binary_protocol.h:260
static const uint16_t VERSION_MAJOR
Definition: binary_protocol.h:218
Definition: binary_protocol.h:230
void dispatch()
Definition: binary_protocol.h:449
char * hex_address(const void *const w)
Definition: hex_print_routines.cpp:67
#define X_MIN_BED
Definition: Conditionals_post.h:81
#define UBL_ERR
Definition: ubl.h:33
void serial_delay(const millis_t ms)
Definition: utility.h:31
char * buffer
Definition: binary_protocol.h:261
png_uint_32 length
Definition: png.c:2247
#define Z_CLEARANCE_DEPLOY_PROBE
Definition: Configuration_A3ides_2209_MINI.h:892
void serialprintPGM(PGM_P str)
Definition: serial.cpp:35
#define SBI(A, B)
Definition: macros.h:85
#define S_FMT
Definition: macros.h:68
#define SERIAL_ECHOLNPGM(S)
Definition: serial.h:174
#define DEBUG_CHAR(...)
Definition: debug_out.h:74
#define HEATSHRINK_STATIC_WINDOW_BITS
Definition: heatshrink_config.h:18
ProtocolControl
Definition: binary_protocol.h:225
void idle()
Definition: Marlin.cpp:629
#define READ(IO)
Definition: fastio.h:95
static void save_ubl_active_state_and_disable()
void serial_spaces(uint8_t count)
Definition: serial.cpp:50
#define UNUSED(X)
Definition: stm32f4xx_hal_def.h:74
#define X_MAX_BED
Definition: Conditionals_post.h:82
void incremental_WLSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z, const float &w)
Definition: least_squares_fit.h:51
uint32_t millis_t
Definition: millis_t.h:26
static const uint16_t MAX_RETRIES
Definition: binary_protocol.h:473
bool bs_serial_data_available(const uint8_t index)
Definition: binary_protocol.h:32
void idle()
Definition: binary_protocol.h:468
constexpr uint8_t active_extruder
Definition: motion.h:107
uint32_t bytes_received
Definition: binary_protocol.h:476
static const uint16_t RX_TIMESLICE
Definition: binary_protocol.h:473
static bed_mesh_t z_values
Definition: ubl.h:108
#define ENABLED(V...)
Definition: macros.h:177
Planner planner
Definition: planner.cpp:111
T y
Definition: types.h:383
parser
Definition: createSpeedLookupTable.py:14
float probe_max_y()
Definition: probe.h:106
uint8_t info[12]
Definition: masstorage.h:54