WPILibC++  2019.3.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
ntcore_c.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2015-2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #ifndef NTCORE_NTCORE_C_H_
9 #define NTCORE_NTCORE_C_H_
10 
11 #include <stdint.h>
12 
13 #ifdef __cplusplus
14 #include <cstddef>
15 #else
16 #include <stddef.h>
17 #endif
18 
19 #include <wpi/deprecated.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
34 typedef int NT_Bool;
35 
36 typedef unsigned int NT_Handle;
37 typedef NT_Handle NT_ConnectionListener;
38 typedef NT_Handle NT_ConnectionListenerPoller;
39 typedef NT_Handle NT_Entry;
40 typedef NT_Handle NT_EntryListener;
41 typedef NT_Handle NT_EntryListenerPoller;
42 typedef NT_Handle NT_Inst;
43 typedef NT_Handle NT_Logger;
44 typedef NT_Handle NT_LoggerPoller;
45 typedef NT_Handle NT_RpcCall;
46 typedef NT_Handle NT_RpcCallPoller;
47 
49 #define NT_DEFAULT_PORT 1735
50 
52 enum NT_Type {
53  NT_UNASSIGNED = 0,
54  NT_BOOLEAN = 0x01,
55  NT_DOUBLE = 0x02,
56  NT_STRING = 0x04,
57  NT_RAW = 0x08,
58  NT_BOOLEAN_ARRAY = 0x10,
59  NT_DOUBLE_ARRAY = 0x20,
60  NT_STRING_ARRAY = 0x40,
61  NT_RPC = 0x80
62 };
63 
65 enum NT_EntryFlags { NT_PERSISTENT = 0x01 };
66 
69  NT_LOG_CRITICAL = 50,
70  NT_LOG_ERROR = 40,
71  NT_LOG_WARNING = 30,
72  NT_LOG_INFO = 20,
73  NT_LOG_DEBUG = 10,
74  NT_LOG_DEBUG1 = 9,
75  NT_LOG_DEBUG2 = 8,
76  NT_LOG_DEBUG3 = 7,
77  NT_LOG_DEBUG4 = 6
78 };
79 
82  NT_NOTIFY_NONE = 0,
83  NT_NOTIFY_IMMEDIATE = 0x01, /* initial listener addition */
84  NT_NOTIFY_LOCAL = 0x02, /* changed locally */
85  NT_NOTIFY_NEW = 0x04, /* newly created entry */
86  NT_NOTIFY_DELETE = 0x08, /* deleted */
87  NT_NOTIFY_UPDATE = 0x10, /* value changed */
88  NT_NOTIFY_FLAGS = 0x20 /* flags changed */
89 };
90 
93  NT_NET_MODE_NONE = 0x00, /* not running */
94  NT_NET_MODE_SERVER = 0x01, /* running in server mode */
95  NT_NET_MODE_CLIENT = 0x02, /* running in client mode */
96  NT_NET_MODE_STARTING = 0x04, /* flag for starting (either client or server) */
97  NT_NET_MODE_FAILURE = 0x08, /* flag for failure (either client or server) */
98 };
99 
100 /*
101  * Structures
102  */
103 
105 struct NT_String {
112  char* str;
113 
118  size_t len;
119 };
120 
122 struct NT_Value {
123  enum NT_Type type;
124  uint64_t last_change;
125  union {
126  NT_Bool v_boolean;
127  double v_double;
128  struct NT_String v_string;
129  struct NT_String v_raw;
130  struct {
131  NT_Bool* arr;
132  size_t size;
133  } arr_boolean;
134  struct {
135  double* arr;
136  size_t size;
137  } arr_double;
138  struct {
139  struct NT_String* arr;
140  size_t size;
141  } arr_string;
142  } data;
143 };
144 
146 struct NT_EntryInfo {
148  NT_Entry entry;
149 
151  struct NT_String name;
152 
154  enum NT_Type type;
155 
157  unsigned int flags;
158 
160  uint64_t last_change;
161 };
162 
170 
173 
175  unsigned int remote_port;
176 
181  uint64_t last_update;
182 
187  unsigned int protocol_version;
188 };
189 
192  struct NT_String name;
193  struct NT_Value def_value;
194 };
195 
198  struct NT_String name;
199  enum NT_Type type;
200 };
201 
204  unsigned int version;
205  struct NT_String name;
206  size_t num_params;
207  struct NT_RpcParamDef* params;
208  size_t num_results;
209  struct NT_RpcResultDef* results;
210 };
211 
213 struct NT_RpcAnswer {
214  NT_Entry entry;
215  NT_RpcCall call;
216  struct NT_String name;
217  struct NT_String params;
218  struct NT_ConnectionInfo conn;
219 };
220 
224  NT_EntryListener listener;
225 
227  NT_Entry entry;
228 
230  struct NT_String name;
231 
233  struct NT_Value value;
234 
239  unsigned int flags;
240 };
241 
245  NT_ConnectionListener listener;
246 
248  NT_Bool connected;
249 
252 };
253 
257  NT_Logger logger;
258 
260  unsigned int level;
261 
263  const char* filename;
264 
266  unsigned int line;
267 
269  char* message;
270 };
271 
283 NT_Inst NT_GetDefaultInstance(void);
284 
290 NT_Inst NT_CreateInstance(void);
291 
298 void NT_DestroyInstance(NT_Inst inst);
299 
306 NT_Inst NT_GetInstanceFromHandle(NT_Handle handle);
307 
323 NT_Entry NT_GetEntry(NT_Inst inst, const char* name, size_t name_len);
324 
339 NT_Entry* NT_GetEntries(NT_Inst inst, const char* prefix, size_t prefix_len,
340  unsigned int types, size_t* count);
341 
350 char* NT_GetEntryName(NT_Entry entry, size_t* name_len);
351 
358 enum NT_Type NT_GetEntryType(NT_Entry entry);
359 
367 uint64_t NT_GetEntryLastChange(NT_Entry entry);
368 
382 void NT_GetEntryValue(NT_Entry entry, struct NT_Value* value);
383 
395 NT_Bool NT_SetDefaultEntryValue(NT_Entry entry,
396  const struct NT_Value* default_value);
397 
408 NT_Bool NT_SetEntryValue(NT_Entry entry, const struct NT_Value* value);
409 
423 void NT_SetEntryTypeValue(NT_Entry entry, const struct NT_Value* value);
424 
431 void NT_SetEntryFlags(NT_Entry entry, unsigned int flags);
432 
439 unsigned int NT_GetEntryFlags(NT_Entry entry);
440 
454 void NT_DeleteEntry(NT_Entry entry);
455 
469 void NT_DeleteAllEntries(NT_Inst inst);
470 
488 struct NT_EntryInfo* NT_GetEntryInfo(NT_Inst inst, const char* prefix,
489  size_t prefix_len, unsigned int types,
490  size_t* count);
491 
502 NT_Bool NT_GetEntryInfoHandle(NT_Entry entry, struct NT_EntryInfo* info);
503 
518 typedef void (*NT_EntryListenerCallback)(
519  void* data, const struct NT_EntryNotification* event);
520 
532 NT_EntryListener NT_AddEntryListener(NT_Inst inst, const char* prefix,
533  size_t prefix_len, void* data,
534  NT_EntryListenerCallback callback,
535  unsigned int flags);
536 
546 NT_EntryListener NT_AddEntryListenerSingle(NT_Entry entry, void* data,
547  NT_EntryListenerCallback callback,
548  unsigned int flags);
549 
561 NT_EntryListenerPoller NT_CreateEntryListenerPoller(NT_Inst inst);
562 
569 void NT_DestroyEntryListenerPoller(NT_EntryListenerPoller poller);
570 
580 NT_EntryListener NT_AddPolledEntryListener(NT_EntryListenerPoller poller,
581  const char* prefix,
582  size_t prefix_len,
583  unsigned int flags);
584 
594 NT_EntryListener NT_AddPolledEntryListenerSingle(NT_EntryListenerPoller poller,
595  NT_Entry entry,
596  unsigned int flags);
597 
610 struct NT_EntryNotification* NT_PollEntryListener(NT_EntryListenerPoller poller,
611  size_t* len);
612 
628  NT_EntryListenerPoller poller, size_t* len, double timeout,
629  NT_Bool* timed_out);
630 
638 void NT_CancelPollEntryListener(NT_EntryListenerPoller poller);
639 
645 void NT_RemoveEntryListener(NT_EntryListener entry_listener);
646 
658 NT_Bool NT_WaitForEntryListenerQueue(NT_Inst inst, double timeout);
659 
675  void* data, const struct NT_ConnectionNotification* event);
676 
686 NT_ConnectionListener NT_AddConnectionListener(
687  NT_Inst inst, void* data, NT_ConnectionListenerCallback callback,
688  NT_Bool immediate_notify);
689 
701 NT_ConnectionListenerPoller NT_CreateConnectionListenerPoller(NT_Inst inst);
702 
709 void NT_DestroyConnectionListenerPoller(NT_ConnectionListenerPoller poller);
710 
718 NT_ConnectionListener NT_AddPolledConnectionListener(
719  NT_ConnectionListenerPoller poller, NT_Bool immediate_notify);
720 
734  NT_ConnectionListenerPoller poller, size_t* len);
735 
751  NT_ConnectionListenerPoller poller, size_t* len, double timeout,
752  NT_Bool* timed_out);
753 
761 void NT_CancelPollConnectionListener(NT_ConnectionListenerPoller poller);
762 
768 void NT_RemoveConnectionListener(NT_ConnectionListener conn_listener);
769 
781 NT_Bool NT_WaitForConnectionListenerQueue(NT_Inst inst, double timeout);
782 
799 typedef void (*NT_RpcCallback)(void* data, const struct NT_RpcAnswer* call);
800 
811 void NT_CreateRpc(NT_Entry entry, const char* def, size_t def_len, void* data,
812  NT_RpcCallback callback);
813 
825 NT_RpcCallPoller NT_CreateRpcCallPoller(NT_Inst inst);
826 
833 void NT_DestroyRpcCallPoller(NT_RpcCallPoller poller);
834 
846 void NT_CreatePolledRpc(NT_Entry entry, const char* def, size_t def_len,
847  NT_RpcCallPoller poller);
848 
862 struct NT_RpcAnswer* NT_PollRpc(NT_RpcCallPoller poller, size_t* len);
863 
880 struct NT_RpcAnswer* NT_PollRpcTimeout(NT_RpcCallPoller poller, size_t* len,
881  double timeout, NT_Bool* timed_out);
882 
889 void NT_CancelPollRpc(NT_RpcCallPoller poller);
890 
902 NT_Bool NT_WaitForRpcCallQueue(NT_Inst inst, double timeout);
903 
916 NT_Bool NT_PostRpcResponse(NT_Entry entry, NT_RpcCall call, const char* result,
917  size_t result_len);
918 
932 NT_RpcCall NT_CallRpc(NT_Entry entry, const char* params, size_t params_len);
933 
943 char* NT_GetRpcResult(NT_Entry entry, NT_RpcCall call, size_t* result_len);
944 
956 char* NT_GetRpcResultTimeout(NT_Entry entry, NT_RpcCall call,
957  size_t* result_len, double timeout,
958  NT_Bool* timed_out);
959 
966 void NT_CancelRpcResult(NT_Entry entry, NT_RpcCall call);
967 
975 char* NT_PackRpcDefinition(const struct NT_RpcDefinition* def,
976  size_t* packed_len);
977 
987 NT_Bool NT_UnpackRpcDefinition(const char* packed, size_t packed_len,
988  struct NT_RpcDefinition* def);
989 
998 char* NT_PackRpcValues(const struct NT_Value** values, size_t values_len,
999  size_t* packed_len);
1000 
1010 struct NT_Value** NT_UnpackRpcValues(const char* packed, size_t packed_len,
1011  const enum NT_Type* types,
1012  size_t types_len);
1013 
1030 void NT_SetNetworkIdentity(NT_Inst inst, const char* name, size_t name_len);
1031 
1038 unsigned int NT_GetNetworkMode(NT_Inst inst);
1039 
1050 void NT_StartServer(NT_Inst inst, const char* persist_filename,
1051  const char* listen_address, unsigned int port);
1052 
1058 void NT_StopServer(NT_Inst inst);
1059 
1065 void NT_StartClientNone(NT_Inst inst);
1066 
1074 void NT_StartClient(NT_Inst inst, const char* server_name, unsigned int port);
1075 
1086 void NT_StartClientMulti(NT_Inst inst, size_t count, const char** server_names,
1087  const unsigned int* ports);
1088 
1096 void NT_StartClientTeam(NT_Inst inst, unsigned int team, unsigned int port);
1097 
1103 void NT_StopClient(NT_Inst inst);
1104 
1112 void NT_SetServer(NT_Inst inst, const char* server_name, unsigned int port);
1113 
1124 void NT_SetServerMulti(NT_Inst inst, size_t count, const char** server_names,
1125  const unsigned int* ports);
1126 
1135 void NT_SetServerTeam(NT_Inst inst, unsigned int team, unsigned int port);
1136 
1145 void NT_StartDSClient(NT_Inst inst, unsigned int port);
1146 
1152 void NT_StopDSClient(NT_Inst inst);
1153 
1161 void NT_SetUpdateRate(NT_Inst inst, double interval);
1162 
1176 void NT_Flush(NT_Inst inst);
1177 
1189 struct NT_ConnectionInfo* NT_GetConnections(NT_Inst inst, size_t* count);
1190 
1197 NT_Bool NT_IsConnected(NT_Inst inst);
1198 
1215 const char* NT_SavePersistent(NT_Inst inst, const char* filename);
1216 
1227 const char* NT_LoadPersistent(NT_Inst inst, const char* filename,
1228  void (*warn)(size_t line, const char* msg));
1229 
1240 const char* NT_SaveEntries(NT_Inst inst, const char* filename,
1241  const char* prefix, size_t prefix_len);
1242 
1254 const char* NT_LoadEntries(NT_Inst inst, const char* filename,
1255  const char* prefix, size_t prefix_len,
1256  void (*warn)(size_t line, const char* msg));
1257 
1270 void NT_DisposeValue(struct NT_Value* value);
1271 
1278 void NT_InitValue(struct NT_Value* value);
1279 
1285 void NT_DisposeString(struct NT_String* str);
1286 
1293 void NT_InitString(struct NT_String* str);
1294 
1301 void NT_DisposeEntryArray(NT_Entry* arr, size_t count);
1302 
1309 void NT_DisposeConnectionInfoArray(struct NT_ConnectionInfo* arr, size_t count);
1310 
1317 void NT_DisposeEntryInfoArray(struct NT_EntryInfo* arr, size_t count);
1318 
1324 void NT_DisposeEntryInfo(struct NT_EntryInfo* info);
1325 
1331 void NT_DisposeRpcDefinition(struct NT_RpcDefinition* def);
1332 
1339 void NT_DisposeRpcAnswerArray(struct NT_RpcAnswer* arr, size_t count);
1340 
1346 void NT_DisposeRpcAnswer(struct NT_RpcAnswer* answer);
1347 
1355  size_t count);
1356 
1363 
1371  struct NT_ConnectionNotification* arr, size_t count);
1372 
1379 
1386 void NT_DisposeLogMessageArray(struct NT_LogMessage* arr, size_t count);
1387 
1393 void NT_DisposeLogMessage(struct NT_LogMessage* info);
1394 
1402 uint64_t NT_Now(void);
1403 
1417 typedef void (*NT_LogFunc)(void* data, const struct NT_LogMessage* msg);
1418 
1433 NT_Logger NT_AddLogger(NT_Inst inst, void* data, NT_LogFunc func,
1434  unsigned int min_level, unsigned int max_level);
1435 
1443 NT_LoggerPoller NT_CreateLoggerPoller(NT_Inst inst);
1444 
1451 void NT_DestroyLoggerPoller(NT_LoggerPoller poller);
1452 
1463 NT_Logger NT_AddPolledLogger(NT_LoggerPoller poller, unsigned int min_level,
1464  unsigned int max_level);
1465 
1474 struct NT_LogMessage* NT_PollLogger(NT_LoggerPoller poller, size_t* len);
1475 
1488 struct NT_LogMessage* NT_PollLoggerTimeout(NT_LoggerPoller poller, size_t* len,
1489  double timeout, NT_Bool* timed_out);
1490 
1497 void NT_CancelPollLogger(NT_LoggerPoller poller);
1498 
1504 void NT_RemoveLogger(NT_Logger logger);
1505 
1517 NT_Bool NT_WaitForLoggerQueue(NT_Inst inst, double timeout);
1518 
1542 char* NT_AllocateCharArray(size_t size);
1543 
1555 NT_Bool* NT_AllocateBooleanArray(size_t size);
1556 
1568 double* NT_AllocateDoubleArray(size_t size);
1569 
1581 struct NT_String* NT_AllocateStringArray(size_t size);
1582 
1588 void NT_FreeCharArray(char* v_char);
1589 
1595 void NT_FreeDoubleArray(double* v_double);
1596 
1602 void NT_FreeBooleanArray(NT_Bool* v_boolean);
1603 
1614 void NT_FreeStringArray(struct NT_String* v_string, size_t arr_size);
1615 
1630 enum NT_Type NT_GetValueType(const struct NT_Value* value);
1631 
1641 NT_Bool NT_GetValueBoolean(const struct NT_Value* value, uint64_t* last_change,
1642  NT_Bool* v_boolean);
1643 
1653 NT_Bool NT_GetValueDouble(const struct NT_Value* value, uint64_t* last_change,
1654  double* v_double);
1655 
1670 char* NT_GetValueString(const struct NT_Value* value, uint64_t* last_change,
1671  size_t* str_len);
1672 
1687 char* NT_GetValueRaw(const struct NT_Value* value, uint64_t* last_change,
1688  size_t* raw_len);
1689 
1704 NT_Bool* NT_GetValueBooleanArray(const struct NT_Value* value,
1705  uint64_t* last_change, size_t* arr_size);
1706 
1721 double* NT_GetValueDoubleArray(const struct NT_Value* value,
1722  uint64_t* last_change, size_t* arr_size);
1723 
1740 struct NT_String* NT_GetValueStringArray(const struct NT_Value* value,
1741  uint64_t* last_change,
1742  size_t* arr_size);
1743 
1755 NT_Bool NT_GetEntryBoolean(NT_Entry entry, uint64_t* last_change,
1756  NT_Bool* v_boolean);
1757 
1769 NT_Bool NT_GetEntryDouble(NT_Entry entry, uint64_t* last_change,
1770  double* v_double);
1771 
1785 char* NT_GetEntryString(NT_Entry entry, uint64_t* last_change, size_t* str_len);
1786 
1800 char* NT_GetEntryRaw(NT_Entry entry, uint64_t* last_change, size_t* raw_len);
1801 
1815 NT_Bool* NT_GetEntryBooleanArray(NT_Entry entry, uint64_t* last_change,
1816  size_t* arr_size);
1817 
1831 double* NT_GetEntryDoubleArray(NT_Entry entry, uint64_t* last_change,
1832  size_t* arr_size);
1833 
1850 struct NT_String* NT_GetEntryStringArray(NT_Entry entry, uint64_t* last_change,
1851  size_t* arr_size);
1852 
1870 NT_Bool NT_SetDefaultEntryBoolean(NT_Entry entry, uint64_t time,
1871  NT_Bool default_boolean);
1872 
1883 NT_Bool NT_SetDefaultEntryDouble(NT_Entry entry, uint64_t time,
1884  double default_double);
1885 
1897 NT_Bool NT_SetDefaultEntryString(NT_Entry entry, uint64_t time,
1898  const char* default_value, size_t default_len);
1899 
1911 NT_Bool NT_SetDefaultEntryRaw(NT_Entry entry, uint64_t time,
1912  const char* default_value, size_t default_len);
1913 
1925 NT_Bool NT_SetDefaultEntryBooleanArray(NT_Entry entry, uint64_t time,
1926  const int* default_value,
1927  size_t default_size);
1928 
1940 NT_Bool NT_SetDefaultEntryDoubleArray(NT_Entry entry, uint64_t time,
1941  const double* default_value,
1942  size_t default_size);
1943 
1955 NT_Bool NT_SetDefaultEntryStringArray(NT_Entry entry, uint64_t time,
1956  const struct NT_String* default_value,
1957  size_t default_size);
1958 
1976 NT_Bool NT_SetEntryBoolean(NT_Entry entry, uint64_t time, NT_Bool v_boolean,
1977  NT_Bool force);
1978 
1989 NT_Bool NT_SetEntryDouble(NT_Entry entry, uint64_t time, double v_double,
1990  NT_Bool force);
1991 
2003 NT_Bool NT_SetEntryString(NT_Entry entry, uint64_t time, const char* str,
2004  size_t str_len, NT_Bool force);
2005 
2017 NT_Bool NT_SetEntryRaw(NT_Entry entry, uint64_t time, const char* raw,
2018  size_t raw_len, NT_Bool force);
2019 
2031 NT_Bool NT_SetEntryBooleanArray(NT_Entry entry, uint64_t time, const int* arr,
2032  size_t size, NT_Bool force);
2033 
2045 NT_Bool NT_SetEntryDoubleArray(NT_Entry entry, uint64_t time, const double* arr,
2046  size_t size, NT_Bool force);
2047 
2059 NT_Bool NT_SetEntryStringArray(NT_Entry entry, uint64_t time,
2060  const struct NT_String* arr, size_t size,
2061  NT_Bool force);
2062 
2067 #ifdef __cplusplus
2068 } // extern "C"
2069 #endif
2070 
2071 #endif // NTCORE_NTCORE_C_H_
struct NT_EntryNotification * NT_PollEntryListener(NT_EntryListenerPoller poller, size_t *len)
Get the next entry listener event.
struct NT_EntryInfo * NT_GetEntryInfo(NT_Inst inst, const char *prefix, size_t prefix_len, unsigned int types, size_t *count)
Get Entry Information.
void NT_DisposeEntryNotificationArray(struct NT_EntryNotification *arr, size_t count)
Disposes an entry notification array.
NT_Bool NT_SetDefaultEntryStringArray(NT_Entry entry, uint64_t time, const struct NT_String *default_value, size_t default_size)
Set Default Entry String Array.
NT_Bool NT_SetEntryBooleanArray(NT_Entry entry, uint64_t time, const int *arr, size_t size, NT_Bool force)
Set Entry Boolean Array Sets an entry boolean array.
void NT_DisposeString(struct NT_String *str)
Frees string memory.
NT_EntryListener listener
Listener that was triggered.
Definition: ntcore_c.h:224
unsigned int protocol_version
The protocol version being used for this connection.
Definition: ntcore_c.h:187
void NT_StartClientNone(NT_Inst inst)
Starts a client.
void NT_SetEntryTypeValue(NT_Entry entry, const struct NT_Value *value)
Set Entry Type and Value.
struct NT_LogMessage * NT_PollLogger(NT_LoggerPoller poller, size_t *len)
Get the next log event.
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.
void NT_SetUpdateRate(NT_Inst inst, double interval)
Set the periodic update rate.
void(* NT_LogFunc)(void *data, const struct NT_LogMessage *msg)
Log function.
Definition: ntcore_c.h:1417
NT_Entry entry
Entry handle.
Definition: ntcore_c.h:148
uint64_t last_change
Timestamp of last change to entry (type or value).
Definition: ntcore_c.h:160
int NT_Bool
Typedefs.
Definition: ntcore_c.h:34
NT_RpcCallPoller NT_CreateRpcCallPoller(NT_Inst inst)
Create a RPC call poller.
struct NT_Value value
The new value.
Definition: ntcore_c.h:233
void NT_DestroyConnectionListenerPoller(NT_ConnectionListenerPoller poller)
Destroy a connection listener poller.
struct NT_ConnectionNotification * NT_PollConnectionListenerTimeout(NT_ConnectionListenerPoller poller, size_t *len, double timeout, NT_Bool *timed_out)
Get the next connection event.
uint64_t last_update
The last time any update was received from the remote node (same scale as returned by nt::Now())...
Definition: ntcore_c.h:181
void NT_SetServerTeam(NT_Inst inst, unsigned int team, unsigned int port)
Sets server addresses and port for client (without restarting client).
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.
void NT_CancelPollLogger(NT_LoggerPoller poller)
Cancel a PollLogger call.
unsigned int remote_port
The port number of the remote node.
Definition: ntcore_c.h:175
NetworkTables RPC Version 1 Definition Result.
Definition: ntcore_c.h:197
void NT_StartClient(NT_Inst inst, const char *server_name, unsigned int port)
Starts a client using the specified server and port.
NT_Bool connected
True if event is due to connection being established.
Definition: ntcore_c.h:248
NT_Bool NT_SetEntryRaw(NT_Entry entry, uint64_t time, const char *raw, size_t raw_len, NT_Bool force)
Set Entry Raw Sets the raw value of an entry.
NetworkTables Connection Information.
Definition: ntcore_c.h:164
void NT_GetEntryValue(NT_Entry entry, struct NT_Value *value)
Get Entry Value.
NetworkTables Entry Value.
Definition: ntcore_c.h:122
NT_Bool NT_SetEntryDouble(NT_Entry entry, uint64_t time, double v_double, NT_Bool force)
Set Entry Double Sets an entry double.
NT_Entry entry
Entry handle.
Definition: ntcore_c.h:227
unsigned int line
The line number in the source file that generated the message.
Definition: ntcore_c.h:266
void NT_InitValue(struct NT_Value *value)
Initializes a NT_Value.
NetworkTables Entry Information.
Definition: ntcore_c.h:146
char * NT_GetEntryString(NT_Entry entry, uint64_t *last_change, size_t *str_len)
Returns a copy of the string assigned to the entry name.
NetworkTables Entry Notification.
Definition: ntcore_c.h:222
void NT_CreatePolledRpc(NT_Entry entry, const char *def, size_t def_len, NT_RpcCallPoller poller)
Create a polled RPC entry point.
struct NT_String * NT_AllocateStringArray(size_t size)
Allocates an array of NT_Strings.
NT_Bool NT_WaitForRpcCallQueue(NT_Inst inst, double timeout)
Wait for the incoming RPC call queue to be empty.
NT_Bool NT_SetEntryStringArray(NT_Entry entry, uint64_t time, const struct NT_String *arr, size_t size, NT_Bool force)
Set Entry String Array Sets an entry string array.
NT_Inst NT_CreateInstance(void)
Create an instance.
char * NT_GetEntryRaw(NT_Entry entry, uint64_t *last_change, size_t *raw_len)
Returns a copy of the raw value assigned to the entry name.
struct NT_LogMessage * NT_PollLoggerTimeout(NT_LoggerPoller poller, size_t *len, double timeout, NT_Bool *timed_out)
Get the next log event.
NT_Bool NT_GetValueDouble(const struct NT_Value *value, uint64_t *last_change, double *v_double)
Returns the double from the NT_Value.
NT_Bool NT_GetValueBoolean(const struct NT_Value *value, uint64_t *last_change, NT_Bool *v_boolean)
Returns the boolean from the NT_Value.
void NT_DisposeLogMessageArray(struct NT_LogMessage *arr, size_t count)
Disposes a log message array.
NT_Bool NT_SetDefaultEntryValue(NT_Entry entry, const struct NT_Value *default_value)
Set Default Entry Value.
NT_Bool NT_SetDefaultEntryDouble(NT_Entry entry, uint64_t time, double default_double)
Set Default Entry Double.
void NT_StopDSClient(NT_Inst inst)
Stops requesting server address from Driver Station.
uint64_t NT_GetEntryLastChange(NT_Entry entry)
Gets the last time the entry was changed.
void(* NT_EntryListenerCallback)(void *data, const struct NT_EntryNotification *event)
Entry listener callback function.
Definition: ntcore_c.h:518
NetworkTables log message.
Definition: ntcore_c.h:255
void NT_DisposeLogMessage(struct NT_LogMessage *info)
Disposes a single log message.
void NT_FreeBooleanArray(NT_Bool *v_boolean)
Frees an array of booleans.
NT_NetworkMode
Client/server modes.
Definition: ntcore_c.h:92
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.
unsigned int flags
Update flags.
Definition: ntcore_c.h:239
NT_ConnectionListenerPoller NT_CreateConnectionListenerPoller(NT_Inst inst)
Create a connection listener poller.
void NT_DestroyInstance(NT_Inst inst)
Destroy an instance.
void NT_SetEntryFlags(NT_Entry entry, unsigned int flags)
Set Entry Flags.
struct NT_String * NT_GetValueStringArray(const struct NT_Value *value, uint64_t *last_change, size_t *arr_size)
Returns a copy of the NT_String array from the NT_Value.
NT_EntryListener NT_AddPolledEntryListenerSingle(NT_EntryListenerPoller poller, NT_Entry entry, unsigned int flags)
Create a polled entry listener.
struct NT_RpcAnswer * NT_PollRpcTimeout(NT_RpcCallPoller poller, size_t *len, double timeout, NT_Bool *timed_out)
Get the next incoming RPC call.
NT_Bool * NT_GetEntryBooleanArray(NT_Entry entry, uint64_t *last_change, size_t *arr_size)
Returns a copy of the boolean array assigned to the entry name.
void NT_RemoveEntryListener(NT_EntryListener entry_listener)
Remove an entry listener.
enum NT_Type NT_GetEntryType(NT_Entry entry)
Gets the type for the specified key, or unassigned if non existent.
void NT_DisposeValue(struct NT_Value *value)
Frees value memory.
unsigned int flags
Entry flags.
Definition: ntcore_c.h:157
char * message
The message.
Definition: ntcore_c.h:269
void NT_DisposeEntryArray(NT_Entry *arr, size_t count)
Disposes an entry handle array.
NetworkTables RPC Call Data.
Definition: ntcore_c.h:213
NT_Bool NT_SetEntryBoolean(NT_Entry entry, uint64_t time, NT_Bool v_boolean, NT_Bool force)
Set Entry Boolean Sets an entry boolean.
NT_RpcCall NT_CallRpc(NT_Entry entry, const char *params, size_t params_len)
Call a RPC function.
void NT_SetServer(NT_Inst inst, const char *server_name, unsigned int port)
Sets server address and port for client (without restarting client).
NT_Logger logger
The logger that generated the message.
Definition: ntcore_c.h:257
NT_EntryFlags
NetworkTables entry flags.
Definition: ntcore_c.h:65
NT_Bool NT_SetDefaultEntryDoubleArray(NT_Entry entry, uint64_t time, const double *default_value, size_t default_size)
Set Default Entry Double Array.
void NT_InitString(struct NT_String *str)
Initializes a NT_String.
char * NT_GetValueRaw(const struct NT_Value *value, uint64_t *last_change, size_t *raw_len)
Returns a copy of the raw value from the NT_Value.
NT_Bool NT_WaitForEntryListenerQueue(NT_Inst inst, double timeout)
Wait for the entry listener queue to be empty.
void NT_StartClientMulti(NT_Inst inst, size_t count, const char **server_names, const unsigned int *ports)
Starts a client using the specified (server, port) combinations.
NT_EntryListener NT_AddEntryListenerSingle(NT_Entry entry, void *data, NT_EntryListenerCallback callback, unsigned int flags)
Add a listener for a single entry.
void NT_DisposeEntryInfo(struct NT_EntryInfo *info)
Disposes a single entry info (as returned by NT_GetEntryInfoHandle).
struct NT_ConnectionInfo * NT_GetConnections(NT_Inst inst, size_t *count)
Get information on the currently established network connections.
NT_Bool NT_WaitForConnectionListenerQueue(NT_Inst inst, double timeout)
Wait for the connection listener queue to be empty.
void NT_DisposeEntryInfoArray(struct NT_EntryInfo *arr, size_t count)
Disposes an entry info array.
const char * NT_SavePersistent(NT_Inst inst, const char *filename)
Save persistent values to a file.
NT_Bool NT_GetEntryInfoHandle(NT_Entry entry, struct NT_EntryInfo *info)
Get Entry Information.
struct NT_String * NT_GetEntryStringArray(NT_Entry entry, uint64_t *last_change, size_t *arr_size)
Returns a copy of the NT_String array assigned to the entry name.
uint64_t NT_Now(void)
Returns monotonic current time in 1 us increments.
NT_Bool NT_SetEntryValue(NT_Entry entry, const struct NT_Value *value)
Set Entry Value.
NT_Inst NT_GetInstanceFromHandle(NT_Handle handle)
Get instance handle from another handle.
void NT_SetServerMulti(NT_Inst inst, size_t count, const char **server_names, const unsigned int *ports)
Sets server addresses for client (without restarting client).
void NT_StopServer(NT_Inst inst)
Stops the server if it is running.
struct NT_RpcAnswer * NT_PollRpc(NT_RpcCallPoller poller, size_t *len)
Get the next incoming RPC call.
const char * filename
The filename of the source file that generated the message.
Definition: ntcore_c.h:263
NT_Entry NT_GetEntry(NT_Inst inst, const char *name, size_t name_len)
Get Entry Handle.
void(* NT_ConnectionListenerCallback)(void *data, const struct NT_ConnectionNotification *event)
Connection listener callback function.
Definition: ntcore_c.h:674
unsigned int level
Log level of the message.
Definition: ntcore_c.h:260
void NT_RemoveConnectionListener(NT_ConnectionListener conn_listener)
Remove a connection listener.
const char * NT_LoadEntries(NT_Inst inst, const char *filename, const char *prefix, size_t prefix_len, void(*warn)(size_t line, const char *msg))
Load table values from a file.
void NT_DisposeRpcDefinition(struct NT_RpcDefinition *def)
Disposes a Rpc Definition structure.
void NT_DisposeConnectionInfoArray(struct NT_ConnectionInfo *arr, size_t count)
Disposes a connection info array.
NT_LoggerPoller NT_CreateLoggerPoller(NT_Inst inst)
Create a log poller.
double * NT_GetEntryDoubleArray(NT_Entry entry, uint64_t *last_change, size_t *arr_size)
Returns a copy of the double array assigned to the entry name.
NT_EntryListener NT_AddEntryListener(NT_Inst inst, const char *prefix, size_t prefix_len, void *data, NT_EntryListenerCallback callback, unsigned int flags)
Add a listener for all entries starting with a certain prefix.
NT_Inst NT_GetDefaultInstance(void)
Get default instance.
void NT_SetNetworkIdentity(NT_Inst inst, const char *name, size_t name_len)
Set the network identity of this node.
NT_Bool NT_SetEntryString(NT_Entry entry, uint64_t time, const char *str, size_t str_len, NT_Bool force)
Set Entry String Sets an entry string.
NT_EntryListener NT_AddPolledEntryListener(NT_EntryListenerPoller poller, const char *prefix, size_t prefix_len, unsigned int flags)
Create a polled entry listener.
char * NT_GetRpcResult(NT_Entry entry, NT_RpcCall call, size_t *result_len)
Get the result (return value) of a RPC call.
NT_Bool * NT_GetValueBooleanArray(const struct NT_Value *value, uint64_t *last_change, size_t *arr_size)
Returns a copy of the boolean array from the NT_Value.
void NT_DisposeConnectionNotification(struct NT_ConnectionNotification *info)
Disposes a single connection notification.
void NT_DestroyEntryListenerPoller(NT_EntryListenerPoller poller)
Destroy a entry listener poller.
const char * NT_LoadPersistent(NT_Inst inst, const char *filename, void(*warn)(size_t line, const char *msg))
Load persistent values from a file.
void NT_CancelRpcResult(NT_Entry entry, NT_RpcCall call)
Ignore the result of a RPC call.
char * NT_AllocateCharArray(size_t size)
Allocates an array of chars.
void NT_FreeStringArray(struct NT_String *v_string, size_t arr_size)
Frees an array of NT_Strings.
NT_Bool * NT_AllocateBooleanArray(size_t size)
Allocates an array of booleans.
void NT_DestroyLoggerPoller(NT_LoggerPoller poller)
Destroy a log poller.
NT_Bool NT_GetEntryDouble(NT_Entry entry, uint64_t *last_change, double *v_double)
Returns the double currently assigned to the entry name.
void NT_CancelPollConnectionListener(NT_ConnectionListenerPoller poller)
Cancel a PollConnectionListener call.
struct NT_ConnectionInfo conn
Connection info.
Definition: ntcore_c.h:251
void(* NT_RpcCallback)(void *data, const struct NT_RpcAnswer *call)
Remote Procedure Call (RPC) callback function.
Definition: ntcore_c.h:799
NT_Bool NT_SetDefaultEntryBooleanArray(NT_Entry entry, uint64_t time, const int *default_value, size_t default_size)
Set Default Entry Boolean Array.
struct NT_EntryNotification * NT_PollEntryListenerTimeout(NT_EntryListenerPoller poller, size_t *len, double timeout, NT_Bool *timed_out)
Get the next entry listener event.
NT_Bool NT_SetDefaultEntryBoolean(NT_Entry entry, uint64_t time, NT_Bool default_boolean)
Set Default Entry Boolean.
NT_Logger NT_AddLogger(NT_Inst inst, void *data, NT_LogFunc func, unsigned int min_level, unsigned int max_level)
Add logger callback function.
NT_Bool NT_SetDefaultEntryRaw(NT_Entry entry, uint64_t time, const char *default_value, size_t default_len)
Set Default Entry Raw.
void NT_DisposeEntryNotification(struct NT_EntryNotification *info)
Disposes a single entry notification.
NT_Bool NT_SetEntryDoubleArray(NT_Entry entry, uint64_t time, const double *arr, size_t size, NT_Bool force)
Set Entry Double Array Sets an entry double array.
NT_Type
NetworkTables data types.
Definition: ntcore_c.h:52
NT_NotifyKind
NetworkTables notifier kinds.
Definition: ntcore_c.h:81
void NT_StartClientTeam(NT_Inst inst, unsigned int team, unsigned int port)
Starts a client using commonly known robot addresses for the specified team.
NT_ConnectionListener NT_AddConnectionListener(NT_Inst inst, void *data, NT_ConnectionListenerCallback callback, NT_Bool immediate_notify)
Add a connection listener.
A NetworkTables string.
Definition: ntcore_c.h:105
NetworkTables RPC Version 1 Definition.
Definition: ntcore_c.h:203
void NT_FreeCharArray(char *v_char)
Frees an array of chars.
NT_Entry * NT_GetEntries(NT_Inst inst, const char *prefix, size_t prefix_len, unsigned int types, size_t *count)
Get Entry Handles.
NT_LogLevel
NetworkTables logging levels.
Definition: ntcore_c.h:68
enum NT_Type NT_GetValueType(const struct NT_Value *value)
Returns the type of an NT_Value struct.
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.
NT_Bool NT_UnpackRpcDefinition(const char *packed, size_t packed_len, struct NT_RpcDefinition *def)
Unpack a RPC version 1 definition.
NetworkTables RPC Version 1 Definition Parameter.
Definition: ntcore_c.h:191
NT_Bool NT_IsConnected(NT_Inst inst)
Return whether or not the instance is connected to another node.
char * str
String contents (UTF-8).
Definition: ntcore_c.h:112
size_t len
Length of the string in bytes.
Definition: ntcore_c.h:118
double * NT_GetValueDoubleArray(const struct NT_Value *value, uint64_t *last_change, size_t *arr_size)
Returns a copy of the double array from the NT_Value.
char * NT_GetValueString(const struct NT_Value *value, uint64_t *last_change, size_t *str_len)
Returns a copy of the string from the NT_Value.
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.
void NT_FreeDoubleArray(double *v_double)
Frees an array of doubles.
struct NT_ConnectionNotification * NT_PollConnectionListener(NT_ConnectionListenerPoller poller, size_t *len)
Get the next connection event.
char * NT_PackRpcDefinition(const struct NT_RpcDefinition *def, size_t *packed_len)
Pack a RPC version 1 definition.
unsigned int NT_GetEntryFlags(NT_Entry entry)
Get Entry Flags.
enum NT_Type type
Entry type.
Definition: ntcore_c.h:154
void NT_DestroyRpcCallPoller(NT_RpcCallPoller poller)
Destroy a RPC call poller.
void NT_DisposeRpcAnswer(struct NT_RpcAnswer *answer)
Disposes a Rpc Answer structure.
void NT_DeleteAllEntries(NT_Inst inst)
Delete All Entries.
struct NT_String remote_ip
The IP address of the remote node.
Definition: ntcore_c.h:172
NT_Bool NT_SetDefaultEntryString(NT_Entry entry, uint64_t time, const char *default_value, size_t default_len)
Set Default Entry String.
char * NT_GetEntryName(NT_Entry entry, size_t *name_len)
Gets the name of the specified entry.
void NT_DisposeRpcAnswerArray(struct NT_RpcAnswer *arr, size_t count)
Disposes a Rpc Answer array.
void NT_StartDSClient(NT_Inst inst, unsigned int port)
Starts requesting server address from Driver Station.
void NT_Flush(NT_Inst inst)
Flush Entries.
NT_Bool NT_WaitForLoggerQueue(NT_Inst inst, double timeout)
Wait for the incoming log event queue to be empty.
void NT_StartServer(NT_Inst inst, const char *persist_filename, const char *listen_address, unsigned int port)
Starts a server using the specified filename, listening address, and port.
NetworkTables Connection Notification.
Definition: ntcore_c.h:243
void NT_RemoveLogger(NT_Logger logger)
Remove a logger.
NT_ConnectionListener NT_AddPolledConnectionListener(NT_ConnectionListenerPoller poller, NT_Bool immediate_notify)
Create a polled connection listener.
NT_Bool NT_GetEntryBoolean(NT_Entry entry, uint64_t *last_change, NT_Bool *v_boolean)
Returns the boolean currently assigned to the entry name.
NT_EntryListenerPoller NT_CreateEntryListenerPoller(NT_Inst inst)
Create a entry listener poller.
NT_Logger NT_AddPolledLogger(NT_LoggerPoller poller, unsigned int min_level, unsigned int max_level)
Set the log level for a log poller.
void NT_StopClient(NT_Inst inst)
Stops the client if it is running.
double * NT_AllocateDoubleArray(size_t size)
Allocates an array of doubles.
void NT_CancelPollRpc(NT_RpcCallPoller poller)
Cancel a PollRpc call.
const char * NT_SaveEntries(NT_Inst inst, const char *filename, const char *prefix, size_t prefix_len)
Save table values to a file.
void NT_CancelPollEntryListener(NT_EntryListenerPoller poller)
Cancel a PollEntryListener call.
void NT_DeleteEntry(NT_Entry entry)
Delete Entry.
NT_ConnectionListener listener
Listener that was triggered.
Definition: ntcore_c.h:245
unsigned int NT_GetNetworkMode(NT_Inst inst)
Get the current network mode.
void NT_DisposeConnectionNotificationArray(struct NT_ConnectionNotification *arr, size_t count)
Disposes a connection notification array.
struct NT_String remote_id
The remote identifier (as set on the remote node by NetworkTableInstance::SetNetworkIdentity() or nt:...
Definition: ntcore_c.h:169