Dcodes.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. #include "Dcodes.h"
  2. #include "Marlin.h"
  3. #ifdef DEBUG_DCODES
  4. #include "ConfigurationStore.h"
  5. #include "cmdqueue.h"
  6. #include "pat9125.h"
  7. #include "adc.h"
  8. #include "temperature.h"
  9. #include <avr/wdt.h>
  10. #define FLASHSIZE 0x40000
  11. #define RAMSIZE 0x2000
  12. #define boot_src_addr (*((uint32_t*)(RAMSIZE - 16)))
  13. #define boot_dst_addr (*((uint32_t*)(RAMSIZE - 12)))
  14. #define boot_copy_size (*((uint16_t*)(RAMSIZE - 8)))
  15. #define boot_reserved (*((uint8_t*)(RAMSIZE - 6)))
  16. #define boot_app_flags (*((uint8_t*)(RAMSIZE - 5)))
  17. #define boot_app_magic (*((uint32_t*)(RAMSIZE - 4)))
  18. #define BOOT_APP_FLG_ERASE 0x01
  19. #define BOOT_APP_FLG_COPY 0x02
  20. #define BOOT_APP_FLG_FLASH 0x04
  21. extern uint8_t fsensor_log;
  22. extern float current_temperature_pinda;
  23. extern float axis_steps_per_unit[NUM_AXIS];
  24. inline void print_hex_nibble(uint8_t val)
  25. {
  26. putchar((val > 9)?(val - 10 + 'a'):(val + '0'));
  27. }
  28. void print_hex_byte(uint8_t val)
  29. {
  30. print_hex_nibble(val >> 4);
  31. print_hex_nibble(val & 15);
  32. }
  33. void print_hex_word(uint16_t val)
  34. {
  35. print_hex_byte(val >> 8);
  36. print_hex_byte(val & 255);
  37. }
  38. void print_mem(uint32_t address, uint16_t count, uint8_t type, uint8_t countperline = 16)
  39. {
  40. while (count)
  41. {
  42. if (type == 2)
  43. print_hex_nibble(address >> 16);
  44. print_hex_word(address);
  45. putchar(' ');
  46. uint8_t count_line = countperline;
  47. while (count && count_line)
  48. {
  49. uint8_t data = 0;
  50. switch (type)
  51. {
  52. case 0: data = *((uint8_t*)address++); break;
  53. case 1: data = eeprom_read_byte((uint8_t*)address++); break;
  54. case 2: data = pgm_read_byte_far((uint8_t*)address++); break;
  55. }
  56. putchar(' ');
  57. print_hex_byte(data);
  58. count_line--;
  59. count--;
  60. }
  61. putchar('\n');
  62. }
  63. }
  64. //#define LOG(args...) printf(args)
  65. #define LOG(args...)
  66. int parse_hex(char* hex, uint8_t* data, int count)
  67. {
  68. int parsed = 0;
  69. while (*hex)
  70. {
  71. if (count && (parsed >= count)) break;
  72. char c = *(hex++);
  73. if (c == ' ') continue;
  74. if (c == '\n') break;
  75. uint8_t val = 0x00;
  76. if ((c >= '0') && (c <= '9')) val |= ((c - '0') << 4);
  77. else if ((c >= 'a') && (c <= 'f')) val |= ((c - 'a' + 10) << 4);
  78. else return -parsed;
  79. c = *(hex++);
  80. if ((c >= '0') && (c <= '9')) val |= (c - '0');
  81. else if ((c >= 'a') && (c <= 'f')) val |= (c - 'a' + 10);
  82. else return -parsed;
  83. data[parsed] = val;
  84. parsed++;
  85. }
  86. return parsed;
  87. }
  88. void dcode__1()
  89. {
  90. printf("D-1 - Endless loop\n");
  91. cli();
  92. while (1);
  93. }
  94. void dcode_0()
  95. {
  96. if (*(strchr_pointer + 1) == 0) return;
  97. LOG("D0 - Reset\n");
  98. if (code_seen('B')) //bootloader
  99. {
  100. cli();
  101. wdt_enable(WDTO_15MS);
  102. while(1);
  103. }
  104. else //reset
  105. {
  106. #ifndef _NO_ASM
  107. asm volatile("jmp 0x00000");
  108. #endif //_NO_ASM
  109. }
  110. }
  111. void dcode_1()
  112. {
  113. LOG("D1 - Clear EEPROM and RESET\n");
  114. cli();
  115. for (int i = 0; i < 8192; i++)
  116. eeprom_write_byte((unsigned char*)i, (unsigned char)0xff);
  117. wdt_enable(WDTO_15MS);
  118. while(1);
  119. }
  120. void dcode_2()
  121. {
  122. LOG("D2 - Read/Write RAM\n");
  123. uint16_t address = 0x0000; //default 0x0000
  124. uint16_t count = 0x2000; //default 0x2000 (entire ram)
  125. if (code_seen('A')) // Address (0x0000-0x1fff)
  126. address = (strchr_pointer[1] == 'x')?strtol(strchr_pointer + 2, 0, 16):(int)code_value();
  127. if (code_seen('C')) // Count (0x0001-0x2000)
  128. count = (int)code_value();
  129. address &= 0x1fff;
  130. if (count > 0x2000) count = 0x2000;
  131. if ((address + count) > 0x2000) count = 0x2000 - address;
  132. if (code_seen('X')) // Data
  133. {
  134. uint8_t data[16];
  135. count = parse_hex(strchr_pointer + 1, data, 16);
  136. if (count > 0)
  137. {
  138. for (int i = 0; i < count; i++)
  139. *((uint8_t*)(address + i)) = data[i];
  140. LOG("%d bytes written to RAM at address %04x", count, address);
  141. }
  142. else
  143. count = 0;
  144. }
  145. print_mem(address, count, 0);
  146. /* while (count)
  147. {
  148. print_hex_word(address);
  149. putchar(' ');
  150. uint8_t countperline = 16;
  151. while (count && countperline)
  152. {
  153. uint8_t data = *((uint8_t*)address++);
  154. putchar(' ');
  155. print_hex_byte(data);
  156. countperline--;
  157. count--;
  158. }
  159. putchar('\n');
  160. }*/
  161. }
  162. void dcode_3()
  163. {
  164. LOG("D3 - Read/Write EEPROM\n");
  165. uint16_t address = 0x0000; //default 0x0000
  166. uint16_t count = 0x2000; //default 0x2000 (entire eeprom)
  167. if (code_seen('A')) // Address (0x0000-0x1fff)
  168. address = (strchr_pointer[1] == 'x')?strtol(strchr_pointer + 2, 0, 16):(int)code_value();
  169. if (code_seen('C')) // Count (0x0001-0x2000)
  170. count = (int)code_value();
  171. address &= 0x1fff;
  172. if (count > 0x2000) count = 0x2000;
  173. if ((address + count) > 0x2000) count = 0x2000 - address;
  174. if (code_seen('X')) // Data
  175. {
  176. uint8_t data[16];
  177. count = parse_hex(strchr_pointer + 1, data, 16);
  178. if (count > 0)
  179. {
  180. for (int i = 0; i < count; i++)
  181. eeprom_write_byte((uint8_t*)(address + i), data[i]);
  182. LOG(count, DEC);
  183. LOG(" bytes written to EEPROM at address ");
  184. print_hex_word(address);
  185. putchar('\n');
  186. }
  187. else
  188. count = 0;
  189. }
  190. print_mem(address, count, 1);
  191. /* while (count)
  192. {
  193. print_hex_word(address);
  194. putchar(' ');
  195. uint8_t countperline = 16;
  196. while (count && countperline)
  197. {
  198. uint8_t data = eeprom_read_byte((uint8_t*)address++);
  199. putchar(' ');
  200. print_hex_byte(data);
  201. countperline--;
  202. count--;
  203. }
  204. putchar('\n');
  205. }*/
  206. }
  207. void dcode_4()
  208. {
  209. LOG("D4 - Read/Write PIN\n");
  210. if (code_seen('P')) // Pin (0-255)
  211. {
  212. int pin = (int)code_value();
  213. if ((pin >= 0) && (pin <= 255))
  214. {
  215. if (code_seen('F')) // Function in/out (0/1)
  216. {
  217. int fnc = (int)code_value();
  218. if (fnc == 0) pinMode(pin, INPUT);
  219. else if (fnc == 1) pinMode(pin, OUTPUT);
  220. }
  221. if (code_seen('V')) // Value (0/1)
  222. {
  223. int val = (int)code_value();
  224. if (val == 0) digitalWrite(pin, LOW);
  225. else if (val == 1) digitalWrite(pin, HIGH);
  226. }
  227. else
  228. {
  229. int val = (digitalRead(pin) != LOW)?1:0;
  230. printf("PIN%d=%d", pin, val);
  231. }
  232. }
  233. }
  234. }
  235. /*
  236. void dcode_5()
  237. {
  238. LOG("D5 - Read/Write FLASH\n");
  239. uint32_t address = 0x0000; //default 0x0000
  240. uint16_t count = 0x0400; //default 0x0400 (1kb block)
  241. if (code_seen('A')) // Address (0x00000-0x3ffff)
  242. address = (strchr_pointer[1] == 'x')?strtol(strchr_pointer + 2, 0, 16):(int)code_value();
  243. if (code_seen('C')) // Count (0x0001-0x2000)
  244. count = (int)code_value();
  245. address &= 0x3ffff;
  246. if (count > 0x2000) count = 0x2000;
  247. if ((address + count) > 0x40000) count = 0x40000 - address;
  248. bool bErase = false;
  249. bool bCopy = false;
  250. if (code_seen('E')) //Erase
  251. bErase = true;
  252. uint8_t data[16];
  253. if (code_seen('X')) // Data
  254. {
  255. count = parse_hex(strchr_pointer + 1, data, 16);
  256. if (count > 0) bCopy = true;
  257. }
  258. if (bErase || bCopy)
  259. {
  260. if (bErase)
  261. {
  262. LOG(count, DEC);
  263. LOG(" bytes of FLASH at address ");
  264. print_hex_word(address);
  265. putchar(" will be erased\n");
  266. }
  267. if (bCopy)
  268. {
  269. LOG(count, DEC);
  270. LOG(" bytes will be written to FLASH at address ");
  271. print_hex_word(address);
  272. putchar('\n');
  273. }
  274. cli();
  275. boot_app_magic = 0x55aa55aa;
  276. boot_app_flags = (bErase?(BOOT_APP_FLG_ERASE):0) | (bCopy?(BOOT_APP_FLG_COPY):0);
  277. boot_copy_size = (uint16_t)count;
  278. boot_dst_addr = (uint32_t)address;
  279. boot_src_addr = (uint32_t)(&data);
  280. wdt_enable(WDTO_15MS);
  281. while(1);
  282. }
  283. while (count)
  284. {
  285. print_hex_nibble(address >> 16);
  286. print_hex_word(address);
  287. putchar(' ');
  288. uint8_t countperline = 16;
  289. while (count && countperline)
  290. {
  291. uint8_t data = pgm_read_byte_far((uint8_t*)address++);
  292. putchar(' ');
  293. print_hex_byte(data);
  294. countperline--;
  295. count--;
  296. }
  297. putchar('\n');
  298. }
  299. }
  300. */
  301. void dcode_6()
  302. {
  303. LOG("D6 - Read/Write external FLASH\n");
  304. }
  305. void dcode_7()
  306. {
  307. LOG("D7 - Read/Write Bootloader\n");
  308. /*
  309. cli();
  310. boot_app_magic = 0x55aa55aa;
  311. boot_app_flags = BOOT_APP_FLG_ERASE | BOOT_APP_FLG_COPY | BOOT_APP_FLG_FLASH;
  312. boot_copy_size = (uint16_t)0xc00;
  313. boot_src_addr = (uint32_t)0x0003e400;
  314. boot_dst_addr = (uint32_t)0x0003f400;
  315. wdt_enable(WDTO_15MS);
  316. while(1);
  317. */
  318. }
  319. void dcode_8()
  320. {
  321. printf_P(PSTR("D8 - Read/Write PINDA\n"));
  322. uint8_t cal_status = calibration_status_pinda();
  323. float temp_pinda = current_temperature_pinda;
  324. float offset_z = temp_compensation_pinda_thermistor_offset(temp_pinda);
  325. if ((strchr_pointer[1+1] == '?') || (strchr_pointer[1+1] == 0))
  326. {
  327. printf_P(PSTR("cal_status=%d\n"), cal_status?1:0);
  328. for (uint8_t i = 0; i < 6; i++)
  329. {
  330. uint16_t offs = 0;
  331. if (i > 0) offs = eeprom_read_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + (i - 1));
  332. float foffs = ((float)offs) / axis_steps_per_unit[Z_AXIS];
  333. offs = 1000 * foffs;
  334. printf_P(PSTR("temp_pinda=%dC temp_shift=%dum\n"), 35 + i * 5, offs);
  335. }
  336. }
  337. else if (strchr_pointer[1+1] == '!')
  338. {
  339. cal_status = 1;
  340. eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, cal_status);
  341. eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 0, 8); //40C - 20um - 8usteps
  342. eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 1, 24); //45C - 60um - 24usteps
  343. eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 2, 48); //50C - 120um - 48usteps
  344. eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 3, 80); //55C - 200um - 80usteps
  345. eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 4, 120); //60C - 300um - 120usteps
  346. }
  347. else
  348. {
  349. if (code_seen('P')) // Pinda temperature [C]
  350. temp_pinda = code_value();
  351. offset_z = temp_compensation_pinda_thermistor_offset(temp_pinda);
  352. if (code_seen('Z')) // Z Offset [mm]
  353. {
  354. offset_z = code_value();
  355. }
  356. }
  357. printf_P(PSTR("temp_pinda=%d offset_z=%d.%03d\n"), (int)temp_pinda, (int)offset_z, ((int)(1000 * offset_z) % 1000));
  358. }
  359. const char* dcode_9_ADC_name(uint8_t i)
  360. {
  361. switch (i)
  362. {
  363. case 0: return PSTR("TEMP_HEATER0");
  364. case 1: return PSTR("TEMP_HEATER1");
  365. case 2: return PSTR("TEMP_BED");
  366. case 3: return PSTR("TEMP_PINDA");
  367. case 4: return PSTR("VOLT_PWR");
  368. case 5: return PSTR("TEMP_AMBIENT");
  369. case 6: return PSTR("VOLT_BED");
  370. }
  371. return 0;
  372. }
  373. extern int current_temperature_raw[EXTRUDERS];
  374. extern int current_temperature_bed_raw;
  375. extern int current_temperature_raw_pinda;
  376. extern int current_temperature_raw_ambient;
  377. extern int current_voltage_raw_pwr;
  378. extern int current_voltage_raw_bed;
  379. uint16_t dcode_9_ADC_val(uint8_t i)
  380. {
  381. switch (i)
  382. {
  383. case 0: return current_temperature_raw[0];
  384. case 1: return 0;
  385. case 2: return current_temperature_bed_raw;
  386. case 3: return current_temperature_raw_pinda;
  387. case 4: return current_voltage_raw_pwr;
  388. case 5: return current_temperature_raw_ambient;
  389. case 6: return current_voltage_raw_bed;
  390. }
  391. return 0;
  392. }
  393. void dcode_9()
  394. {
  395. printf_P(PSTR("D9 - Read/Write ADC\n"));
  396. if ((strchr_pointer[1+1] == '?') || (strchr_pointer[1+1] == 0))
  397. {
  398. for (uint8_t i = 0; i < ADC_CHAN_CNT; i++)
  399. printf_P(PSTR("\tADC%d=%4d\t(%S)\n"), i, dcode_9_ADC_val(i) >> 4, dcode_9_ADC_name(i));
  400. }
  401. else
  402. {
  403. uint8_t index = 0xff;
  404. if (code_seen('I')) // index (index of used channel, not avr channel index)
  405. index = code_value();
  406. if (index < ADC_CHAN_CNT)
  407. {
  408. if (code_seen('V')) // value to be written as simulated
  409. {
  410. adc_sim_mask |= (1 << index);
  411. adc_values[index] = (((int)code_value()) << 4);
  412. printf_P(PSTR("ADC%d=%4d\n"), index, adc_values[index] >> 4);
  413. }
  414. }
  415. }
  416. }
  417. void dcode_10()
  418. {//Tell the printer that XYZ calibration went OK
  419. LOG("D10 - XYZ calibration = OK\n");
  420. calibration_status_store(CALIBRATION_STATUS_LIVE_ADJUST);
  421. }
  422. void dcode_12()
  423. {//Time
  424. LOG("D12 - Time\n");
  425. }
  426. #include "tmc2130.h"
  427. #include "Marlin.h"
  428. #include "planner.h"
  429. extern void st_synchronize();
  430. void dcode_2130()
  431. {
  432. printf_P(PSTR("D2130 - TMC2130\n"));
  433. uint8_t axis = 0xff;
  434. switch (strchr_pointer[1+4])
  435. {
  436. case 'X': axis = X_AXIS; break;
  437. case 'Y': axis = Y_AXIS; break;
  438. case 'Z': axis = Z_AXIS; break;
  439. case 'E': axis = E_AXIS; break;
  440. }
  441. if (axis != 0xff)
  442. {
  443. char ch_axis = strchr_pointer[1+4];
  444. if (strchr_pointer[1+5] == '0') { tmc2130_set_pwr(axis, 0); }
  445. else if (strchr_pointer[1+5] == '1') { tmc2130_set_pwr(axis, 1); }
  446. else if (strchr_pointer[1+5] == '+')
  447. {
  448. if (strchr_pointer[1+6] == 0)
  449. {
  450. tmc2130_set_dir(axis, 0);
  451. tmc2130_do_step(axis);
  452. }
  453. else
  454. {
  455. uint8_t steps = atoi(strchr_pointer + 1 + 6);
  456. tmc2130_do_steps(axis, steps, 0, 1000);
  457. }
  458. }
  459. else if (strchr_pointer[1+5] == '-')
  460. {
  461. if (strchr_pointer[1+6] == 0)
  462. {
  463. tmc2130_set_dir(axis, 1);
  464. tmc2130_do_step(axis);
  465. }
  466. else
  467. {
  468. uint8_t steps = atoi(strchr_pointer + 1 + 6);
  469. tmc2130_do_steps(axis, steps, 1, 1000);
  470. }
  471. }
  472. else if (strchr_pointer[1+5] == '?')
  473. {
  474. if (strcmp(strchr_pointer + 7, "mres") == 0) printf_P(PSTR("%c mres=%d\n"), ch_axis, tmc2130_mres[axis]);
  475. else if (strcmp(strchr_pointer + 7, "step") == 0) printf_P(PSTR("%c step=%d\n"), ch_axis, tmc2130_rd_MSCNT(axis) >> tmc2130_mres[axis]);
  476. else if (strcmp(strchr_pointer + 7, "mscnt") == 0) printf_P(PSTR("%c MSCNT=%d\n"), ch_axis, tmc2130_rd_MSCNT(axis));
  477. else if (strcmp(strchr_pointer + 7, "mscuract") == 0)
  478. {
  479. uint32_t val = tmc2130_rd_MSCURACT(axis);
  480. int curA = (val & 0xff);
  481. int curB = ((val >> 16) & 0xff);
  482. if ((val << 7) & 0x8000) curA -= 256;
  483. if ((val >> 9) & 0x8000) curB -= 256;
  484. printf_P(PSTR("%c MSCURACT=0x%08lx A=%d B=%d\n"), ch_axis, val, curA, curB);
  485. }
  486. else if (strcmp(strchr_pointer + 7, "wave") == 0)
  487. {
  488. tmc2130_get_wave(axis, 0, stdout);
  489. }
  490. }
  491. else if (strchr_pointer[1+5] == '!')
  492. {
  493. if (strncmp(strchr_pointer + 7, "step", 4) == 0)
  494. {
  495. uint8_t step = atoi(strchr_pointer + 11);
  496. uint16_t res = tmc2130_get_res(axis);
  497. tmc2130_goto_step(axis, step & (4*res - 1), 2, 1000, res);
  498. }
  499. else if (strncmp(strchr_pointer + 7, "mres", 4) == 0)
  500. {
  501. uint8_t mres = strchr_pointer[11] - '0';
  502. if ((mres >= 0) && (mres <= 8))
  503. {
  504. st_synchronize();
  505. uint16_t res = tmc2130_get_res(axis);
  506. uint16_t res_new = tmc2130_mres2usteps(mres);
  507. tmc2130_set_res(axis, res_new);
  508. if (res_new > res)
  509. axis_steps_per_unit[axis] *= (res_new / res);
  510. else
  511. axis_steps_per_unit[axis] /= (res / res_new);
  512. }
  513. }
  514. else if (strncmp(strchr_pointer + 7, "wave", 4) == 0)
  515. {
  516. uint8_t fac200 = atoi(strchr_pointer + 11) & 0xff;
  517. if (fac200 < TMC2130_WAVE_FAC200_MIN) fac200 = 0;
  518. if (fac200 > TMC2130_WAVE_FAC200_MAX) fac200 = TMC2130_WAVE_FAC200_MAX;
  519. tmc2130_set_wave(axis, 247, fac200);
  520. tmc2130_wave_fac[axis] = fac200;
  521. }
  522. }
  523. else if (strchr_pointer[1+5] == '@')
  524. {
  525. tmc2130_home_calibrate(axis);
  526. }
  527. }
  528. }
  529. void dcode_9125()
  530. {
  531. LOG("D9125 - PAT9125\n");
  532. if ((strchr_pointer[1+4] == '?') || (strchr_pointer[1+4] == 0))
  533. {
  534. // printf("res_x=%d res_y=%d x=%d y=%d b=%d s=%d\n", pat9125_xres, pat9125_yres, pat9125_x, pat9125_y, pat9125_b, pat9125_s);
  535. printf("x=%d y=%d b=%d s=%d\n", pat9125_x, pat9125_y, pat9125_b, pat9125_s);
  536. return;
  537. }
  538. if (strchr_pointer[1+4] == '!')
  539. {
  540. pat9125_update();
  541. printf("x=%d y=%d b=%d s=%d\n", pat9125_x, pat9125_y, pat9125_b, pat9125_s);
  542. return;
  543. }
  544. /*
  545. if (code_seen('R'))
  546. {
  547. unsigned char res = (int)code_value();
  548. LOG("pat9125_init(xres=yres=%d)=%d\n", res, pat9125_init(res, res));
  549. }
  550. */
  551. if (code_seen('X'))
  552. {
  553. pat9125_x = (int)code_value();
  554. LOG("pat9125_x=%d\n", pat9125_x);
  555. }
  556. if (code_seen('Y'))
  557. {
  558. pat9125_y = (int)code_value();
  559. LOG("pat9125_y=%d\n", pat9125_y);
  560. }
  561. if (code_seen('L'))
  562. {
  563. fsensor_log = (int)code_value();
  564. LOG("fsensor_log=%d\n", fsensor_log);
  565. }
  566. }
  567. #endif //DEBUG_DCODES