maix.comm

maix.comm module

You can use maix.comm to access this module with MaixPy
This module is generated from MaixPy and MaixCDK

Module

module brief
modbus maix.comm.modbus module

Enum

Variable

Function

add_default_comm_listener

Add default CommProtocol listener.\nWhen the application uses this port, the listening thread will immediately\nrelease the port resources and exit. If you need to start the default listening thread again,\nplease release the default port resources and then call this function.

C++ defination code:

void add_default_comm_listener()

rm_default_comm_listener

Remove default CommProtocol listener.

item description
return bool type.

C++ defination code:

bool rm_default_comm_listener()

Class

CommProtocol

Class for communication protocol

C++ defination code:

class CommProtocol

__init__

def __init__(self, buff_size: int = 1024, header: int = 3148663466) -> None

Construct a new CommProtocol object

item description
type func
param buff_size: buffer size, default to 1024 bytes
static False

C++ defination code:

CommProtocol(int buff_size = 1024, uint32_t header=maix::protocol::HEADER)

get_msg

def get_msg(self, timeout: int = 0) -> ...

Read data to buffer, and try to decode it as maix.protocol.MSG object

item description
type func
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++.
static False

C++ defination code:

protocol::MSG *get_msg(int timeout = 0)

resp_ok

def resp_ok(self, cmd: int, body: maix.Bytes(bytes) = None) -> maix.err.Err

Send response ok(success) message

item description
type func
param cmd: CMD value
body: response body, can be null
return encoded data, if nullptr, means error, and the error code is -err.Err.
Attentioin, delete it after use in C++.
static False

C++ defination code:

err::Err resp_ok(uint8_t cmd, Bytes *body = nullptr)

report

def report(self, cmd: int, body: maix.Bytes(bytes) = None) -> maix.err.Err

Send report message

item description
type func
param cmd: CMD value
body: report body, can be null
return encoded data, if nullptr, means error, and the error code is -err.Err.
Attentioin, delete it after use in C++.
static False

C++ defination code:

err::Err report(uint8_t cmd, Bytes *body = nullptr)

resp_err

def resp_err(self, cmd: int, code: maix.err.Err, msg: str) -> maix.err.Err

Encode response error message to buffer

item description
type func
param cmd: CMD value
code: error code
msg: error message
return encoded data, if nullptr, means error, and the error code is -err.Err.
Attentioin, delete it after use in C++.
static False

C++ defination code:

err::Err resp_err(uint8_t cmd, err::Err code, const std::string &msg)