WPILibC++  unspecified
ntcore_c.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2015-2018. 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 #include <cstddef>
14 
15 #include <support/deprecated.h>
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
22 typedef int NT_Bool;
23 
24 typedef unsigned int NT_Handle;
25 typedef NT_Handle NT_ConnectionListener;
26 typedef NT_Handle NT_ConnectionListenerPoller;
27 typedef NT_Handle NT_Entry;
28 typedef NT_Handle NT_EntryListener;
29 typedef NT_Handle NT_EntryListenerPoller;
30 typedef NT_Handle NT_Inst;
31 typedef NT_Handle NT_Logger;
32 typedef NT_Handle NT_LoggerPoller;
33 typedef NT_Handle NT_RpcCall;
34 typedef NT_Handle NT_RpcCallPoller;
35 
37 #define NT_DEFAULT_PORT 1735
38 
40 enum NT_Type {
41  NT_UNASSIGNED = 0,
42  NT_BOOLEAN = 0x01,
43  NT_DOUBLE = 0x02,
44  NT_STRING = 0x04,
45  NT_RAW = 0x08,
46  NT_BOOLEAN_ARRAY = 0x10,
47  NT_DOUBLE_ARRAY = 0x20,
48  NT_STRING_ARRAY = 0x40,
49  NT_RPC = 0x80
50 };
51 
53 enum NT_EntryFlags { NT_PERSISTENT = 0x01 };
54 
56 enum NT_LogLevel {
57  NT_LOG_CRITICAL = 50,
58  NT_LOG_ERROR = 40,
59  NT_LOG_WARNING = 30,
60  NT_LOG_INFO = 20,
61  NT_LOG_DEBUG = 10,
62  NT_LOG_DEBUG1 = 9,
63  NT_LOG_DEBUG2 = 8,
64  NT_LOG_DEBUG3 = 7,
65  NT_LOG_DEBUG4 = 6
66 };
67 
69 enum NT_NotifyKind {
70  NT_NOTIFY_NONE = 0,
71  NT_NOTIFY_IMMEDIATE = 0x01, /* initial listener addition */
72  NT_NOTIFY_LOCAL = 0x02, /* changed locally */
73  NT_NOTIFY_NEW = 0x04, /* newly created entry */
74  NT_NOTIFY_DELETE = 0x08, /* deleted */
75  NT_NOTIFY_UPDATE = 0x10, /* value changed */
76  NT_NOTIFY_FLAGS = 0x20 /* flags changed */
77 };
78 
80 enum NT_NetworkMode {
81  NT_NET_MODE_NONE = 0x00, /* not running */
82  NT_NET_MODE_SERVER = 0x01, /* running in server mode */
83  NT_NET_MODE_CLIENT = 0x02, /* running in client mode */
84  NT_NET_MODE_STARTING = 0x04, /* flag for starting (either client or server) */
85  NT_NET_MODE_FAILURE = 0x08, /* flag for failure (either client or server) */
86 };
87 
88 /*
89  * Structures
90  */
91 
93 struct NT_String {
100  char* str;
101 
106  size_t len;
107 };
108 
110 struct NT_Value {
111  enum NT_Type type;
112  uint64_t last_change;
113  union {
114  NT_Bool v_boolean;
115  double v_double;
116  struct NT_String v_string;
117  struct NT_String v_raw;
118  struct {
119  NT_Bool* arr;
120  size_t size;
121  } arr_boolean;
122  struct {
123  double* arr;
124  size_t size;
125  } arr_double;
126  struct {
127  struct NT_String* arr;
128  size_t size;
129  } arr_string;
130  } data;
131 };
132 
134 struct NT_EntryInfo {
136  NT_Entry entry;
137 
139  struct NT_String name;
140 
142  enum NT_Type type;
143 
145  unsigned int flags;
146 
148  uint64_t last_change;
149 };
150 
157  struct NT_String remote_id;
158 
160  struct NT_String remote_ip;
161 
163  unsigned int remote_port;
164 
169  uint64_t last_update;
170 
175  unsigned int protocol_version;
176 };
177 
180  struct NT_String name;
181  struct NT_Value def_value;
182 };
183 
186  struct NT_String name;
187  enum NT_Type type;
188 };
189 
192  unsigned int version;
193  struct NT_String name;
194  size_t num_params;
195  NT_RpcParamDef* params;
196  size_t num_results;
197  NT_RpcResultDef* results;
198 };
199 
201 struct NT_RpcAnswer {
202  NT_Entry entry;
203  NT_RpcCall call;
204  struct NT_String name;
205  struct NT_String params;
206  struct NT_ConnectionInfo conn;
207 };
208 
212  NT_EntryListener listener;
213 
215  NT_Entry entry;
216 
218  struct NT_String name;
219 
221  struct NT_Value value;
222 
227  unsigned int flags;
228 };
229 
233  NT_ConnectionListener listener;
234 
236  NT_Bool connected;
237 
239  struct NT_ConnectionInfo conn;
240 };
241 
245  NT_Logger logger;
246 
248  unsigned int level;
249 
251  const char* filename;
252 
254  unsigned int line;
255 
257  char* message;
258 };
259 
270 NT_Inst NT_GetDefaultInstance(void);
271 
276 NT_Inst NT_CreateInstance(void);
277 
283 void NT_DestroyInstance(NT_Inst inst);
284 
290 NT_Inst NT_GetInstanceFromHandle(NT_Handle handle);
291 
306 NT_Entry NT_GetEntry(NT_Inst inst, const char* name, size_t name_len);
307 
321 NT_Entry* NT_GetEntries(NT_Inst inst, const char* prefix, size_t prefix_len,
322  unsigned int types, size_t* count);
323 
331 char* NT_GetEntryName(NT_Entry entry, size_t* name_len);
332 
338 enum NT_Type NT_GetEntryType(NT_Entry entry);
339 
346 uint64_t NT_GetEntryLastChange(NT_Entry entry);
347 
360 void NT_GetEntryValue(NT_Entry entry, struct NT_Value* value);
361 
372 NT_Bool NT_SetDefaultEntryValue(NT_Entry entry,
373  const struct NT_Value* default_value);
374 
384 NT_Bool NT_SetEntryValue(NT_Entry entry, const struct NT_Value* value);
385 
398 void NT_SetEntryTypeValue(NT_Entry entry, const struct NT_Value* value);
399 
405 void NT_SetEntryFlags(NT_Entry entry, unsigned int flags);
406 
412 unsigned int NT_GetEntryFlags(NT_Entry entry);
413 
426 void NT_DeleteEntry(NT_Entry entry);
427 
440 void NT_DeleteAllEntries(NT_Inst inst);
441 
458 struct NT_EntryInfo* NT_GetEntryInfo(NT_Inst inst, const char* prefix,
459  size_t prefix_len, unsigned int types,
460  size_t* count);
461 
471 NT_Bool NT_GetEntryInfoHandle(NT_Entry entry, struct NT_EntryInfo* info);
472 
487 typedef void (*NT_EntryListenerCallback)(void* data,
488  const NT_EntryNotification* event);
489 
501 NT_EntryListener NT_AddEntryListener(NT_Inst inst, const char* prefix,
502  size_t prefix_len, void* data,
503  NT_EntryListenerCallback callback,
504  unsigned int flags);
505 
515 NT_EntryListener NT_AddEntryListenerSingle(NT_Entry entry, void* data,
516  NT_EntryListenerCallback callback,
517  unsigned int flags);
518 
528 NT_EntryListenerPoller NT_CreateEntryListenerPoller(NT_Inst inst);
529 
535 void NT_DestroyEntryListenerPoller(NT_EntryListenerPoller poller);
536 
545 NT_EntryListener NT_AddPolledEntryListener(NT_EntryListenerPoller poller,
546  const char* prefix,
547  size_t prefix_len,
548  unsigned int flags);
549 
558 NT_EntryListener NT_AddPolledEntryListenerSingle(NT_EntryListenerPoller poller,
559  NT_Entry entry,
560  unsigned int flags);
561 
572 struct NT_EntryNotification* NT_PollEntryListener(NT_EntryListenerPoller poller,
573  size_t* len);
574 
589  NT_EntryListenerPoller poller, size_t* len, double timeout,
590  NT_Bool* timed_out);
591 
598 void NT_CancelPollEntryListener(NT_EntryListenerPoller poller);
599 
604 void NT_RemoveEntryListener(NT_EntryListener entry_listener);
605 
616 NT_Bool NT_WaitForEntryListenerQueue(NT_Inst inst, double timeout);
617 
633  void* data, const struct NT_ConnectionNotification* event);
634 
644 NT_ConnectionListener NT_AddConnectionListener(
645  NT_Inst inst, void* data, NT_ConnectionListenerCallback callback,
646  NT_Bool immediate_notify);
647 
658 NT_ConnectionListenerPoller NT_CreateConnectionListenerPoller(NT_Inst inst);
659 
665 void NT_DestroyConnectionListenerPoller(NT_ConnectionListenerPoller poller);
666 
673 NT_ConnectionListener NT_AddPolledConnectionListener(
674  NT_ConnectionListenerPoller poller, NT_Bool immediate_notify);
675 
688  NT_ConnectionListenerPoller poller, size_t* len);
689 
704  NT_ConnectionListenerPoller poller, size_t* len, double timeout,
705  NT_Bool* timed_out);
706 
713 void NT_CancelPollConnectionListener(NT_ConnectionListenerPoller poller);
714 
719 void NT_RemoveConnectionListener(NT_ConnectionListener conn_listener);
720 
731 NT_Bool NT_WaitForConnectionListenerQueue(NT_Inst inst, double timeout);
732 
747 typedef void (*NT_RpcCallback)(void* data, const struct NT_RpcAnswer* call);
748 
758 void NT_CreateRpc(NT_Entry entry, const char* def, size_t def_len, void* data,
759  NT_RpcCallback callback);
760 
770 NT_RpcCallPoller NT_CreateRpcCallPoller(NT_Inst inst);
771 
777 void NT_DestroyRpcCallPoller(NT_RpcCallPoller poller);
778 
788 void NT_CreatePolledRpc(NT_Entry entry, const char* def, size_t def_len,
789  NT_RpcCallPoller poller);
790 
803 struct NT_RpcAnswer* NT_PollRpc(NT_RpcCallPoller poller, size_t* len);
804 
820 struct NT_RpcAnswer* NT_PollRpcTimeout(NT_RpcCallPoller poller, size_t* len,
821  double timeout, NT_Bool* timed_out);
822 
828 void NT_CancelPollRpc(NT_RpcCallPoller poller);
829 
840 NT_Bool NT_WaitForRpcCallQueue(NT_Inst inst, double timeout);
841 
851 void NT_PostRpcResponse(NT_Entry entry, NT_RpcCall call, const char* result,
852  size_t result_len);
853 
865 NT_RpcCall NT_CallRpc(NT_Entry entry, const char* params, size_t params_len);
866 
875 char* NT_GetRpcResult(NT_Entry entry, NT_RpcCall call, size_t* result_len);
876 
887 char* NT_GetRpcResultTimeout(NT_Entry entry, NT_RpcCall call,
888  size_t* result_len, double timeout,
889  NT_Bool* timed_out);
890 
896 void NT_CancelRpcResult(NT_Entry entry, NT_RpcCall call);
897 
904 char* NT_PackRpcDefinition(const struct NT_RpcDefinition* def,
905  size_t* packed_len);
906 
915 NT_Bool NT_UnpackRpcDefinition(const char* packed, size_t packed_len,
916  struct NT_RpcDefinition* def);
917 
925 char* NT_PackRpcValues(const struct NT_Value** values, size_t values_len,
926  size_t* packed_len);
927 
936 struct NT_Value** NT_UnpackRpcValues(const char* packed, size_t packed_len,
937  const NT_Type* types, size_t types_len);
938 
954 void NT_SetNetworkIdentity(NT_Inst inst, const char* name, size_t name_len);
955 
961 unsigned int NT_GetNetworkMode(NT_Inst inst);
962 
973 void NT_StartServer(NT_Inst inst, const char* persist_filename,
974  const char* listen_address, unsigned int port);
975 
980 void NT_StopServer(NT_Inst inst);
981 
986 void NT_StartClientNone(NT_Inst inst);
987 
995 void NT_StartClient(NT_Inst inst, const char* server_name, unsigned int port);
996 
1007 void NT_StartClientMulti(NT_Inst inst, size_t count, const char** server_names,
1008  const unsigned int* ports);
1009 
1017 void NT_StartClientTeam(NT_Inst inst, unsigned int team, unsigned int port);
1018 
1023 void NT_StopClient(NT_Inst inst);
1024 
1032 void NT_SetServer(NT_Inst inst, const char* server_name, unsigned int port);
1033 
1044 void NT_SetServerMulti(NT_Inst inst, size_t count, const char** server_names,
1045  const unsigned int* ports);
1046 
1055 void NT_SetServerTeam(NT_Inst inst, unsigned int team, unsigned int port);
1056 
1065 void NT_StartDSClient(NT_Inst inst, unsigned int port);
1066 
1071 void NT_StopDSClient(NT_Inst inst);
1072 
1080 void NT_SetUpdateRate(NT_Inst inst, double interval);
1081 
1094 void NT_Flush(NT_Inst inst);
1095 
1107 struct NT_ConnectionInfo* NT_GetConnections(NT_Inst inst, size_t* count);
1108 
1114 NT_Bool NT_IsConnected(NT_Inst inst);
1115 
1131 const char* NT_SavePersistent(NT_Inst inst, const char* filename);
1132 
1142 const char* NT_LoadPersistent(NT_Inst inst, const char* filename,
1143  void (*warn)(size_t line, const char* msg));
1144 
1154 const char* NT_SaveEntries(NT_Inst inst, const char* filename,
1155  const char* prefix, size_t prefix_len);
1156 
1167 const char* NT_LoadEntries(NT_Inst inst, const char* filename,
1168  const char* prefix, size_t prefix_len,
1169  void (*warn)(size_t line, const char* msg));
1170 
1182 void NT_DisposeValue(struct NT_Value* value);
1183 
1189 void NT_InitValue(struct NT_Value* value);
1190 
1195 void NT_DisposeString(struct NT_String* str);
1196 
1202 void NT_InitString(struct NT_String* str);
1203 
1209 void NT_DisposeEntryArray(NT_Entry* arr, size_t count);
1210 
1216 void NT_DisposeConnectionInfoArray(struct NT_ConnectionInfo* arr, size_t count);
1217 
1223 void NT_DisposeEntryInfoArray(struct NT_EntryInfo* arr, size_t count);
1224 
1229 void NT_DisposeEntryInfo(struct NT_EntryInfo* info);
1230 
1235 void NT_DisposeRpcDefinition(struct NT_RpcDefinition* def);
1236 
1242 void NT_DisposeRpcAnswerArray(struct NT_RpcAnswer* arr, size_t count);
1243 
1248 void NT_DisposeRpcAnswer(struct NT_RpcAnswer* answer);
1249 
1256  size_t count);
1257 
1263 
1270  struct NT_ConnectionNotification* arr, size_t count);
1271 
1277 
1283 void NT_DisposeLogMessageArray(struct NT_LogMessage* arr, size_t count);
1284 
1289 void NT_DisposeLogMessage(struct NT_LogMessage* info);
1290 
1297 uint64_t NT_Now(void);
1298 
1311 typedef void (*NT_LogFunc)(void* data, const struct NT_LogMessage* msg);
1312 
1327 NT_Logger NT_AddLogger(NT_Inst inst, void* data, NT_LogFunc func,
1328  unsigned int min_level, unsigned int max_level);
1329 
1336 NT_LoggerPoller NT_CreateLoggerPoller(NT_Inst inst);
1337 
1343 void NT_DestroyLoggerPoller(NT_LoggerPoller poller);
1344 
1354 NT_Logger NT_AddPolledLogger(NT_LoggerPoller poller, unsigned int min_level,
1355  unsigned int max_level);
1356 
1364 struct NT_LogMessage* NT_PollLogger(NT_LoggerPoller poller, size_t* len);
1365 
1377 struct NT_LogMessage* NT_PollLoggerTimeout(NT_LoggerPoller poller, size_t* len,
1378  double timeout, NT_Bool* timed_out);
1379 
1385 void NT_CancelPollLogger(NT_LoggerPoller poller);
1386 
1391 void NT_RemoveLogger(NT_Logger logger);
1392 
1403 NT_Bool NT_WaitForLoggerQueue(NT_Inst inst, double timeout);
1404 
1428 char* NT_AllocateCharArray(size_t size);
1429 
1441 NT_Bool* NT_AllocateBooleanArray(size_t size);
1442 
1454 double* NT_AllocateDoubleArray(size_t size);
1455 
1467 struct NT_String* NT_AllocateStringArray(size_t size);
1468 
1474 void NT_FreeCharArray(char* v_char);
1475 
1481 void NT_FreeDoubleArray(double* v_double);
1482 
1488 void NT_FreeBooleanArray(NT_Bool* v_boolean);
1489 
1500 void NT_FreeStringArray(struct NT_String* v_string, size_t arr_size);
1501 
1516 enum NT_Type NT_GetValueType(const struct NT_Value* value);
1517 
1527 NT_Bool NT_GetValueBoolean(const struct NT_Value* value, uint64_t* last_change,
1528  NT_Bool* v_boolean);
1529 
1539 NT_Bool NT_GetValueDouble(const struct NT_Value* value, uint64_t* last_change,
1540  double* v_double);
1541 
1556 char* NT_GetValueString(const struct NT_Value* value, uint64_t* last_change,
1557  size_t* str_len);
1558 
1573 char* NT_GetValueRaw(const struct NT_Value* value, uint64_t* last_change,
1574  size_t* raw_len);
1575 
1590 NT_Bool* NT_GetValueBooleanArray(const struct NT_Value* value,
1591  uint64_t* last_change, size_t* arr_size);
1592 
1607 double* NT_GetValueDoubleArray(const struct NT_Value* value,
1608  uint64_t* last_change, size_t* arr_size);
1609 
1626 NT_String* NT_GetValueStringArray(const struct NT_Value* value,
1627  uint64_t* last_change, size_t* arr_size);
1628 
1640 NT_Bool NT_GetEntryBoolean(NT_Entry entry, uint64_t* last_change,
1641  NT_Bool* v_boolean);
1642 
1654 NT_Bool NT_GetEntryDouble(NT_Entry entry, uint64_t* last_change,
1655  double* v_double);
1656 
1670 char* NT_GetEntryString(NT_Entry entry, uint64_t* last_change, size_t* str_len);
1671 
1685 char* NT_GetEntryRaw(NT_Entry entry, uint64_t* last_change, size_t* raw_len);
1686 
1700 NT_Bool* NT_GetEntryBooleanArray(NT_Entry entry, uint64_t* last_change,
1701  size_t* arr_size);
1702 
1716 double* NT_GetEntryDoubleArray(NT_Entry entry, uint64_t* last_change,
1717  size_t* arr_size);
1718 
1735 NT_String* NT_GetEntryStringArray(NT_Entry entry, uint64_t* last_change,
1736  size_t* arr_size);
1737 
1755 NT_Bool NT_SetDefaultEntryBoolean(NT_Entry entry, uint64_t time,
1756  NT_Bool default_boolean);
1757 
1768 NT_Bool NT_SetDefaultEntryDouble(NT_Entry entry, uint64_t time,
1769  double default_double);
1770 
1782 NT_Bool NT_SetDefaultEntryString(NT_Entry entry, uint64_t time,
1783  const char* default_value, size_t default_len);
1784 
1796 NT_Bool NT_SetDefaultEntryRaw(NT_Entry entry, uint64_t time,
1797  const char* default_value, size_t default_len);
1798 
1810 NT_Bool NT_SetDefaultEntryBooleanArray(NT_Entry entry, uint64_t time,
1811  const int* default_value,
1812  size_t default_size);
1813 
1825 NT_Bool NT_SetDefaultEntryDoubleArray(NT_Entry entry, uint64_t time,
1826  const double* default_value,
1827  size_t default_size);
1828 
1840 NT_Bool NT_SetDefaultEntryStringArray(NT_Entry entry, uint64_t time,
1841  const struct NT_String* default_value,
1842  size_t default_size);
1843 
1861 NT_Bool NT_SetEntryBoolean(NT_Entry entry, uint64_t time, NT_Bool v_boolean,
1862  NT_Bool force);
1863 
1874 NT_Bool NT_SetEntryDouble(NT_Entry entry, uint64_t time, double v_double,
1875  NT_Bool force);
1876 
1888 NT_Bool NT_SetEntryString(NT_Entry entry, uint64_t time, const char* str,
1889  size_t str_len, NT_Bool force);
1890 
1902 NT_Bool NT_SetEntryRaw(NT_Entry entry, uint64_t time, const char* raw,
1903  size_t raw_len, NT_Bool force);
1904 
1916 NT_Bool NT_SetEntryBooleanArray(NT_Entry entry, uint64_t time, const int* arr,
1917  size_t size, NT_Bool force);
1918 
1930 NT_Bool NT_SetEntryDoubleArray(NT_Entry entry, uint64_t time, const double* arr,
1931  size_t size, NT_Bool force);
1932 
1944 NT_Bool NT_SetEntryStringArray(NT_Entry entry, uint64_t time,
1945  const struct NT_String* arr, size_t size,
1946  NT_Bool force);
1947 
1951 #ifdef __cplusplus
1952 } // extern "C"
1953 #endif
1954 
1955 #endif // NTCORE_NTCORE_C_H_
void NT_DisposeConnectionNotification(struct NT_ConnectionNotification *info)
Disposes a single connection notification.
Definition: ntcore_c.cpp:793
void NT_PostRpcResponse(NT_Entry entry, NT_RpcCall call, const char *result, size_t result_len)
Post RPC response (return value) for a polled RPC.
Definition: ntcore_c.cpp:457
struct NT_EntryInfo * NT_GetEntryInfo(NT_Inst inst, const char *prefix, size_t prefix_len, unsigned int types, size_t *count)
Get Entry Information.
Definition: ntcore_c.cpp:245
NT_EntryListener listener
Listener that was triggered.
Definition: ntcore_c.h:212
unsigned int protocol_version
The protocol version being used for this connection.
Definition: ntcore_c.h:175
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.
Definition: ntcore_c.cpp:1018
NT_Bool NT_SetEntryBoolean(NT_Entry entry, uint64_t time, NT_Bool v_boolean, NT_Bool force)
Set Entry Boolean Sets an entry boolean.
Definition: ntcore_c.cpp:880
void NT_CancelPollConnectionListener(NT_ConnectionListenerPoller poller)
Cancel a PollConnectionListener call.
Definition: ntcore_c.cpp:395
void NT_FreeDoubleArray(double *v_double)
Frees an array of doubles.
Definition: ntcore_c.cpp:863
NT_Entry entry
Entry handle.
Definition: ntcore_c.h:136
uint64_t last_change
Timestamp of last change to entry (type or value).
Definition: ntcore_c.h:148
NT_Bool NT_GetEntryBoolean(NT_Entry entry, uint64_t *last_change, NT_Bool *v_boolean)
Returns the boolean currently assigned to the entry name.
Definition: ntcore_c.cpp:1087
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.
NT_RpcCall NT_CallRpc(NT_Entry entry, const char *params, size_t params_len)
Call a RPC function.
Definition: ntcore_c.cpp:462
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.
Definition: ntcore_c.cpp:270
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:169
NT_EntryListener NT_AddPolledEntryListener(NT_EntryListenerPoller poller, const char *prefix, size_t prefix_len, unsigned int flags)
Create a polled entry listener.
Definition: ntcore_c.cpp:305
NT_Entry NT_GetEntry(NT_Inst inst, const char *name, size_t name_len)
Get Entry Handle.
Definition: ntcore_c.cpp:183
NT_Logger NT_AddPolledLogger(NT_LoggerPoller poller, unsigned int min_level, unsigned int max_level)
Set the log level for a log poller.
Definition: ntcore_c.cpp:686
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.
Definition: ntcore_c.cpp:477
void NT_RemoveConnectionListener(NT_ConnectionListener conn_listener)
Remove a connection listener.
Definition: ntcore_c.cpp:399
unsigned int remote_port
The port number of the remote node.
Definition: ntcore_c.h:163
NetworkTables RPC Version 1 Definition Result.
Definition: ntcore_c.h:185
NT_Bool connected
True if event is due to connection being established.
Definition: ntcore_c.h:236
NT_Bool NT_WaitForConnectionListenerQueue(NT_Inst inst, double timeout)
Wait for the connection listener queue to be empty.
Definition: ntcore_c.cpp:403
NetworkTables Connection Information.
Definition: ntcore_c.h:152
void NT_CancelPollLogger(NT_LoggerPoller poller)
Cancel a PollLogger call.
Definition: ntcore_c.cpp:708
struct NT_Value ** NT_UnpackRpcValues(const char *packed, size_t packed_len, const NT_Type *types, size_t types_len)
Unpack RPC values as required for RPC version 1 definition messages.
Definition: ntcore_c.cpp:537
struct NT_RpcAnswer * NT_PollRpcTimeout(NT_RpcCallPoller poller, size_t *len, double timeout, NT_Bool *timed_out)
Get the next incoming RPC call.
Definition: ntcore_c.cpp:441
struct NT_LogMessage * NT_PollLogger(NT_LoggerPoller poller, size_t *len)
Get the next log event.
Definition: ntcore_c.cpp:691
NetworkTables Entry Value.
Definition: ntcore_c.h:110
NT_Entry entry
Entry handle.
Definition: ntcore_c.h:215
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.
Definition: ntcore_c.cpp:1105
unsigned int line
The line number in the source file that generated the message.
Definition: ntcore_c.h:254
void NT_FreeBooleanArray(NT_Bool *v_boolean)
Frees an array of booleans.
Definition: ntcore_c.cpp:864
void(* NT_ConnectionListenerCallback)(void *data, const struct NT_ConnectionNotification *event)
Connection listener callback function.
Definition: ntcore_c.h:632
NetworkTables Entry Information.
Definition: ntcore_c.h:134
NT_LoggerPoller NT_CreateLoggerPoller(NT_Inst inst)
Create a log poller.
Definition: ntcore_c.cpp:678
NetworkTables Entry Notification.
Definition: ntcore_c.h:210
NT_Bool NT_GetValueDouble(const struct NT_Value *value, uint64_t *last_change, double *v_double)
Returns the double from the NT_Value.
Definition: ntcore_c.cpp:966
void NT_SetUpdateRate(NT_Inst inst, double interval)
Set the periodic update rate.
Definition: ntcore_c.cpp:616
unsigned int NT_GetEntryFlags(NT_Entry entry)
Get Entry Flags.
Definition: ntcore_c.cpp:237
double * NT_AllocateDoubleArray(size_t size)
Allocates an array of doubles.
Definition: ntcore_c.cpp:850
NT_ConnectionListener NT_AddConnectionListener(NT_Inst inst, void *data, NT_ConnectionListenerCallback callback, NT_Bool immediate_notify)
Add a connection listener.
Definition: ntcore_c.cpp:350
void NT_DeleteEntry(NT_Entry entry)
Delete Entry.
Definition: ntcore_c.cpp:241
void(* NT_LogFunc)(void *data, const struct NT_LogMessage *msg)
Log function.
Definition: ntcore_c.h:1311
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).
Definition: ntcore_c.cpp:597
NT_Bool NT_WaitForEntryListenerQueue(NT_Inst inst, double timeout)
Wait for the entry listener queue to be empty.
Definition: ntcore_c.cpp:346
void NT_SetServer(NT_Inst inst, const char *server_name, unsigned int port)
Sets server address and port for client (without restarting client).
Definition: ntcore_c.cpp:593
char * NT_AllocateCharArray(size_t size)
Allocates an array of chars.
Definition: ntcore_c.cpp:838
void NT_DestroyConnectionListenerPoller(NT_ConnectionListenerPoller poller)
Destroy a connection listener poller.
Definition: ntcore_c.cpp:367
struct NT_EntryNotification * NT_PollEntryListener(NT_EntryListenerPoller poller, size_t *len)
Get the next entry listener event.
Definition: ntcore_c.cpp:319
NetworkTables log message.
Definition: ntcore_c.h:243
NT_ConnectionListener NT_AddPolledConnectionListener(NT_ConnectionListenerPoller poller, NT_Bool immediate_notify)
Create a polled connection listener.
Definition: ntcore_c.cpp:371
unsigned int flags
Update flags.
Definition: ntcore_c.h:227
const char * NT_SaveEntries(NT_Inst inst, const char *filename, const char *prefix, size_t prefix_len)
Save table values to a file.
Definition: ntcore_c.cpp:649
void NT_FreeCharArray(char *v_char)
Frees an array of chars.
Definition: ntcore_c.cpp:862
void NT_FreeStringArray(struct NT_String *v_string, size_t arr_size)
Frees an array of NT_Strings.
Definition: ntcore_c.cpp:865
void NT_DestroyInstance(NT_Inst inst)
Destroy an instance.
Definition: ntcore_c.cpp:173
void NT_StartClientTeam(NT_Inst inst, unsigned int team, unsigned int port)
Starts a client using commonly known robot addresses for the specified team.
Definition: ntcore_c.cpp:587
void NT_Flush(NT_Inst inst)
Flush Entries.
Definition: ntcore_c.cpp:620
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.
Definition: ntcore_c.cpp:902
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.
Definition: ntcore_c.cpp:938
NT_Bool NT_IsConnected(NT_Inst inst)
Return whether or not the instance is connected to another node.
Definition: ntcore_c.cpp:622
NT_Bool NT_WaitForLoggerQueue(NT_Inst inst, double timeout)
Wait for the incoming log event queue to be empty.
Definition: ntcore_c.cpp:714
void NT_DisposeEntryArray(NT_Entry *arr, size_t count)
Disposes an entry handle array.
Definition: ntcore_c.cpp:764
void NT_CreatePolledRpc(NT_Entry entry, const char *def, size_t def_len, NT_RpcCallPoller poller)
Create a polled RPC entry point.
Definition: ntcore_c.cpp:429
void NT_StartDSClient(NT_Inst inst, unsigned int port)
Starts requesting server address from Driver Station.
Definition: ntcore_c.cpp:610
char * NT_PackRpcDefinition(const struct NT_RpcDefinition *def, size_t *packed_len)
Pack a RPC version 1 definition.
void NT_InitString(struct NT_String *str)
Initializes a NT_String.
Definition: ntcore_c.cpp:759
unsigned int flags
Entry flags.
Definition: ntcore_c.h:145
char * message
The message.
Definition: ntcore_c.h:257
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.
Definition: ntcore_c.cpp:1075
NetworkTables RPC Call Data.
Definition: ntcore_c.h:201
uint64_t NT_Now(void)
Returns monotonic current time in 1 us increments.
Definition: ntcore_c.cpp:664
void NT_SetEntryFlags(NT_Entry entry, unsigned int flags)
Set Entry Flags.
Definition: ntcore_c.cpp:233
NT_Logger logger
The logger that generated the message.
Definition: ntcore_c.h:245
void NT_DisposeEntryNotification(struct NT_EntryNotification *info)
Disposes a single entry notification.
Definition: ntcore_c.cpp:783
void NT_SetServerTeam(NT_Inst inst, unsigned int team, unsigned int port)
Sets server addresses and port for client (without restarting client).
Definition: ntcore_c.cpp:606
void(* NT_EntryListenerCallback)(void *data, const NT_EntryNotification *event)
Entry listener callback function.
Definition: ntcore_c.h:487
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.
Definition: ntcore_c.cpp:994
const char * NT_LoadPersistent(NT_Inst inst, const char *filename, void(*warn)(size_t line, const char *msg))
Load persistent values from a file.
Definition: ntcore_c.cpp:644
void NT_SetEntryTypeValue(NT_Entry entry, const struct NT_Value *value)
Set Entry Type and Value.
Definition: ntcore_c.cpp:229
NT_Bool NT_UnpackRpcDefinition(const char *packed, size_t packed_len, struct NT_RpcDefinition *def)
Unpack a RPC version 1 definition.
Definition: ntcore_c.cpp:509
NT_Bool * NT_AllocateBooleanArray(size_t size)
Allocates an array of booleans.
Definition: ntcore_c.cpp:844
void NT_DestroyEntryListenerPoller(NT_EntryListenerPoller poller)
Destroy a entry listener poller.
Definition: ntcore_c.cpp:301
NT_Bool NT_SetEntryDouble(NT_Entry entry, uint64_t time, double v_double, NT_Bool force)
Set Entry Double Sets an entry double.
Definition: ntcore_c.cpp:870
void NT_DisposeLogMessage(struct NT_LogMessage *info)
Disposes a single log message.
Definition: ntcore_c.cpp:802
NT_Bool NT_SetDefaultEntryDoubleArray(NT_Entry entry, uint64_t time, const double *default_value, size_t default_size)
Set Default Entry Double Array.
Definition: ntcore_c.cpp:1067
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.
Definition: ntcore_c.cpp:578
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.
Definition: ntcore_c.cpp:984
enum NT_Type NT_GetEntryType(NT_Entry entry)
Gets the type for the specified key, or unassigned if non existent.
Definition: ntcore_c.cpp:207
void NT_DisposeString(struct NT_String *str)
Frees string memory.
Definition: ntcore_c.cpp:753
NT_EntryListener NT_AddPolledEntryListenerSingle(NT_EntryListenerPoller poller, NT_Entry entry, unsigned int flags)
Create a polled entry listener.
Definition: ntcore_c.cpp:313
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.
Definition: ntcore_c.cpp:1150
NT_Bool NT_SetDefaultEntryBooleanArray(NT_Entry entry, uint64_t time, const int *default_value, size_t default_size)
Set Default Entry Boolean Array.
Definition: ntcore_c.cpp:1059
void NT_StopDSClient(NT_Inst inst)
Stops requesting server address from Driver Station.
Definition: ntcore_c.cpp:614
const char * filename
The filename of the source file that generated the message.
Definition: ntcore_c.h:251
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.
Definition: ntcore_c.cpp:1138
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.
Definition: ntcore_c.cpp:913
unsigned int level
Log level of the message.
Definition: ntcore_c.h:248
void NT_InitValue(struct NT_Value *value)
Initializes a NT_Value.
Definition: ntcore_c.cpp:748
uint64_t NT_GetEntryLastChange(NT_Entry entry)
Gets the last time the entry was changed.
Definition: ntcore_c.cpp:209
void NT_StopServer(NT_Inst inst)
Stops the server if it is running.
Definition: ntcore_c.cpp:570
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.
Definition: ntcore_c.cpp:654
const char * NT_SavePersistent(NT_Inst inst, const char *filename)
Save persistent values to a file.
Definition: ntcore_c.cpp:640
NT_RpcCallPoller NT_CreateRpcCallPoller(NT_Inst inst)
Create a RPC call poller.
Definition: ntcore_c.cpp:421
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.
Definition: ntcore_c.cpp:1126
void NT_DeleteAllEntries(NT_Inst inst)
Delete All Entries.
Definition: ntcore_c.cpp:243
void NT_DisposeConnectionNotificationArray(struct NT_ConnectionNotification *arr, size_t count)
Disposes a connection notification array.
Definition: ntcore_c.cpp:787
void NT_GetEntryValue(NT_Entry entry, struct NT_Value *value)
Get Entry Value.
Definition: ntcore_c.cpp:213
NT_Bool NT_GetValueBoolean(const struct NT_Value *value, uint64_t *last_change, NT_Bool *v_boolean)
Returns the boolean from the NT_Value.
Definition: ntcore_c.cpp:958
void NT_CancelRpcResult(NT_Entry entry, NT_RpcCall call)
Ignore the result of a RPC call.
Definition: ntcore_c.cpp:495
NT_Entry * NT_GetEntries(NT_Inst inst, const char *prefix, size_t prefix_len, unsigned int types, size_t *count)
Get Entry Handles.
Definition: ntcore_c.cpp:187
NT_Bool NT_SetDefaultEntryBoolean(NT_Entry entry, uint64_t time, NT_Bool default_boolean)
Set Default Entry Boolean.
Definition: ntcore_c.cpp:1034
NT_EntryListenerPoller NT_CreateEntryListenerPoller(NT_Inst inst)
Create a entry listener poller.
Definition: ntcore_c.cpp:297
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.
Definition: ntcore_c.cpp:565
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.
Definition: ntcore_c.cpp:926
void NT_StartClientNone(NT_Inst inst)
Starts a client.
Definition: ntcore_c.cpp:572
NT_ConnectionListenerPoller NT_CreateConnectionListenerPoller(NT_Inst inst)
Create a connection listener poller.
Definition: ntcore_c.cpp:363
struct NT_ConnectionNotification * NT_PollConnectionListener(NT_ConnectionListenerPoller poller, size_t *len)
Get the next connection event.
Definition: ntcore_c.cpp:376
void NT_DisposeValue(struct NT_Value *value)
Frees value memory.
Definition: ntcore_c.cpp:718
void(* NT_RpcCallback)(void *data, const struct NT_RpcAnswer *call)
Remote Procedure Call (RPC) callback function.
Definition: ntcore_c.h:747
void NT_SetNetworkIdentity(NT_Inst inst, const char *name, size_t name_len)
Set the network identity of this node.
Definition: ntcore_c.cpp:557
void NT_StartClient(NT_Inst inst, const char *server_name, unsigned int port)
Starts a client using the specified server and port.
Definition: ntcore_c.cpp:574
NT_Inst NT_CreateInstance(void)
Create an instance.
Definition: ntcore_c.cpp:171
char * NT_GetRpcResult(NT_Entry entry, NT_RpcCall call, size_t *result_len)
Get the result (return value) of a RPC call.
Definition: ntcore_c.cpp:466
NT_Bool NT_SetEntryValue(NT_Entry entry, const struct NT_Value *value)
Set Entry Value.
Definition: ntcore_c.cpp:225
NT_Inst NT_GetInstanceFromHandle(NT_Handle handle)
Get instance handle from another handle.
Definition: ntcore_c.cpp:175
struct NT_ConnectionInfo * NT_GetConnections(NT_Inst inst, size_t *count)
Get information on the currently established network connections.
Definition: ntcore_c.cpp:624
struct NT_RpcAnswer * NT_PollRpc(NT_RpcCallPoller poller, size_t *len)
Get the next incoming RPC call.
Definition: ntcore_c.cpp:434
void NT_DisposeConnectionInfoArray(struct NT_ConnectionInfo *arr, size_t count)
Disposes a connection info array.
Definition: ntcore_c.cpp:766
void NT_DisposeEntryInfo(struct NT_EntryInfo *info)
Disposes a single entry info (as returned by NT_GetEntryInfoHandle).
Definition: ntcore_c.cpp:776
struct NT_LogMessage * NT_PollLoggerTimeout(NT_LoggerPoller poller, size_t *len, double timeout, NT_Bool *timed_out)
Get the next log event.
Definition: ntcore_c.cpp:698
void NT_DisposeEntryNotificationArray(struct NT_EntryNotification *arr, size_t count)
Disposes an entry notification array.
Definition: ntcore_c.cpp:778
void NT_DisposeEntryInfoArray(struct NT_EntryInfo *arr, size_t count)
Disposes an entry info array.
Definition: ntcore_c.cpp:771
A NetworkTables string.
Definition: ntcore_c.h:93
NT_Bool NT_WaitForRpcCallQueue(NT_Inst inst, double timeout)
Wait for the incoming RPC call queue to be empty.
Definition: ntcore_c.cpp:453
NetworkTables RPC Version 1 Definition.
Definition: ntcore_c.h:191
struct NT_EntryNotification * NT_PollEntryListenerTimeout(NT_EntryListenerPoller poller, size_t *len, double timeout, NT_Bool *timed_out)
Get the next entry listener event.
Definition: ntcore_c.cpp:327
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.
Definition: ntcore_c.cpp:411
NetworkTables RPC Version 1 Definition Parameter.
Definition: ntcore_c.h:179
NT_Bool NT_GetEntryDouble(NT_Entry entry, uint64_t *last_change, double *v_double)
Returns the double currently assigned to the entry name.
Definition: ntcore_c.cpp:1096
void NT_DestroyLoggerPoller(NT_LoggerPoller poller)
Destroy a log poller.
Definition: ntcore_c.cpp:682
NT_Bool NT_SetDefaultEntryDouble(NT_Entry entry, uint64_t time, double default_double)
Set Default Entry Double.
Definition: ntcore_c.cpp:1040
struct NT_String * NT_AllocateStringArray(size_t size)
Allocates an array of NT_Strings.
Definition: ntcore_c.cpp:856
void NT_RemoveEntryListener(NT_EntryListener entry_listener)
Remove an entry listener.
Definition: ntcore_c.cpp:342
NT_Inst NT_GetDefaultInstance(void)
Get default instance.
Definition: ntcore_c.cpp:169
NT_Bool NT_SetDefaultEntryRaw(NT_Entry entry, uint64_t time, const char *default_value, size_t default_len)
Set Default Entry Raw.
Definition: ntcore_c.cpp:1053
char * str
String contents (UTF-8).
Definition: ntcore_c.h:100
void NT_RemoveLogger(NT_Logger logger)
Remove a logger.
Definition: ntcore_c.cpp:712
size_t len
Length of the string in bytes.
Definition: ntcore_c.h:106
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.
Definition: ntcore_c.cpp:1006
unsigned int NT_GetNetworkMode(NT_Inst inst)
Get the current network mode.
Definition: ntcore_c.cpp:561
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.
Definition: ntcore_c.cpp:974
NT_Bool NT_SetDefaultEntryString(NT_Entry entry, uint64_t time, const char *default_value, size_t default_len)
Set Default Entry String.
Definition: ntcore_c.cpp:1046
void NT_DisposeRpcDefinition(struct NT_RpcDefinition *def)
Disposes a Rpc Definition structure.
Definition: ntcore_c.cpp:804
void NT_CancelPollEntryListener(NT_EntryListenerPoller poller)
Cancel a PollEntryListener call.
Definition: ntcore_c.cpp:338
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.
Definition: ntcore_c.cpp:890
char * NT_GetEntryName(NT_Entry entry, size_t *name_len)
Gets the name of the specified entry.
Definition: ntcore_c.cpp:200
enum NT_Type NT_GetValueType(const struct NT_Value *value)
Returns the type of an NT_Value struct.
Definition: ntcore_c.cpp:953
void NT_StopClient(NT_Inst inst)
Stops the client if it is running.
Definition: ntcore_c.cpp:591
void NT_DisposeRpcAnswerArray(struct NT_RpcAnswer *arr, size_t count)
Disposes a Rpc Answer array.
Definition: ntcore_c.cpp:822
void NT_CancelPollRpc(NT_RpcCallPoller poller)
Cancel a PollRpc call.
Definition: ntcore_c.cpp:451
NT_EntryListener NT_AddEntryListenerSingle(NT_Entry entry, void *data, NT_EntryListenerCallback callback, unsigned int flags)
Add a listener for a single entry.
Definition: ntcore_c.cpp:284
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.
Definition: ntcore_c.cpp:1116
NT_Bool NT_GetEntryInfoHandle(NT_Entry entry, struct NT_EntryInfo *info)
Get Entry Information.
Definition: ntcore_c.cpp:259
void NT_DisposeRpcAnswer(struct NT_RpcAnswer *answer)
Disposes a Rpc Answer structure.
Definition: ntcore_c.cpp:827
NetworkTables Connection Notification.
Definition: ntcore_c.h:231
void NT_DestroyRpcCallPoller(NT_RpcCallPoller poller)
Destroy a RPC call poller.
Definition: ntcore_c.cpp:425
struct NT_ConnectionNotification * NT_PollConnectionListenerTimeout(NT_ConnectionListenerPoller poller, size_t *len, double timeout, NT_Bool *timed_out)
Get the next connection event.
Definition: ntcore_c.cpp:384
NT_ConnectionListener listener
Listener that was triggered.
Definition: ntcore_c.h:233
void NT_DisposeLogMessageArray(struct NT_LogMessage *arr, size_t count)
Disposes a log message array.
Definition: ntcore_c.cpp:797
NT_Bool NT_SetDefaultEntryValue(NT_Entry entry, const struct NT_Value *default_value)
Set Default Entry Value.
Definition: ntcore_c.cpp:220
NT_Logger NT_AddLogger(NT_Inst inst, void *data, NT_LogFunc func, unsigned int min_level, unsigned int max_level)
Add logger callback function.
Definition: ntcore_c.cpp:666