diff --git a/chip/basic/logger.hpp b/chip/basic/logger.hpp index 8fe69f7..5e4d791 100644 --- a/chip/basic/logger.hpp +++ b/chip/basic/logger.hpp @@ -18,7 +18,7 @@ extern bool g_enable_log; #define ZEARLY_LOGD(TAG, fmt, ...) \ if (g_enable_log) { \ zchip_log("%08lu DEBU [%-8s] " fmt "\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \ - } + } #define ZEARLY_LOGE(TAG, fmt, ...) \ if (g_enable_log) { \ zchip_log("%08lu ERRO [%-8s] " fmt "\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \ @@ -36,7 +36,7 @@ extern bool g_enable_log; zchip_clock_early_delayus(1000 * 1000); \ } \ } -void zchip_log(const char* fmt, ...); +void zchip_log(const char* fmt, ...) ; void zchip_loggger_init(zchip_uart_t* huart); void zchip_loggger_enable(bool enable); } diff --git a/chip/zuart.cpp b/chip/zuart.cpp index 4b48977..ddd950f 100644 --- a/chip/zuart.cpp +++ b/chip/zuart.cpp @@ -1,10 +1,8 @@ #include "zuart.hpp" #include -#include -#include -#include #include +#include using namespace iflytop; static ZUART *s_uart_table[10]; @@ -164,9 +162,13 @@ void ZUART::periodicJob() { } clearRxData(); } + if (m_isRxing) { + if (!(HAL_UART_GetState(m_huart) == HAL_UART_STATE_BUSY_RX || HAL_UART_GetState(m_huart) == HAL_UART_STATE_BUSY_TX_RX)) { + HAL_UART_Receive_IT(m_huart, &onebyte, 1); + } + } } - /******************************************************************************* * 中断 * *******************************************************************************/ diff --git a/components/cmdscheduler/cmd_scheduler.cpp b/components/cmdscheduler/cmd_scheduler.cpp index e0b2c16..6b61285 100644 --- a/components/cmdscheduler/cmd_scheduler.cpp +++ b/components/cmdscheduler/cmd_scheduler.cpp @@ -47,7 +47,7 @@ void CmdScheduler::schedule() { } } // ZLOGI(TAG, "cmdstr2: %s %d %d", cmdstr, strlen(cmdstr),m_rxsize); - for (size_t i = 0; i < m_rxsize; i++) { + for (int i = 0; i < m_rxsize; i++) { if (rxbuf[i] != '\0') { ZLOGI(TAG, "docmd: %s", &rxbuf[i]); int inext = strlen(&rxbuf[i]) + i; @@ -72,7 +72,9 @@ void CmdScheduler::callcmd(const char* cmd, CmdProcessContext& context) { memset(argv, 0, sizeof(argv)); strcpy(cmdcache, cmd); prase_cmd(cmdcache, strlen(cmdcache), argc, argv); - + if(argc == 0){ + return; + } // printf("argc:%d\n", argc); // for (size_t i = 0; i < argc; i++) { // printf("argv[%d]:%s\n", i, argv[i]); @@ -96,7 +98,7 @@ void CmdScheduler::prase_cmd(char* input, int inputlen, int& argc, char* argv[]) } int j = 0; - for (size_t i = 0; input[i] == 0 || i < inputlen; i++) { + for (int i = 0; input[i] == 0 || i < inputlen; i++) { if (input[i] != 0 && j == 0) { argv[argc++] = &input[i]; j = 1; @@ -108,4 +110,4 @@ void CmdScheduler::prase_cmd(char* input, int inputlen, int& argc, char* argv[]) continue; } } -} \ No newline at end of file +} diff --git a/components/cmdscheduler/cmd_scheduler.hpp b/components/cmdscheduler/cmd_scheduler.hpp index 6eb76fa..5ce8628 100644 --- a/components/cmdscheduler/cmd_scheduler.hpp +++ b/components/cmdscheduler/cmd_scheduler.hpp @@ -26,7 +26,7 @@ class CmdScheduler { bool m_dataisready = false; - char cmdcache[100]; + char cmdcache[1024] = {0}; public: void initialize(UART_HandleTypeDef* huart, uint32_t rxbufsize); diff --git a/components/dwin/text_displayer.cpp b/components/dwin/text_displayer.cpp index 0bf1f84..9338524 100644 --- a/components/dwin/text_displayer.cpp +++ b/components/dwin/text_displayer.cpp @@ -52,9 +52,9 @@ void TextDisplayer::setFont(uint16_t EncodeMode, uint8_t font0id, uint8_t font1i m_descript.TextLength = 256; } void TextDisplayer::setPos(uint16_t x, uint16_t y, uint16_t width, uint16_t hight) { - uint16_t startx = x; + // uint16_t startx = x; uint16_t endx = x + width; - uint16_t starty = y; + // uint16_t starty = y; uint16_t endy = y + hight; m_descript.PosX = x; diff --git a/components/flash/znvs.cpp b/components/flash/znvs.cpp index 9a4fba5..5c01627 100644 --- a/components/flash/znvs.cpp +++ b/components/flash/znvs.cpp @@ -5,6 +5,9 @@ #include "sdk\components\flash\zsimple_flash.hpp" #define TAG "config" +#ifdef IFLYTOP_NVS_CONFIG_MAX_ITEM_NUM + + using namespace iflytop; using namespace std; #define MARK_S 0x123456 @@ -157,3 +160,5 @@ bool ZNVS::get_config_bool(const char* key, bool default_val) { GET_CFG(bool void ZNVS::set_config_bool(const char* key, bool val) { SET_CFG(bool); } void ZNVS::flush() { zsimple_flash_write((uint8_t*)&m_cfg, sizeof(m_cfg)); } + +#endif \ No newline at end of file diff --git a/components/flash/znvs.hpp b/components/flash/znvs.hpp index e7807cc..457881e 100644 --- a/components/flash/znvs.hpp +++ b/components/flash/znvs.hpp @@ -2,6 +2,8 @@ #include "project_configs.h" #include "sdk/os/zos.hpp" +#ifdef IFLYTOP_NVS_CONFIG_MAX_ITEM_NUM + namespace iflytop { using namespace std; @@ -75,4 +77,5 @@ class ZNVS { cfg_t* get_and_create_cfg(const char* key, type_t type, uint8_t* default_val, uint8_t len); }; -} // namespace iflytop \ No newline at end of file +} // namespace iflytop +#endif \ No newline at end of file diff --git a/components/iflytop_can_slave_module_master_end/stepmotor.cpp b/components/iflytop_can_slave_module_master_end/stepmotor.cpp index 77b084e..efdf95e 100644 --- a/components/iflytop_can_slave_module_master_end/stepmotor.cpp +++ b/components/iflytop_can_slave_module_master_end/stepmotor.cpp @@ -136,6 +136,16 @@ void StepMotor::clearException() { } m_canMaster->writeReg(m_id, m_baseCtrlPoint + SAMC_REG_ACT_CLEAR_EXCEPTION, 0, 20); } +int32_t StepMotor::readpos() { + if (m_fakeMotorl) { + ZLOGE(TAG, "call stepmotor fail,motor is null"); + return 0; + } + int32_t pos = 0; + m_canMaster->readReg(m_id, m_baseCtrlPoint + SAMC_REG_STAT_CURRENT_POS, pos, 20); + return pos; +} + namespace iflytop { StepMotor g_nullStepMotor; diff --git a/components/iflytop_can_slave_module_master_end/stepmotor.hpp b/components/iflytop_can_slave_module_master_end/stepmotor.hpp index df2e018..3b54675 100644 --- a/components/iflytop_can_slave_module_master_end/stepmotor.hpp +++ b/components/iflytop_can_slave_module_master_end/stepmotor.hpp @@ -28,13 +28,13 @@ class StepMotor { bool setVelocity(int32_t velocity); int32_t getVelocity(); - bool setAcc(int32_t acc); - bool setDec(int32_t dec); - bool moveTo(int32_t pos); - bool moveBy(int32_t pos); - bool rotate(int32_t direction); - - void clearException(); + bool setAcc(int32_t acc); + bool setDec(int32_t dec); + bool moveTo(int32_t pos); + bool moveBy(int32_t pos); + bool rotate(int32_t direction); + int32_t readpos(); + void clearException(); int32_t getPos(); bool stop(); diff --git a/components/mini_servo_motor/feite_servo_motor.cpp b/components/mini_servo_motor/feite_servo_motor.cpp index fe42e32..2416486 100644 --- a/components/mini_servo_motor/feite_servo_motor.cpp +++ b/components/mini_servo_motor/feite_servo_motor.cpp @@ -314,8 +314,8 @@ bool FeiTeServoMotor::tx_and_rx(uint8_t* tx, uint8_t txdatalen, uint8_t* rx, uin uint32_t enter_ticket = HAL_GetTick(); dumphex("tx:", tx, txdatalen); - HAL_UART_Receive_DMA(m_uart, (uint8_t*)rx, expectrxsize); HAL_UART_Transmit(m_uart, tx, txdatalen, 1000); + HAL_UART_Receive_DMA(m_uart, (uint8_t*)rx, expectrxsize); bool overtime_flag = false; while (HAL_UART_GetState(m_uart) == HAL_UART_STATE_BUSY_RX || // diff --git a/components/motor_laser_code_scanner/motor_laser_code_scanne.cpp b/components/motor_laser_code_scanner/motor_laser_code_scanne.cpp index 7a86e57..0f31b58 100644 --- a/components/motor_laser_code_scanner/motor_laser_code_scanne.cpp +++ b/components/motor_laser_code_scanner/motor_laser_code_scanne.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "sdk\components\zprotocols\errorcode\errorcode.hpp" using namespace iflytop; diff --git a/components/sensors/smtp2/smtp2.cpp b/components/sensors/smtp2/smtp2.cpp index cf5c8c4..7d4f534 100644 --- a/components/sensors/smtp2/smtp2.cpp +++ b/components/sensors/smtp2/smtp2.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "sdk\components\zprotocols\errorcode\errorcode.hpp" using namespace iflytop; diff --git a/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp b/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp index 9c646cc..28d64a2 100644 --- a/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp +++ b/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp @@ -2,6 +2,7 @@ #include "sdk/components/errorcode/errorcode.hpp" +#include using namespace iflytop; #define TAG "StepMotorCtrlModule" void StepMotorCtrlModule::initialize(int id, IStepperMotor* stepM, ZGPIO* zero_gpio, ZGPIO* end_gpio) { @@ -140,7 +141,7 @@ int32_t StepMotorCtrlModule::move_to_zero_with_calibrate(int32_t nowx, action_cb return; } - int32_t calibrate_x, calibrate_y; + int32_t calibrate_x; calibrate_x = dx + nowx; m_param.shift_x = calibrate_x; diff --git a/components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp b/components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp index 6bd7f84..4bf2b36 100644 --- a/components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp +++ b/components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp @@ -29,7 +29,7 @@ void XYRobotCtrlModule::initialize(IStepperMotor* stepM1, // int32_t XYRobotCtrlModule::move_to(int32_t x, int32_t y, action_cb_status_t status_cb) { zlock_guard lock(m_lock); ZLOGI(TAG, "move_to x:%d y:%d", x, y); - int32_t m1pos, m2pos; + //int32_t m1pos, m2pos; m_thread.stop(); /** * @TODO:Ìí¼ÓÏÞλ¼ì²é diff --git a/components/zprotocols/zcancmder b/components/zprotocols/zcancmder index fca927c..272fe1a 160000 --- a/components/zprotocols/zcancmder +++ b/components/zprotocols/zcancmder @@ -1 +1 @@ -Subproject commit fca927c9a222ea031e6516df2bdef9b7f1f300b7 +Subproject commit 272fe1ac5a48f2093f87c7429bf444a15b0de097 diff --git a/os/zoslogger.cpp b/os/zoslogger.cpp index 81ecbe2..16c0b61 100644 --- a/os/zoslogger.cpp +++ b/os/zoslogger.cpp @@ -1,6 +1,20 @@ #include "zoslogger.hpp" + +#include +#include +#include +#include + iflytop::zmutex glog_mutex; extern "C" { -void zos_loggger_init() { glog_mutex.init(); } +void zos_loggger_init() { glog_mutex.init(); } +void zos_log(const char* fmt, ...) { + if (g_enable_log) { + va_list args; + va_start(args, fmt); + vprintf(fmt, args); + va_end(args); + } +} } diff --git a/os/zoslogger.hpp b/os/zoslogger.hpp index 99d2548..51714b4 100644 --- a/os/zoslogger.hpp +++ b/os/zoslogger.hpp @@ -12,36 +12,37 @@ extern bool g_enable_log; #define ZLOG_RELEASE(TAG, fmt, ...) \ if (g_enable_log) { \ iflytop::zlock_guard lock(glog_mutex); \ - printf(TAG "" fmt "\n", ##__VA_ARGS__); \ + zos_log(TAG "" fmt "\n", ##__VA_ARGS__); \ } #define ZLOGI(TAG, fmt, ...) \ if (g_enable_log) { \ iflytop::zlock_guard lock(glog_mutex); \ - printf("%08lu INFO [%-8s] " fmt "\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \ + zos_log("%08lu INFO [%-8s] " fmt "\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \ } #define ZLOGD(TAG, fmt, ...) \ if (g_enable_log) { \ iflytop::zlock_guard lock(glog_mutex); \ - printf("%08lu DEBU [%-8s] " fmt "\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \ + zos_log("%08lu DEBU [%-8s] " fmt "\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \ } #define ZLOGE(TAG, fmt, ...) \ if (g_enable_log) { \ iflytop::zlock_guard lock(glog_mutex); \ - printf("%08lu ERRO [%-8s] " fmt "\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \ + zos_log("%08lu ERRO [%-8s] " fmt "\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \ } #define ZLOGW(TAG, fmt, ...) \ if (g_enable_log) { \ iflytop::zlock_guard lock(glog_mutex); \ - printf("%08lu WARN [%-8s] " fmt "\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \ + zos_log("%08lu WARN [%-8s] " fmt "\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \ } #define ZASSERT(cond) \ if (!(cond)) { \ while (1) { \ - printf("ASSERT: %s [%s:%d]\n", #cond, __FILE__, __LINE__); \ + zos_log("ASSERT: %s [%s:%d]\n", #cond, __FILE__, __LINE__); \ zchip_clock_early_delayus(1000 * 1000); \ } \ } +void zos_log(const char* fmt, ...) ; void zos_loggger_init(); }