|
|
@ -75,20 +75,6 @@ void ZCanHost::initialize(string can_if_name, int baudrate, bool enablLoopback) |
|
|
|
logger->error("hpp272_read_c1000 fail"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
// int16_t hydrogen_peroxide_volume; // ppm 0x0100
|
|
|
|
// int16_t h2o_h2o2_rs; // %RS * 100
|
|
|
|
// int16_t temperature1; // °C * 100
|
|
|
|
// int16_t relative_humidity; // %RH * 100
|
|
|
|
// int16_t absolute_hydrogen_peroxide; // mg/m3
|
|
|
|
// int16_t h2o_h2o2dew_point_temperature; // °C * 100
|
|
|
|
// int16_t reserved1; //
|
|
|
|
// int16_t water_volume; // ppm
|
|
|
|
// int16_t water_vapor_pressure; // hpa
|
|
|
|
// int16_t absolute_humidity; // g/m3
|
|
|
|
// int16_t water_vapor_saturation_pressure_h2o; // hpa
|
|
|
|
// int16_t temperature2; // °C * 100
|
|
|
|
// int16_t h2o2_vapor_pressure; // hpa
|
|
|
|
// int16_t water_vapor_saturation_pressure_h2o_h2o2; // hpa
|
|
|
|
logger->info("hpp272_read_c1000 {}:", id); |
|
|
|
logger->info(" hydrogen_peroxide_volume :{}", v.hydrogen_peroxide_volume); |
|
|
|
logger->info(" h2o_h2o2_rs :{}", v.h2o_h2o2_rs); |
|
|
@ -218,7 +204,7 @@ bool ZCanHost::execcmd(string cmd, string& retval) { |
|
|
|
/**
|
|
|
|
* @brief 0-1000 Command support |
|
|
|
*/ |
|
|
|
bool ZCanHost::ping(int board_id) { |
|
|
|
int32_t ZCanHost::ping(int board_id) { |
|
|
|
shared_ptr<ZCanReceiverCMD> cmd = make_shared<ZCanReceiverCMD>(); |
|
|
|
cmd->cmdid = 0; |
|
|
|
cmd->subcmdid = 0; |
|
|
@ -226,14 +212,14 @@ bool ZCanHost::ping(int board_id) { |
|
|
|
cmd->len = 1; |
|
|
|
auto rx = m_zcanReceiverHost->sendcmdblock(cmd, 100); |
|
|
|
if (rx == nullptr) { |
|
|
|
return false; |
|
|
|
return err::zecode(err::knoack); |
|
|
|
} |
|
|
|
if (rx->packetType == kpt_error_ack) { |
|
|
|
logger->error("ping error ack,{}", *zuint16p(&rx->data[0])); |
|
|
|
return false; |
|
|
|
return err::zecode(err::kfail); |
|
|
|
} |
|
|
|
|
|
|
|
return rx != nullptr; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
int32_t ZCanHost::readio(int id, bool& value) { |
|
|
@ -292,7 +278,7 @@ int32_t ZCanHost::readadc(int id, int& value) { |
|
|
|
} |
|
|
|
|
|
|
|
// 1004
|
|
|
|
bool ZCanHost::pumpctrl_c1004(int sensorid, int16_t acc, int16_t rpm) { |
|
|
|
int32_t ZCanHost::pumpctrl_c1004(int sensorid, int16_t acc, int16_t rpm) { |
|
|
|
shared_ptr<ZCanReceiverCMD> cmd = make_shared<ZCanReceiverCMD>(); |
|
|
|
cmd->cmdid = 1004; |
|
|
|
cmd->subcmdid = 0; |
|
|
@ -301,12 +287,15 @@ bool ZCanHost::pumpctrl_c1004(int sensorid, int16_t acc, int16_t rpm) { |
|
|
|
*zint16p(&cmd->data[4]) = rpm; |
|
|
|
cmd->len = 6; |
|
|
|
auto rx = m_zcanReceiverHost->sendcmdblock(cmd, 100); |
|
|
|
if (rx == nullptr) { |
|
|
|
return err::zecode(err::knoack); |
|
|
|
} |
|
|
|
if (rx->packetType == kpt_error_ack) { |
|
|
|
logger->error("pumpctrl_c1004 error ack,{}", *zuint16p(&rx->data[0])); |
|
|
|
return false; |
|
|
|
return err::zecode(err::kfail); |
|
|
|
} |
|
|
|
|
|
|
|
return rx != nullptr; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
/**
|
|
|
@ -318,7 +307,7 @@ bool ZCanHost::pumpctrl_c1004(int sensorid, int16_t acc, int16_t rpm) { |
|
|
|
* @param b |
|
|
|
* @param w |
|
|
|
*/ |
|
|
|
bool ZCanHost::warning_light_ctrl_c1002(uint8_t sensorid, uint8_t r, uint8_t g, uint8_t b, uint8_t w) { |
|
|
|
int32_t ZCanHost::warning_light_ctrl_c1002(uint8_t sensorid, uint8_t r, uint8_t g, uint8_t b, uint8_t w) { |
|
|
|
shared_ptr<ZCanReceiverCMD> cmd = make_shared<ZCanReceiverCMD>(); |
|
|
|
cmd->cmdid = 1002; |
|
|
|
cmd->subcmdid = 0; |
|
|
@ -331,12 +320,16 @@ bool ZCanHost::warning_light_ctrl_c1002(uint8_t sensorid, uint8_t r, uint8_t g, |
|
|
|
|
|
|
|
auto rx = m_zcanReceiverHost->sendcmdblock(cmd, 100); |
|
|
|
|
|
|
|
if (!rx) { |
|
|
|
return err::zecode(err::knoack); |
|
|
|
} |
|
|
|
|
|
|
|
if (rx->packetType == kpt_error_ack) { |
|
|
|
logger->error("warning_light_ctrl_c1002 error ack,{}", *zuint16p(&rx->data[0])); |
|
|
|
return false; |
|
|
|
return err::zecode(err::kfail); |
|
|
|
} |
|
|
|
|
|
|
|
return rx != nullptr; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
/**
|
|
|
@ -346,7 +339,7 @@ bool ZCanHost::warning_light_ctrl_c1002(uint8_t sensorid, uint8_t r, uint8_t g, |
|
|
|
* @param value |
|
|
|
*/ |
|
|
|
|
|
|
|
bool ZCanHost::huacheng_pressure_sensor_read_c1005(int sensorid, huacheng_pressure_sensor_read_c1005_t& value) { |
|
|
|
int32_t ZCanHost::huacheng_pressure_sensor_read_c1005(int sensorid, huacheng_pressure_sensor_read_c1005_t& value) { |
|
|
|
/**
|
|
|
|
* @brief |
|
|
|
*/ |
|
|
@ -358,15 +351,18 @@ bool ZCanHost::huacheng_pressure_sensor_read_c1005(int sensorid, huacheng_pressu |
|
|
|
cmd->len = 2; |
|
|
|
|
|
|
|
auto rx = m_zcanReceiverHost->sendcmdblock(cmd, 100); |
|
|
|
if (!rx) { |
|
|
|
return err::zecode(err::knoack); |
|
|
|
} |
|
|
|
|
|
|
|
if (rx->packetType == kpt_error_ack) { |
|
|
|
logger->error("huacheng_pressure_sensor_read_c1005 error ack"); |
|
|
|
return false; |
|
|
|
return err::zecode(err::kfail); |
|
|
|
} |
|
|
|
|
|
|
|
if (rx->len != 10) { |
|
|
|
logger->warn("huacheng_pressure_sensor_read_c1005 rx len error:{}", rx->len); |
|
|
|
return false; |
|
|
|
return err::zecode(err::kfail); |
|
|
|
} |
|
|
|
|
|
|
|
value.precision = rx->data[2]; |
|
|
@ -375,28 +371,31 @@ bool ZCanHost::huacheng_pressure_sensor_read_c1005(int sensorid, huacheng_pressu |
|
|
|
value.zero = *(int16_t*)(&rx->data[6]); |
|
|
|
value.full = *(int16_t*)(&rx->data[8]); |
|
|
|
|
|
|
|
return rx != nullptr; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
bool ZCanHost::hpp272_read_c1000(int sensorid, hpp272_data_t& value) { |
|
|
|
int32_t ZCanHost::hpp272_read_c1000(int sensorid, hpp272_data_t& value) { |
|
|
|
shared_ptr<ZCanReceiverCMD> cmd = make_shared<ZCanReceiverCMD>(); |
|
|
|
cmd->cmdid = 1000; |
|
|
|
cmd->subcmdid = 0; |
|
|
|
cmd->data[0] = sensorid; |
|
|
|
cmd->len = 2; |
|
|
|
|
|
|
|
auto rx = m_zcanReceiverHost->sendcmdblock(cmd, 100); |
|
|
|
auto rx = m_zcanReceiverHost->sendcmdblock(cmd, 300); |
|
|
|
if (!rx) { |
|
|
|
logger->error("hpp272_read_c1000 timeout"); |
|
|
|
return err::zecode(err::knoack); |
|
|
|
} |
|
|
|
|
|
|
|
if (rx->packetType == kpt_error_ack) { |
|
|
|
logger->error("hpp272_read_c1000 error ack"); |
|
|
|
return false; |
|
|
|
return err::zecode(err::kfail); |
|
|
|
} |
|
|
|
|
|
|
|
if (rx->len != sizeof(hpp272_data_t) + 2) { |
|
|
|
logger->warn("hpp272_read_c1000 rx len error:{}!=", rx->len, sizeof(hpp272_data_t) + 2); |
|
|
|
return false; |
|
|
|
return err::zecode(err::kfail); |
|
|
|
} |
|
|
|
|
|
|
|
memcpy(&value, &rx->data[2], sizeof(hpp272_data_t)); |
|
|
|
return rx != nullptr; |
|
|
|
return 0; |
|
|
|
} |