Browse Source

add new api

master
zhaohe 2 years ago
parent
commit
11b2ea877c
  1. 28
      components/zcan_module/zcan_pump_ctrl_module.cpp
  2. 2
      components/zcan_module/zcan_pump_ctrl_module.hpp

28
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;

2
components/zcan_module/zcan_pump_ctrl_module.hpp

@ -12,7 +12,7 @@ namespace iflytop {
class ZCanPumpCtrlModule : public ZCanRceiverListener {
public:
typedef function<void(int16_t acc, int16_t rpm)> pumprun_t;
typedef function<void(int16_t acc, int16_t rpm, int16_t idlepower, int16_t power)> pumprun_t;
class Submodule {
public:

Loading…
Cancel
Save