tvm
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | List of all members
tvm::runtime::micro_rpc::Framer Class Reference

#include <framing.h>

Collaboration diagram for tvm::runtime::micro_rpc::Framer:

Public Types

typedef ssize_t(* WriteFunc) (const uint8_t *data, size_t data_size_bytes)
 

Public Member Functions

 Framer (WriteStream *stream)
 
tvm_crt_error_t Write (const uint8_t *payload, size_t payload_size_bytes)
 Frame and write a full packet. More...
 
tvm_crt_error_t StartPacket (size_t payload_size_bytes)
 Start framing and writing a new packet to the wire. More...
 
tvm_crt_error_t WritePayloadChunk (const uint8_t *payload_chunk, size_t payload_chunk_size_bytes)
 Write payload data to the wire. More...
 
tvm_crt_error_t FinishPacket ()
 
void Reset ()
 

Member Typedef Documentation

◆ WriteFunc

typedef ssize_t(* tvm::runtime::micro_rpc::Framer::WriteFunc) (const uint8_t *data, size_t data_size_bytes)

Constructor & Destructor Documentation

◆ Framer()

tvm::runtime::micro_rpc::Framer::Framer ( WriteStream stream)
inlineexplicit

Member Function Documentation

◆ FinishPacket()

tvm_crt_error_t tvm::runtime::micro_rpc::Framer::FinishPacket ( )

◆ Reset()

void tvm::runtime::micro_rpc::Framer::Reset ( )

◆ StartPacket()

tvm_crt_error_t tvm::runtime::micro_rpc::Framer::StartPacket ( size_t  payload_size_bytes)

Start framing and writing a new packet to the wire.

When transmitting payloads that are too large to be buffered, call this function first to send the packet header and length fields.

Parameters
payload_size_bytesNumber of payload bytes included as part of this packet.
Returns
  • kTvmErrorNoError when no error occurs
  • kTvmErrorWriteStreamShortWrite if the WriteStream passed to constructor's Write() function returns 0.
  • kTvmErrorWriteStreamShortWrite if the WriteStream passed to constructor's Write() function returns an invalid positive number.
  • Any negative value (i.e. with bits in kTvmErrorSystemErrorMask set) returned by the WriteStream's Write() function.

◆ Write()

tvm_crt_error_t tvm::runtime::micro_rpc::Framer::Write ( const uint8_t *  payload,
size_t  payload_size_bytes 
)

Frame and write a full packet.

Parameters
payloadThe entire packet payload.
payload_size_bytesNumber of bytes in the packet.
Returns
  • kTvmErrorNoError when no error occurs
  • kTvmErrorWriteStreamShortWrite if the WriteStream passed to constructor's Write() function returns 0.
  • kTvmErrorWriteStreamShortWrite if the WriteStream passed to constructor's Write() function returns an invalid positive number.
  • Any negative value (i.e. with bits in kTvmErrorSystemErrorMask set) returned by the WriteStream's Write() function.

◆ WritePayloadChunk()

tvm_crt_error_t tvm::runtime::micro_rpc::Framer::WritePayloadChunk ( const uint8_t *  payload_chunk,
size_t  payload_chunk_size_bytes 
)

Write payload data to the wire.

When transmitting payloads that are too large to be buffered, call this function after calling StartPacket to escape and transmit framed payloads. This function can be called multiple times for a single packet.

Parameters
payload_chunkA piece of the packet payload.
payload_chunk_size_bytesNumber of valid bytes in payload_chunk.
Returns
  • kTvmErrorNoError when no error occurs
  • kTvmErrorFramingInvalidState when StartPacket() has not been called.
  • kTvmErrorFramingPayloadOverflow when more bytes were requested to be written than were declared in the payload_size_bytes parameter given to StartPacket().
  • kTvmErrorWriteStreamShortWrite if the WriteStream passed to constructor's Write() function returns 0.
  • kTvmErrorWriteStreamShortWrite if the WriteStream passed to constructor's Write() function returns an invalid positive number.
  • Any negative value (i.e. with bits in kTvmErrorSystemErrorMask set) returned by the WriteStream's Write() function.

The documentation for this class was generated from the following file: