output.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #include <stdio.h>
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #include <stdlib.h>
  5. #include <stdarg.h>
  6. #include <limits.h>
  7. #include <string.h>
  8. #include <ctype.h>
  9. #include <unistd.h>
  10. #include <stddef.h>
  11. #include <time.h>
  12. #include <errno.h>
  13. #include "main.h"
  14. #include "cmdopt.h"
  15. #include "error.h"
  16. #include "output.h"
  17. /////////////////////////////////////////////////////////////////////////////
  18. extern int g_nVerbosity;
  19. /////////////////////////////////////////////////////////////////////////////
  20. int GfaTfuPrintF(int verb, const char *pszFormat, ...)
  21. {
  22. if(verb <= g_nVerbosity)
  23. {
  24. int nRet;
  25. FILE *pf = (verb <= 1) ? stderr : stdout;
  26. va_list args;
  27. va_start(args, pszFormat);
  28. nRet = vfprintf(pf, pszFormat, args);
  29. fflush(pf);
  30. va_end(args);
  31. return nRet;
  32. }
  33. return 0;
  34. }
  35. /////////////////////////////////////////////////////////////////////////////
  36. void GfaTfuDumpImageInfo(const char *pszContext, LPCGFA_IMG_INFO pii)
  37. {
  38. if( (g_nVerbosity >= 2) &&
  39. pszContext &&
  40. pii &&
  41. (pii->nImgLength != 0xFFFFFFFF) &&
  42. (pii->nImgCRC32 != 0xFFFFFFFF))
  43. {
  44. TRACE2("%s Image Information:\n", pszContext);
  45. TRACE2(" Length: %u\n", pii->nImgLength);
  46. TRACE2(" CRC32: 0x%08X\n", pii->nImgCRC32);
  47. TRACE2(" Mat.Nr.: %s\n", pii->szImgMaterialNum);
  48. TRACE2(" Build: %s\n", pii->szImgNameBuild);
  49. }
  50. }
  51. /////////////////////////////////////////////////////////////////////////////
  52. void GfaTfuOnDownloadStatus(const char *pszFile, int nLine, uint8_t nNodeAddr, uint32_t nFlashStartAddr, uint32_t nCbData, int nCtx, int nErrorCode)
  53. {
  54. UNUSED(pszFile);
  55. UNUSED(nLine);
  56. UNUSED(nNodeAddr);
  57. UNUSED(nFlashStartAddr);
  58. UNUSED(nCbData);
  59. UNUSED(nCtx);
  60. UNUSED(nErrorCode);
  61. }
  62. /////////////////////////////////////////////////////////////////////////////
  63. void GfaTfuOnSendDataStatus(const char *pszFile, int nLine, uint8_t nNodeAddr, uint32_t nCbBlock, uint32_t nCbData, int nCtx, int nErrorCode)
  64. {
  65. UNUSED(pszFile);
  66. UNUSED(nLine);
  67. UNUSED(nNodeAddr);
  68. UNUSED(nCbBlock);
  69. UNUSED(nCbData);
  70. UNUSED(nCtx);
  71. UNUSED(nErrorCode);
  72. }