My Marlin configs for Fabrikator Mini and CTC i3 Pro B
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

UHS_hexdump.h 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* Copyright (C) 2015-2016 Andrew J. Kroll
  2. and
  3. Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15. Contact information
  16. -------------------
  17. Circuits At Home, LTD
  18. Web : https://www.circuitsathome.com
  19. e-mail : support@circuitsathome.com
  20. */
  21. #if !defined(_usb_h_) || defined(__HEXDUMP_H__)
  22. #error "Never include UHS_hexdump.h directly; include UHS_Usb.h instead"
  23. #else
  24. #define __HEXDUMP_H__
  25. extern int UsbDEBUGlvl;
  26. template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE>
  27. class HexDumper : public BASE_CLASS {
  28. uint8_t byteCount;
  29. OFFSET_TYPE byteTotal;
  30. public:
  31. HexDumper() : byteCount(0), byteTotal(0) {
  32. };
  33. void Initialize() {
  34. byteCount = 0;
  35. byteTotal = 0;
  36. };
  37. virtual void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset);
  38. };
  39. template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE>
  40. void HexDumper<BASE_CLASS, LEN_TYPE, OFFSET_TYPE>::Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset) {
  41. if(UsbDEBUGlvl >= 0x80) { // Fully bypass this block of code if we do not debug.
  42. for(LEN_TYPE j = 0; j < len; j++, byteCount++, byteTotal++) {
  43. if(!byteCount) {
  44. PrintHex<OFFSET_TYPE > (byteTotal, 0x80);
  45. E_Notify(PSTR(": "), 0x80);
  46. }
  47. PrintHex<uint8_t > (pbuf[j], 0x80);
  48. E_Notify(PSTR(" "), 0x80);
  49. if(byteCount == 15) {
  50. E_Notify(PSTR("\r\n"), 0x80);
  51. byteCount = 0xFF;
  52. }
  53. }
  54. }
  55. }
  56. #endif // __HEXDUMP_H__