From 11b2ea877c103523e857108c1a521f2755700dac Mon Sep 17 00:00:00 2001 From: zhaohe Date: Tue, 15 Aug 2023 23:03:33 +0800 Subject: [PATCH] add new api --- components/zcan_module/zcan_pump_ctrl_module.cpp | 28 +++++++++++++++++++++++- components/zcan_module/zcan_pump_ctrl_module.hpp | 2 +- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/components/zcan_module/zcan_pump_ctrl_module.cpp b/components/zcan_module/zcan_pump_ctrl_module.cpp index 205635a..6f965f9 100644 --- a/components/zcan_module/zcan_pump_ctrl_module.cpp +++ b/components/zcan_module/zcan_pump_ctrl_module.cpp @@ -41,7 +41,33 @@ void ZCanPumpCtrlModule::onRceivePacket(CanPacketRxBuffer* rxbuf, uint8_t* packe int16_t acc = *(int16_t*)(&cmdheader->data[2]); int16_t rpm = *(int16_t*)(&cmdheader->data[4]); - subm->m_pumprun_fn(acc, rpm); + subm->m_pumprun_fn(acc, rpm, -1, -1); + + uint8_t txbuff[1] = {}; + txbuff[0] = id; + m_zcanReceiver->sendAck(cmdheader, txbuff, sizeof(txbuff)); + return; + } + } + + if (cmdheader->cmdid == kcmd_peristaltic_pump_ctl && cmdheader->subcmdid == 1) { + /** + * @brief + * cmd: + * [0]:蠕动泵ID + * [2:3]:acc [4:5]:转速rpm [6]: 功率 + * ack : b0:pumpid + * ack_datalen : 1 + */ + uint8_t id = cmdheader->data[0]; + Submodule* subm = find(id); + if (subm) { + int16_t acc = *(int16_t*)(&cmdheader->data[2]); + int16_t rpm = *(int16_t*)(&cmdheader->data[4]); + int16_t idlepower = cmdheader->data[6]; + int16_t power = cmdheader->data[7]; + + subm->m_pumprun_fn(acc, rpm, idlepower, power); uint8_t txbuff[1] = {}; txbuff[0] = id; diff --git a/components/zcan_module/zcan_pump_ctrl_module.hpp b/components/zcan_module/zcan_pump_ctrl_module.hpp index b6ef99f..c65567d 100644 --- a/components/zcan_module/zcan_pump_ctrl_module.hpp +++ b/components/zcan_module/zcan_pump_ctrl_module.hpp @@ -12,7 +12,7 @@ namespace iflytop { class ZCanPumpCtrlModule : public ZCanRceiverListener { public: - typedef function pumprun_t; + typedef function pumprun_t; class Submodule { public: