Browse Source

update

update_protocol
zhaohe 5 months ago
parent
commit
dbe3d5692a
  1. 2
      api/api.hpp
  2. 1
      api/apibasic/errorcode.hpp
  3. 22
      api/apibasic/packet_interface.hpp
  4. 11
      api/zi_pipette_ctrl_module.hpp
  5. 2
      i_zcanreceiver.hpp
  6. 4
      protocol.hpp
  7. 24
      reg_index_table.cpp
  8. 13
      reg_index_table.hpp

2
api/api.hpp

@ -13,8 +13,6 @@
//
#include "zi_a8000_optical_module.hpp"
//
#include "zi_pipette_ctrl_module.hpp"
//
#include "zi_mini_servo.hpp"
//
#include "zi_board.hpp"

1
api/apibasic/errorcode.hpp

@ -20,6 +20,7 @@ typedef enum {
knoack = 1107,
kerrorack = 1108,
kdevice_offline = 1109,
kcheck_sum_error = 1110,
ksubdevice_overtime = 1111,
kbuffer_not_enough = 1112,

22
api/apibasic/packet_interface.hpp

@ -22,8 +22,26 @@ typedef enum {
kptv2_event = 3,
} zcan_cmd_packet_type_t;
static inline bool zcr_cmd_checkpacket(const zcr_cmd_header_t* header, int len) {
if (len < sizeof(zcr_cmd_header_t)) {
return false;
}
if ((header->datalen + sizeof(zcr_cmd_header_t) + 1) != len) {
return false;
}
} // namespace zcr
} // namespace iflytop
uint8_t* rawpacket = (uint8_t*)header;
uint8_t checksum = 0;
for (int i = 0; i < len - 1; i++) {
checksum += rawpacket[i];
}
if (checksum != rawpacket[len - 1]) {
return false;
}
return true;
}
} // namespace zcr
} // namespace iflytop

11
api/zi_pipette_ctrl_module.hpp

@ -1,11 +0,0 @@
#pragma once
#include <stdint.h>
#include <functional>
#include "apibasic/basic.hpp"
namespace iflytop {
using namespace std;
} // namespace iflytop

2
i_zcanreceiver.hpp

@ -9,7 +9,7 @@ using namespace zcr;
class IZCanReceiverListener {
public:
virtual void onRceivePacket(zcr_cmd_header_t *rxcmd, uint8_t *data, int32_t len) = 0;
virtual void onRceivePacket(zcr_cmd_header_t *rxcmd, int32_t len) = 0;
};
class IZCanReceiver {

4
protocol.hpp

@ -1,6 +1,4 @@
#pragma once
#include "api/api.hpp"
//
#include "i_zcanreceiver.hpp"
//
#include "reg_index_table.hpp"
#include "i_zcanreceiver.hpp"

24
reg_index_table.cpp

@ -1,24 +0,0 @@
#include "reg_index_table.hpp"
#include <stdlib.h>
#include <string.h>
#include "api/api.hpp"
using namespace iflytop;
static reg_index_table_iterm_t iterms[] = {};
namespace iflytop {
void reg_index_table_get(reg_index_table_iterm_t** table, int32_t* size) {
*size = sizeof(iterms) / sizeof(iterms[0]);
*table = iterms;
}
int32_t str_to_reg_index(const char* val) {
for (int32_t i = 0; i < sizeof(iterms) / sizeof(iterms[0]); i++) {
if (strcmp(iterms[i].name, val) == 0) {
return iterms[i].index;
}
}
return atoi(val);
}
} // namespace iflytop

13
reg_index_table.hpp

@ -1,13 +0,0 @@
#pragma once
#include <stdint.h>
namespace iflytop {
typedef struct {
const char* name;
int32_t index;
} reg_index_table_iterm_t;
void reg_index_table_get(reg_index_table_iterm_t** table, int32_t* size);
int32_t str_to_reg_index(const char* val);
} // namespace iflytop
Loading…
Cancel
Save