Prusa MINI Firmware overview
base64_stream_decoder.h
Go to the documentation of this file.
1 #ifndef BASE64_STREAM_DECODER_H
2 #define BASE64_STREAM_DECODER_H
3 
4 #include <stdint.h>
5 
6 // dekodovani 3 bajtu ze 4 base64 znaku - jelikoz mame 80 znaku na radek
7 // a 2 znaky jsou uvodni, tak 78/4 rozhodne neni cely cislo, takze to bude
8 // pretejkat Stavy funkce muzou bejt nasledujici: 0 podarilo se zdekodovat
9 // vsechny 3 bajty, tj. vstupem byl dost dlouhej retezec 1 podarilo se
10 // zdekodovat 2 bajty a nic nezbylo 2 podarilo se zdekodovat 2 bajty a neco
11 // zbylo, ceka se na dalsi radek (nejslozitejsi pripad) 3 podarilo se zdekodovat
12 // 1 bajt a nic nezbylo -1 jiny pruser, chyba dekodovani/dat Idealne tohle
13 // udelat jako objekt, ktery bude dostavat vstupni znaky a obcas z nej vypadne
14 // nejakej bajt proste aby si to pamatovalo svuj stav i mezi volanima... Pak by
15 // byla funkce ConsumeChar, ktera by vracela true/false jako mam bajt/nemam bajt
17 public:
19  : state(States::AwaitingFirst) {
20  }
21 
22  inline static uint8_t find64(uint8_t base64c) {
23  return base64_inverse[base64c];
24  }
25 
26  inline void Reset() {
27  state = States::AwaitingFirst;
28  }
29 
30  // @param c znak z base64 retezce
31  // @param out sem se pripadne zapise zdekodovany bajt
32  // @return 1 pokud je vystupni bajt hotovy a platny
33  // 0 pokud na vystup nic nejde
34  // -1 pokud se posralo dekodovani vstupniho znaku
35  int ConsumeChar(char c, uint8_t *out);
36 
37 private:
38  uint8_t lastbits;
39  enum class States : uint8_t {
40  AwaitingFirst, // ocekavam prvni znak, nemam nic
41  FirstByteOut, // mam prvni znak, a prisel mi 2. znak - vracim 1. bajt,
42  // ukladam si zbyly 4 bity pro dalsi pouziti
43  SecondByteOut, // mam 2. znak a prisel mi 3. znak, pouziju z nej 4 bity,
44  // slozim s predchozimi 4 bity, vracim 1 bajt, zustavaji
45  // mi 2 bity pro dalsi pouziti
46  ThirdByteOut // mam 3. znak a prisel mi 4. znak, slozim s predchozimi 2
47  // bity a vracim 1 bajt, prechazim do stavu 0
48  };
49  States state;
50 
51  // Inverse base64 lookup table
52  // generated programmatically
53  // for(size_t i = 0; i <= 255; ++i){
54  // cout << hex << "0x" << (int)( is_base64(i) ? find64((uint8_t)i) : 0xff
55  //) << ", ";
56  // }
57  static const uint8_t base64_inverse[256];
58 };
59 
60 #endif // BASE64_STREAM_DECODER_H
marlin_server.h
Base64StreamDecoder::Base64StreamDecoder
Base64StreamDecoder()
Definition: base64_stream_decoder.h:18
app_tim6_tick
void app_tim6_tick(void)
Definition: appmain.cpp:157
usbh_core.h
Header file for usbh_core.c.
app_run
void app_run(void)
Definition: appmain.cpp:62
trinamic.h
osThreadId
TaskHandle_t osThreadId
Definition: cmsis_os.h:283
hwio_safe_state
void hwio_safe_state(void)
Put hardware into safe state.
Definition: safe_state.c:8
settings
MarlinSettings settings
Definition: configuration_store.cpp:344
app_setup
void app_setup(void)
Definition: appmain.cpp:51
uartslave.h
eeprom.h
_uartslave_t
Definition: uartslave.h:32
app_assert
void app_assert(uint8_t *file, uint32_t line)
Definition: appmain.cpp:149
IWDG_HandleTypeDef
IWDG Handle Structure definition.
Definition: stm32f4xx_hal_iwdg.h:76
diag.h
uartslave_cycle
void uartslave_cycle(uartslave_t *pslave)
Definition: uartslave.c:68
sys.h
bsod.h
setup
void setup(void)
Definition: Marlin.cpp:818
osThreadResume
osStatus osThreadResume(osThreadId thread_id)
Resume execution of a suspended thread.
Definition: cmsis_os.c:1494
marlin_server_stop_processing
void marlin_server_stop_processing(void)
Definition: marlin_server.cpp:293
safe_state.h
i
uint8_t i
Definition: screen_test_graph.c:72
adc.h
init_tmc
void init_tmc(void)
diag_fastboot
int diag_fastboot
Definition: diag.c:11
dbg.h
_USBH_HandleTypeDef
Definition: usbh_def.h:450
HOST_ENUMERATION
Definition: usbh_def.h:333
MarlinSettings::save
static bool save()
Definition: configuration_store.cpp:2198
MarlinSettings::reset
static void reset()
Definition: configuration_store.cpp:2208
eeprom_init
uint8_t eeprom_init(void)
Definition: eeprom.c:53
osDelay
osStatus osDelay(uint32_t millisec)
Wait for Timeout (Time Delay)
Definition: cmsis_os.c:365
HAL_GetTick
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
Definition: stm32f4xx_hal.c:339
sim_heater.h
hwio_update_1ms
void hwio_update_1ms(void)
Definition: hwio_a3ides_2209_02.c:539
uart6slave
uartslave_t uart6slave
Definition: main.c:149
jogwheel_encoder
int32_t jogwheel_encoder
Definition: jogwheel.c:10
HAL_IWDG_Refresh
HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg)
adc_cycle
void adc_cycle(void)
Definition: adc.c:65
loop
void loop(void)
Definition: Marlin.cpp:1127
app_error
void app_error(void)
Definition: appmain.cpp:145
ENUM_IDLE
Definition: usbh_def.h:346
hwio_fan_get_cnt
int hwio_fan_get_cnt(void)
Definition: hwio_a3ides_2209_02.c:444
sys_fw_is_valid
int sys_fw_is_valid(void)
Definition: sys.cpp:266
Base64StreamDecoder::ConsumeChar
int ConsumeChar(char c, uint8_t *out)
Definition: base64_stream_decoder.cpp:28
app_tim14_tick
void app_tim14_tick(void)
Definition: appmain.cpp:173
uart6rxbuff
uartrxbuff_t uart6rxbuff
Definition: main.c:147
jogwheel_signals
uint8_t jogwheel_signals
Definition: jogwheel.c:7
DBG
#define DBG
Definition: appmain.cpp:33
webServerTaskHandle
osThreadId webServerTaskHandle
Definition: main.c:100
USBH_ReEnumerate
USBH_StatusTypeDef USBH_ReEnumerate(USBH_HandleTypeDef *phost)
HCD_ReEnumerate Perform a new Enumeration phase.
Definition: usbh_core.c:371
Base64StreamDecoder::Reset
void Reset()
Definition: base64_stream_decoder.h:26
sim_motion.h
gpio.h
hwio_fan_set_pwm
void hwio_fan_set_pwm(int i_fan, int val)
Definition: hwio_a3ides_2209_02.c:447
Base64StreamDecoder
Definition: base64_stream_decoder.h:16
Base64StreamDecoder::find64
static uint8_t find64(uint8_t base64c)
Definition: base64_stream_decoder.h:22
hUsbHostHS
USBH_HandleTypeDef hUsbHostHS
Definition: usb_host.c:74
uint8_t
const uint8_t[]
Definition: 404_html.c:3
_dbg
#define _dbg(...)
Definition: dbg.h:50
sim_heater_init
void sim_heater_init(void)
app_idle
void app_idle(void)
Definition: appmain.cpp:58
jogwheel_update_1ms
void jogwheel_update_1ms(void)
Definition: jogwheel.c:22
_USBH_HandleTypeDef::EnumState
ENUM_StateTypeDef EnumState
Definition: usbh_def.h:453
jogwheel.h
app_usbhost_reenum
void app_usbhost_reenum(void)
Definition: appmain.cpp:187
app.h
marlin_server_loop
int marlin_server_loop(void)
Definition: marlin_server.cpp:239
bsod
#define bsod(fmt,...)
Definition: bsod.h:20
hiwdg
IWDG_HandleTypeDef hiwdg
Definition: watchdog.h:24
base64_stream_decoder.h
marlin_server_idle_cb
marlin_server_idle_t * marlin_server_idle_cb
Definition: marlin_server.cpp:94
config.h
marlin_server_init
void marlin_server_init(void)
Definition: marlin_server.cpp:154
hwio_a3ides.h
sim_motion_pos
int32_t sim_motion_pos[4]
USBSerial_put_rx_data
void USBSerial_put_rx_data(uint8_t *buffer, uint32_t length)
Definition: USBSerial.cpp:53
length
png_uint_32 length
Definition: png.c:2247
adc_init
void adc_init(void)
Definition: adc.c:53
app_cdc_rx
void app_cdc_rx(uint8_t *buffer, uint32_t length)
Definition: appmain.cpp:153
_USBH_HandleTypeDef::gState
__IO HOST_StateTypeDef gState
Definition: usbh_def.h:452
cmsis_os.h
Header of cmsis_os.c A new set of APIs are added in addition to existing ones, these APIs are specifi...
_uartrxbuff_t
Definition: uartrxbuff.h:16
sim_heater_cycle
void sim_heater_cycle(void)
sim_motion_cycle
void sim_motion_cycle(void)
marlin_server_processing
int marlin_server_processing(void)
Definition: marlin_server.cpp:284