tvm
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Typedefs | Functions
microtvm_rpc_server.h File Reference

MicroTVM RPC Server. More...

#include <stdlib.h>
#include <sys/types.h>
#include <tvm/runtime/crt/error_codes.h>
#include "../../../../src/support/ssize.h"
Include dependency graph for microtvm_rpc_server.h:

Go to the source code of this file.

Typedefs

typedef ssize_t(* microtvm_rpc_channel_write_t) (void *context, const uint8_t *data, size_t num_bytes)
 TVM RPC channel write function. More...
 
typedef void * microtvm_rpc_server_t
 Opaque pointer type to TVM RPC Server. More...
 

Functions

microtvm_rpc_server_t MicroTVMRpcServerInit (microtvm_rpc_channel_write_t write_func, void *write_func_ctx)
 Initialize the TVM RPC Server. More...
 
tvm_crt_error_t MicroTVMRpcServerLoop (microtvm_rpc_server_t server, uint8_t **new_data, size_t *new_data_size_bytes)
 Do any tasks suitable for the main thread, and maybe process new incoming data. More...
 

Detailed Description

MicroTVM RPC Server.

Typedef Documentation

◆ microtvm_rpc_channel_write_t

typedef ssize_t(* microtvm_rpc_channel_write_t) (void *context, const uint8_t *data, size_t num_bytes)

TVM RPC channel write function.

Tries to write num_bytes from data to the underlying channel.

Parameters
contextThe context.
dataPointer to data to write.
num_bytesNumber of bytes avaiable in data.
Returns
The number of bytes written.

◆ microtvm_rpc_server_t

typedef void* microtvm_rpc_server_t

Opaque pointer type to TVM RPC Server.

Function Documentation

◆ MicroTVMRpcServerInit()

microtvm_rpc_server_t MicroTVMRpcServerInit ( microtvm_rpc_channel_write_t  write_func,
void *  write_func_ctx 
)

Initialize the TVM RPC Server.

Call this on device startup before calling anyother microtvm_rpc_server_ functions.

Parameters
write_funcA callback function invoked by the TVM RPC Server to write data back to the host. Internally, the TVM RPC Server will block until all data in a reply packet has been written.
write_func_ctxAn opaque pointer passed to write_func when it is called.
Returns
A pointer to the TVM RPC Server. The pointer is allocated in the same memory space as the TVM workspace.

◆ MicroTVMRpcServerLoop()

tvm_crt_error_t MicroTVMRpcServerLoop ( microtvm_rpc_server_t  server,
uint8_t **  new_data,
size_t *  new_data_size_bytes 
)

Do any tasks suitable for the main thread, and maybe process new incoming data.

Parameters
serverThe TVM RPC Server pointer.
new_dataIf not nullptr, a pointer to a buffer pointer, which should point at new input data to process. On return, updated to point past data that has been consumed.
new_data_size_bytesPoints to the number of valid bytes in new_data. On return, updated to the number of unprocessed bytes remaining in new_data (usually 0).
Returns
An error code indicating the outcome of the server main loop iteration.