mirror of
https://github.com/sipeed/MaixCDK.git
synced 2026-09-15 06:03:02 -05:00
faster nn speed and fix default commprotocol high CPU occupy
This commit is contained in:
@@ -86,13 +86,15 @@ namespace maix
|
||||
uint8_t version;
|
||||
|
||||
/**
|
||||
* @brief Is success response or not, (only for response msg)
|
||||
* @brief Indicate response message type, true means CMD valid and the CMD processed correctly, (only for response msg)
|
||||
* @maixpy maix.protocol.MSG.resp_ok
|
||||
*/
|
||||
uint8_t resp_ok;
|
||||
|
||||
/**
|
||||
* @brief Whether or not it has been replied to.
|
||||
* @brief Flag whether CMD has been processed and responded to CMD sender.
|
||||
* E.g. CMD CMD_START_APP will be automatically processed in CommProtocol.get_msg function,
|
||||
* so the return msg will set this flag to true.
|
||||
* @maixpy maix.protocol.MSG.has_been_replied
|
||||
*/
|
||||
bool has_been_replied{false};
|
||||
|
||||
@@ -509,7 +509,7 @@ namespace maix
|
||||
{
|
||||
if(copy)
|
||||
{
|
||||
tensor::Tensor *t = new tensor::Tensor(*tensor);
|
||||
tensor::Tensor *t = new tensor::Tensor(tensor->shape(), tensor->dtype(), tensor->data(), true);
|
||||
tensors[key] = t;
|
||||
_auto_delete[key] = true;
|
||||
}
|
||||
|
||||
@@ -38,12 +38,11 @@ namespace maix
|
||||
/**
|
||||
* @brief Remove default CommProtocol listener.
|
||||
*
|
||||
* @param blocking True means blocking and false means non-blocking.
|
||||
* @return bool type.
|
||||
*
|
||||
* @maixpy maix.comm.rm_default_comm_listener
|
||||
*/
|
||||
bool rm_default_comm_listener(bool blocking=false);
|
||||
bool rm_default_comm_listener();
|
||||
|
||||
/**
|
||||
* Class for communication protocol
|
||||
@@ -63,11 +62,12 @@ namespace maix
|
||||
|
||||
/**
|
||||
* Read data to buffer, and try to decode it as maix.protocol.MSG object
|
||||
* @param timeout unit ms, 0 means return immediatly, -1 means block util have msg, >0 means block until have msg or timeout.
|
||||
* @return decoded data, if nullptr, means no valid frame found.
|
||||
* Attentioin, delete it after use in C++.
|
||||
* @maixpy maix.comm.CommProtocol.get_msg
|
||||
*/
|
||||
protocol::MSG *get_msg();
|
||||
protocol::MSG *get_msg(int timeout = 0);
|
||||
|
||||
/**
|
||||
* Send response ok(success) message
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -369,7 +369,7 @@ namespace maix::peripheral::uart
|
||||
{
|
||||
data = uart->read(-1, -1);
|
||||
}
|
||||
catch(err::Exception)
|
||||
catch(const err::Exception& e)
|
||||
{
|
||||
log::error("read file failed");
|
||||
break;
|
||||
@@ -527,8 +527,13 @@ namespace maix::peripheral::uart
|
||||
{
|
||||
int wait_time = _one_byte_time_us * 30; // system maybe use some time
|
||||
time::sleep_us(wait_time > 50000 ? 50000: wait_time);
|
||||
if (available(0) > 0 || (timeout < 0 && read_len == 0))
|
||||
if (available(0) > 0)
|
||||
continue;
|
||||
if (timeout < 0 && read_len == 0) // block read
|
||||
{
|
||||
available(-1);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ update:
|
||||
|
||||
## 数据帧
|
||||
|
||||
| | header(4B LE) | data len(4B LE)(version+cmd+body+crc) |flags(1B) | cmd(1B) | body(nB) | CRC16_IBM(2B LE)(前面所有) |
|
||||
| | header(4B LE) | data len(4B LE)(flags+cmd+body+crc) |flags(1B) | cmd(1B) | body(nB) | CRC16_IBM(2B LE)(前面所有) |
|
||||
| ------------- | ---------- | ---------------------------- | ------------------ | ------- | ---------------- | ---------------------- |
|
||||
| 十进制示例 | 3148663466 | 9 | 0 | 1 | hello | 17451 |
|
||||
| 十六进制示例 | 0xBBACCAAA | 0x00000009 | 0x00 | 0x01 | hello | 0x442B |
|
||||
@@ -48,7 +48,7 @@ update:
|
||||
> 这里的例子,最终发送数据: `AA CA AC BB 09 00 00 00 00 01 68 65 6c 6c 6F 2B 44`。
|
||||
|
||||
* `header`: 头,4 字节,用来标识一帧的开始,固定为 4 字节 `0xAA 0xCA 0xAC 0xBB`, 先发`0xAA`
|
||||
* `data len`: 数据长度, 4 字节, 包含了 `version` `cmd` + `body` + `CRC` 的长度。
|
||||
* `data len`: 数据长度, 4 字节, 包含了 `flags` `cmd` + `body` + `CRC` 的长度。
|
||||
* `flags`: 一个字节,各个位分别表示:
|
||||
* 最高位 `is_resp`: 是否是响应,`0`代表发送请求,`1`代表 响应 或者 主动上报(第三高位需要置`1`)。
|
||||
* 第二高位 `resp_ok`:
|
||||
|
||||
Reference in New Issue
Block a user