WPILibC++
2019.1.1-beta-4-32-g6bdd7ce
|
Typedefs | |
typedef void(* | NT_RpcCallback )(void *data, const struct NT_RpcAnswer *call) |
Remote Procedure Call (RPC) callback function. More... | |
Functions | |
void | NT_CreateRpc (NT_Entry entry, const char *def, size_t def_len, void *data, NT_RpcCallback callback) |
Create a callback-based RPC entry point. More... | |
NT_RpcCallPoller | NT_CreateRpcCallPoller (NT_Inst inst) |
Create a RPC call poller. More... | |
void | NT_DestroyRpcCallPoller (NT_RpcCallPoller poller) |
Destroy a RPC call poller. More... | |
void | NT_CreatePolledRpc (NT_Entry entry, const char *def, size_t def_len, NT_RpcCallPoller poller) |
Create a polled RPC entry point. More... | |
struct NT_RpcAnswer * | NT_PollRpc (NT_RpcCallPoller poller, size_t *len) |
Get the next incoming RPC call. More... | |
struct NT_RpcAnswer * | NT_PollRpcTimeout (NT_RpcCallPoller poller, size_t *len, double timeout, NT_Bool *timed_out) |
Get the next incoming RPC call. More... | |
void | NT_CancelPollRpc (NT_RpcCallPoller poller) |
Cancel a PollRpc call. More... | |
NT_Bool | NT_WaitForRpcCallQueue (NT_Inst inst, double timeout) |
Wait for the incoming RPC call queue to be empty. More... | |
NT_Bool | NT_PostRpcResponse (NT_Entry entry, NT_RpcCall call, const char *result, size_t result_len) |
Post RPC response (return value) for a polled RPC. More... | |
NT_RpcCall | NT_CallRpc (NT_Entry entry, const char *params, size_t params_len) |
Call a RPC function. More... | |
char * | NT_GetRpcResult (NT_Entry entry, NT_RpcCall call, size_t *result_len) |
Get the result (return value) of a RPC call. More... | |
char * | NT_GetRpcResultTimeout (NT_Entry entry, NT_RpcCall call, size_t *result_len, double timeout, NT_Bool *timed_out) |
Get the result (return value) of a RPC call. More... | |
void | NT_CancelRpcResult (NT_Entry entry, NT_RpcCall call) |
Ignore the result of a RPC call. More... | |
char * | NT_PackRpcDefinition (const struct NT_RpcDefinition *def, size_t *packed_len) |
Pack a RPC version 1 definition. More... | |
NT_Bool | NT_UnpackRpcDefinition (const char *packed, size_t packed_len, struct NT_RpcDefinition *def) |
Unpack a RPC version 1 definition. More... | |
char * | NT_PackRpcValues (const struct NT_Value **values, size_t values_len, size_t *packed_len) |
Pack RPC values as required for RPC version 1 definition messages. More... | |
struct NT_Value ** | NT_UnpackRpcValues (const char *packed, size_t packed_len, const enum NT_Type *types, size_t types_len) |
Unpack RPC values as required for RPC version 1 definition messages. More... | |
typedef void(* NT_RpcCallback)(void *data, const struct NT_RpcAnswer *call) |
Remote Procedure Call (RPC) callback function.
data | data pointer provided to NT_CreateRpc() |
call | call information |
Note: NT_PostRpcResponse() must be called by the callback to provide a response to the call.
NT_RpcCall NT_CallRpc | ( | NT_Entry | entry, |
const char * | params, | ||
size_t | params_len | ||
) |
Call a RPC function.
May be used on either the client or server.
This function is non-blocking. Either NT_GetRpcResult() or NT_CancelRpcResult() must be called to either get or ignore the result of the call.
entry | entry handle of RPC entry |
params | parameter |
params_len | length of param in bytes |
void NT_CancelPollRpc | ( | NT_RpcCallPoller | poller | ) |
Cancel a PollRpc call.
This wakes up a call to PollRpc for this poller and causes it to immediately return an empty array.
poller | poller handle |
void NT_CancelRpcResult | ( | NT_Entry | entry, |
NT_RpcCall | call | ||
) |
Ignore the result of a RPC call.
This function is non-blocking.
entry | entry handle of RPC entry |
call | RPC call handle returned by NT_CallRpc() |
void NT_CreatePolledRpc | ( | NT_Entry | entry, |
const char * | def, | ||
size_t | def_len, | ||
NT_RpcCallPoller | poller | ||
) |
Create a polled RPC entry point.
Only valid to use on the server.
The caller is responsible for calling NT_PollRpc() or NT_PollRpcTimeout() to poll for servicing incoming RPC calls.
entry | entry handle of RPC entry |
def | RPC definition |
def_len | length of def in bytes |
poller | poller handle |
void NT_CreateRpc | ( | NT_Entry | entry, |
const char * | def, | ||
size_t | def_len, | ||
void * | data, | ||
NT_RpcCallback | callback | ||
) |
Create a callback-based RPC entry point.
Only valid to use on the server. The callback function will be called when the RPC is called.
entry | entry handle of RPC entry |
def | RPC definition |
def_len | length of def in bytes |
data | data pointer to pass to callback function |
callback | callback function |
NT_RpcCallPoller NT_CreateRpcCallPoller | ( | NT_Inst | inst | ) |
Create a RPC call poller.
Only valid to use on the server.
A poller provides a single queue of poll events. Events linked to this poller (using NT_CreatePolledRpc()) will be stored in the queue and must be collected by calling NT_PollRpc() or NT_PollRpcTimeout(). The returned handle must be destroyed with NT_DestroyRpcCallPoller().
inst | instance handle |
void NT_DestroyRpcCallPoller | ( | NT_RpcCallPoller | poller | ) |
Destroy a RPC call poller.
This will abort any blocked polling call and prevent additional events from being generated for this poller.
poller | poller handle |
char* NT_GetRpcResult | ( | NT_Entry | entry, |
NT_RpcCall | call, | ||
size_t * | result_len | ||
) |
Get the result (return value) of a RPC call.
This function blocks until the result is received.
entry | entry handle of RPC entry |
call | RPC call handle returned by NT_CallRpc() |
result_len | length of returned result in bytes |
char* NT_GetRpcResultTimeout | ( | NT_Entry | entry, |
NT_RpcCall | call, | ||
size_t * | result_len, | ||
double | timeout, | ||
NT_Bool * | timed_out | ||
) |
Get the result (return value) of a RPC call.
This function blocks until the result is received or it times out.
entry | entry handle of RPC entry |
call | RPC call handle returned by NT_CallRpc() |
result_len | length of returned result in bytes |
timeout | timeout, in seconds |
timed_out | true if the timeout period elapsed (output) |
char* NT_PackRpcDefinition | ( | const struct NT_RpcDefinition * | def, |
size_t * | packed_len | ||
) |
Pack a RPC version 1 definition.
def | RPC version 1 definition |
packed_len | length of return value in bytes |
char* NT_PackRpcValues | ( | const struct NT_Value ** | values, |
size_t | values_len, | ||
size_t * | packed_len | ||
) |
Pack RPC values as required for RPC version 1 definition messages.
values | array of values to pack |
values_len | length of values |
packed_len | length of return value in bytes |
struct NT_RpcAnswer* NT_PollRpc | ( | NT_RpcCallPoller | poller, |
size_t * | len | ||
) |
Get the next incoming RPC call.
This blocks until the next incoming RPC call is received. This is intended to be used with NT_CreatePolledRpc(void); RPC calls created using NT_CreateRpc() will not be serviced through this function. Upon successful return, NT_PostRpcResponse() must be called to send the return value to the caller. The returned array must be freed using NT_DisposeRpcAnswerArray().
poller | poller handle |
len | length of returned array (output) |
struct NT_RpcAnswer* NT_PollRpcTimeout | ( | NT_RpcCallPoller | poller, |
size_t * | len, | ||
double | timeout, | ||
NT_Bool * | timed_out | ||
) |
Get the next incoming RPC call.
This blocks until the next incoming RPC call is received or it times out. This is intended to be used with NT_CreatePolledRpc(); RPC calls created using NT_CreateRpc() will not be serviced through this function. Upon successful return, NT_PostRpcResponse() must be called to send the return value to the caller. The returned array must be freed using NT_DisposeRpcAnswerArray().
poller | poller handle |
len | length of returned array (output) |
timeout | timeout, in seconds |
timed_out | true if the timeout period elapsed (output) |
NT_Bool NT_PostRpcResponse | ( | NT_Entry | entry, |
NT_RpcCall | call, | ||
const char * | result, | ||
size_t | result_len | ||
) |
Post RPC response (return value) for a polled RPC.
The rpc and call parameters should come from the NT_RpcAnswer returned by NT_PollRpc().
entry | entry handle of RPC entry (from NT_RpcAnswer) |
call | RPC call handle (from NT_RpcAnswer) |
result | result raw data that will be provided to remote caller |
result_len | length of result in bytes |
NT_Bool NT_UnpackRpcDefinition | ( | const char * | packed, |
size_t | packed_len, | ||
struct NT_RpcDefinition * | def | ||
) |
Unpack a RPC version 1 definition.
This can be used for introspection or validation.
packed | raw packed bytes |
packed_len | length of packed in bytes |
def | RPC version 1 definition (output) |
struct NT_Value** NT_UnpackRpcValues | ( | const char * | packed, |
size_t | packed_len, | ||
const enum NT_Type * | types, | ||
size_t | types_len | ||
) |
Unpack RPC values as required for RPC version 1 definition messages.
packed | raw packed bytes |
packed_len | length of packed in bytes |
types | array of data types (as provided in the RPC definition) |
types_len | length of types |
NT_Bool NT_WaitForRpcCallQueue | ( | NT_Inst | inst, |
double | timeout | ||
) |
Wait for the incoming RPC call queue to be empty.
This is primarily useful for deterministic testing. This blocks until either the RPC call queue is empty (e.g. there are no more events that need to be passed along to callbacks or poll queues) or the timeout expires.
inst | instance handle |
timeout | timeout, in seconds. Set to 0 for non-blocking behavior, or a negative value to block indefinitely |