luat_log_air105.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "luat_base.h"
  2. #include "luat_log.h"
  3. #include "luat_cmux.h"
  4. #include "luat_conf_bsp.h"
  5. #include "app_interface.h"
  6. extern uint8_t cmux_state;
  7. extern uint8_t cmux_log_state;
  8. void DBG_DirectOut(void *Data, uint32_t Len);
  9. void luat_nprint(char *s, size_t l) {
  10. #ifdef LUAT_USE_SHELL
  11. if (cmux_state == 1 && cmux_log_state ==1){
  12. luat_cmux_write(LUAT_CMUX_CH_LOG, CMUX_FRAME_UIH & ~ CMUX_CONTROL_PF,s, l);
  13. }else
  14. #endif
  15. DBG_DirectOut(s, l);
  16. }
  17. void luat_log_write(char *s, size_t l) {
  18. #ifdef LUAT_USE_SHELL
  19. if (cmux_state == 1 && cmux_log_state ==1){
  20. luat_cmux_write(LUAT_CMUX_CH_LOG, CMUX_FRAME_UIH & ~ CMUX_CONTROL_PF,s, l);
  21. }else
  22. #endif
  23. DBG_DirectOut(s, l);
  24. }
  25. static void luat_cmux_write_cb(uint8_t *data, uint32_t len){
  26. luat_cmux_write(LUAT_CMUX_CH_LOG, CMUX_FRAME_UIH & ~ CMUX_CONTROL_PF,data, len);
  27. }
  28. void luat_cmux_log_set(uint8_t state) {
  29. if (state == 1){
  30. DBG_SetTxCB(luat_cmux_write_cb);
  31. }else if(state == 0){
  32. DBG_SetTxCB(add_printf_data);
  33. }
  34. }