WPILibC++  unspecified
ntcore_c.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2015. 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_C_H_
9 #define NTCORE_C_H_
10 
11 #include <stddef.h>
12 
13 #include "support/deprecated.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
20 typedef int NT_Bool;
21 
22 typedef unsigned int NT_Handle;
23 typedef NT_Handle NT_ConnectionListener;
24 typedef NT_Handle NT_ConnectionListenerPoller;
25 typedef NT_Handle NT_Entry;
26 typedef NT_Handle NT_EntryListener;
27 typedef NT_Handle NT_EntryListenerPoller;
28 typedef NT_Handle NT_Inst;
29 typedef NT_Handle NT_Logger;
30 typedef NT_Handle NT_LoggerPoller;
31 typedef NT_Handle NT_RpcCall;
32 typedef NT_Handle NT_RpcCallPoller;
33 
35 #define NT_DEFAULT_PORT 1735
36 
38 enum NT_Type {
39  NT_UNASSIGNED = 0,
40  NT_BOOLEAN = 0x01,
41  NT_DOUBLE = 0x02,
42  NT_STRING = 0x04,
43  NT_RAW = 0x08,
44  NT_BOOLEAN_ARRAY = 0x10,
45  NT_DOUBLE_ARRAY = 0x20,
46  NT_STRING_ARRAY = 0x40,
47  NT_RPC = 0x80
48 };
49 
51 enum NT_EntryFlags { NT_PERSISTENT = 0x01 };
52 
54 enum NT_LogLevel {
55  NT_LOG_CRITICAL = 50,
56  NT_LOG_ERROR = 40,
57  NT_LOG_WARNING = 30,
58  NT_LOG_INFO = 20,
59  NT_LOG_DEBUG = 10,
60  NT_LOG_DEBUG1 = 9,
61  NT_LOG_DEBUG2 = 8,
62  NT_LOG_DEBUG3 = 7,
63  NT_LOG_DEBUG4 = 6
64 };
65 
67 enum NT_NotifyKind {
68  NT_NOTIFY_NONE = 0,
69  NT_NOTIFY_IMMEDIATE = 0x01, /* initial listener addition */
70  NT_NOTIFY_LOCAL = 0x02, /* changed locally */
71  NT_NOTIFY_NEW = 0x04, /* newly created entry */
72  NT_NOTIFY_DELETE = 0x08, /* deleted */
73  NT_NOTIFY_UPDATE = 0x10, /* value changed */
74  NT_NOTIFY_FLAGS = 0x20 /* flags changed */
75 };
76 
78 enum NT_NetworkMode {
79  NT_NET_MODE_NONE = 0x00, /* not running */
80  NT_NET_MODE_SERVER = 0x01, /* running in server mode */
81  NT_NET_MODE_CLIENT = 0x02, /* running in client mode */
82  NT_NET_MODE_STARTING = 0x04, /* flag for starting (either client or server) */
83  NT_NET_MODE_FAILURE = 0x08, /* flag for failure (either client or server) */
84 };
85 
86 /*
87  * Structures
88  */
89 
91 struct NT_String {
98  char* str;
99 
104  size_t len;
105 };
106 
108 struct NT_Value {
109  enum NT_Type type;
110  unsigned long long last_change;
111  union {
112  NT_Bool v_boolean;
113  double v_double;
114  struct NT_String v_string;
115  struct NT_String v_raw;
116  struct {
117  NT_Bool* arr;
118  size_t size;
119  } arr_boolean;
120  struct {
121  double* arr;
122  size_t size;
123  } arr_double;
124  struct {
125  struct NT_String* arr;
126  size_t size;
127  } arr_string;
128  } data;
129 };
130 
132 struct NT_EntryInfo {
134  NT_Entry entry;
135 
137  struct NT_String name;
138 
140  enum NT_Type type;
141 
143  unsigned int flags;
144 
146  unsigned long long last_change;
147 };
148 
155  struct NT_String remote_id;
156 
158  struct NT_String remote_ip;
159 
161  unsigned int remote_port;
162 
167  unsigned long long last_update;
168 
173  unsigned int protocol_version;
174 };
175 
178  struct NT_String name;
179  struct NT_Value def_value;
180 };
181 
184  struct NT_String name;
185  enum NT_Type type;
186 };
187 
190  unsigned int version;
191  struct NT_String name;
192  size_t num_params;
193  NT_RpcParamDef* params;
194  size_t num_results;
195  NT_RpcResultDef* results;
196 };
197 
199 struct NT_RpcAnswer {
200  NT_Entry entry;
201  NT_RpcCall call;
202  struct NT_String name;
203  struct NT_String params;
204  struct NT_ConnectionInfo conn;
205 };
206 
210  NT_EntryListener listener;
211 
213  NT_Entry entry;
214 
216  struct NT_String name;
217 
219  struct NT_Value value;
220 
225  unsigned int flags;
226 };
227 
231  NT_ConnectionListener listener;
232 
234  NT_Bool connected;
235 
237  struct NT_ConnectionInfo conn;
238 };
239 
243  NT_Logger logger;
244 
246  unsigned int level;
247 
249  const char* filename;
250 
252  unsigned int line;
253 
255  char* message;
256 };
257 
268 NT_Inst NT_GetDefaultInstance(void);
269 
274 NT_Inst NT_CreateInstance(void);
275 
281 void NT_DestroyInstance(NT_Inst inst);
282 
288 NT_Inst NT_GetInstanceFromHandle(NT_Handle handle);
289 
304 NT_Entry NT_GetEntry(NT_Inst inst, const char* name, size_t name_len);
305 
319 NT_Entry* NT_GetEntries(NT_Inst inst, const char* prefix, size_t prefix_len,
320  unsigned int types, size_t* count);
321 
329 char* NT_GetEntryName(NT_Entry entry, size_t* name_len);
330 
336 enum NT_Type NT_GetEntryType(NT_Entry entry);
337 
344 unsigned long long NT_GetEntryLastChange(NT_Entry entry);
345 
358 void NT_GetEntryValue(NT_Entry entry, struct NT_Value* value);
359 
370 NT_Bool NT_SetDefaultEntryValue(NT_Entry entry,
371  const struct NT_Value* default_value);
372 
382 NT_Bool NT_SetEntryValue(NT_Entry entry, const struct NT_Value* value);
383 
396 void NT_SetEntryTypeValue(NT_Entry entry, const struct NT_Value* value);
397 
403 void NT_SetEntryFlags(NT_Entry entry, unsigned int flags);
404 
410 unsigned int NT_GetEntryFlags(NT_Entry entry);
411 
424 void NT_DeleteEntry(NT_Entry entry);
425 
438 void NT_DeleteAllEntries(NT_Inst inst);
439 
456 struct NT_EntryInfo* NT_GetEntryInfo(NT_Inst inst, const char* prefix,
457  size_t prefix_len, unsigned int types,
458  size_t* count);
459 
469 NT_Bool NT_GetEntryInfoHandle(NT_Entry entry, struct NT_EntryInfo* info);
470 
485 typedef void (*NT_EntryListenerCallback)(void* data,
486  const NT_EntryNotification* event);
487 
499 NT_EntryListener NT_AddEntryListener(NT_Inst inst, const char* prefix,
500  size_t prefix_len, void* data,
501  NT_EntryListenerCallback callback,
502  unsigned int flags);
503 
513 NT_EntryListener NT_AddEntryListenerSingle(NT_Entry entry, void* data,
514  NT_EntryListenerCallback callback,
515  unsigned int flags);
516 
526 NT_EntryListenerPoller NT_CreateEntryListenerPoller(NT_Inst inst);
527 
533 void NT_DestroyEntryListenerPoller(NT_EntryListenerPoller poller);
534 
543 NT_EntryListener NT_AddPolledEntryListener(NT_EntryListenerPoller poller,
544  const char* prefix,
545  size_t prefix_len,
546  unsigned int flags);
547 
556 NT_EntryListener NT_AddPolledEntryListenerSingle(NT_EntryListenerPoller poller,
557  NT_Entry entry,
558  unsigned int flags);
559 
570 struct NT_EntryNotification* NT_PollEntryListener(NT_EntryListenerPoller poller,
571  size_t* len);
572 
587  NT_EntryListenerPoller poller, size_t* len, double timeout,
588  NT_Bool* timed_out);
589 
596 void NT_CancelPollEntryListener(NT_EntryListenerPoller poller);
597 
602 void NT_RemoveEntryListener(NT_EntryListener entry_listener);
603 
614 NT_Bool NT_WaitForEntryListenerQueue(NT_Inst inst, double timeout);
615 
631  void* data, const struct NT_ConnectionNotification* event);
632 
642 NT_ConnectionListener NT_AddConnectionListener(
643  NT_Inst inst, void* data, NT_ConnectionListenerCallback callback,
644  NT_Bool immediate_notify);
645 
656 NT_ConnectionListenerPoller NT_CreateConnectionListenerPoller(NT_Inst inst);
657 
663 void NT_DestroyConnectionListenerPoller(NT_ConnectionListenerPoller poller);
664 
671 NT_ConnectionListener NT_AddPolledConnectionListener(
672  NT_ConnectionListenerPoller poller, NT_Bool immediate_notify);
673 
686  NT_ConnectionListenerPoller poller, size_t* len);
687 
702  NT_ConnectionListenerPoller poller, size_t* len, double timeout,
703  NT_Bool* timed_out);
704 
711 void NT_CancelPollConnectionListener(NT_ConnectionListenerPoller poller);
712 
717 void NT_RemoveConnectionListener(NT_ConnectionListener conn_listener);
718 
729 NT_Bool NT_WaitForConnectionListenerQueue(NT_Inst inst, double timeout);
730 
745 typedef void (*NT_RpcCallback)(void* data, const struct NT_RpcAnswer* call);
746 
756 void NT_CreateRpc(NT_Entry entry, const char* def, size_t def_len, void* data,
757  NT_RpcCallback callback);
758 
768 NT_RpcCallPoller NT_CreateRpcCallPoller(NT_Inst inst);
769 
775 void NT_DestroyRpcCallPoller(NT_RpcCallPoller poller);
776 
786 void NT_CreatePolledRpc(NT_Entry entry, const char* def, size_t def_len,
787  NT_RpcCallPoller poller);
788 
801 struct NT_RpcAnswer* NT_PollRpc(NT_RpcCallPoller poller, size_t* len);
802 
818 struct NT_RpcAnswer* NT_PollRpcTimeout(NT_RpcCallPoller poller, size_t* len,
819  double timeout, NT_Bool* timed_out);
820 
826 void NT_CancelPollRpc(NT_RpcCallPoller poller);
827 
838 NT_Bool NT_WaitForRpcCallQueue(NT_Inst inst, double timeout);
839 
849 void NT_PostRpcResponse(NT_Entry entry, NT_RpcCall call, const char* result,
850  size_t result_len);
851 
863 NT_RpcCall NT_CallRpc(NT_Entry entry, const char* params, size_t params_len);
864 
873 char* NT_GetRpcResult(NT_Entry entry, NT_RpcCall call, size_t* result_len);
874 
885 char* NT_GetRpcResultTimeout(NT_Entry entry, NT_RpcCall call,
886  size_t* result_len, double timeout,
887  NT_Bool* timed_out);
888 
894 void NT_CancelRpcResult(NT_Entry entry, NT_RpcCall call);
895 
902 char* NT_PackRpcDefinition(const struct NT_RpcDefinition* def,
903  size_t* packed_len);
904 
913 NT_Bool NT_UnpackRpcDefinition(const char* packed, size_t packed_len,
914  struct NT_RpcDefinition* def);
915 
923 char* NT_PackRpcValues(const struct NT_Value** values, size_t values_len,
924  size_t* packed_len);
925 
934 struct NT_Value** NT_UnpackRpcValues(const char* packed, size_t packed_len,
935  const NT_Type* types, size_t types_len);
936 
952 void NT_SetNetworkIdentity(NT_Inst inst, const char* name, size_t name_len);
953 
959 unsigned int NT_GetNetworkMode(NT_Inst inst);
960 
971 void NT_StartServer(NT_Inst inst, const char* persist_filename,
972  const char* listen_address, unsigned int port);
973 
978 void NT_StopServer(NT_Inst inst);
979 
984 void NT_StartClientNone(NT_Inst inst);
985 
993 void NT_StartClient(NT_Inst inst, const char* server_name, unsigned int port);
994 
1005 void NT_StartClientMulti(NT_Inst inst, size_t count, const char** server_names,
1006  const unsigned int* ports);
1007 
1015 void NT_StartClientTeam(NT_Inst inst, unsigned int team, unsigned int port);
1016 
1021 void NT_StopClient(NT_Inst inst);
1022 
1030 void NT_SetServer(NT_Inst inst, const char* server_name, unsigned int port);
1031 
1042 void NT_SetServerMulti(NT_Inst inst, size_t count, const char** server_names,
1043  const unsigned int* ports);
1044 
1053 void NT_SetServerTeam(NT_Inst inst, unsigned int team, unsigned int port);
1054 
1063 void NT_StartDSClient(NT_Inst inst, unsigned int port);
1064 
1069 void NT_StopDSClient(NT_Inst inst);
1070 
1078 void NT_SetUpdateRate(NT_Inst inst, double interval);
1079 
1092 void NT_Flush(NT_Inst inst);
1093 
1105 struct NT_ConnectionInfo* NT_GetConnections(NT_Inst inst, size_t* count);
1106 
1112 NT_Bool NT_IsConnected(NT_Inst inst);
1113 
1129 const char* NT_SavePersistent(NT_Inst inst, const char* filename);
1130 
1140 const char* NT_LoadPersistent(NT_Inst inst, const char* filename,
1141  void (*warn)(size_t line, const char* msg));
1142 
1152 const char* NT_SaveEntries(NT_Inst inst, const char* filename,
1153  const char* prefix, size_t prefix_len);
1154 
1165 const char* NT_LoadEntries(NT_Inst inst, const char* filename,
1166  const char* prefix, size_t prefix_len,
1167  void (*warn)(size_t line, const char* msg));
1168 
1180 void NT_DisposeValue(struct NT_Value* value);
1181 
1187 void NT_InitValue(struct NT_Value* value);
1188 
1193 void NT_DisposeString(struct NT_String* str);
1194 
1200 void NT_InitString(struct NT_String* str);
1201 
1207 void NT_DisposeEntryArray(NT_Entry* arr, size_t count);
1208 
1214 void NT_DisposeConnectionInfoArray(struct NT_ConnectionInfo* arr, size_t count);
1215 
1221 void NT_DisposeEntryInfoArray(struct NT_EntryInfo* arr, size_t count);
1222 
1227 void NT_DisposeEntryInfo(struct NT_EntryInfo* info);
1228 
1233 void NT_DisposeRpcDefinition(struct NT_RpcDefinition* def);
1234 
1240 void NT_DisposeRpcAnswerArray(struct NT_RpcAnswer* arr, size_t count);
1241 
1246 void NT_DisposeRpcAnswer(struct NT_RpcAnswer* answer);
1247 
1254  size_t count);
1255 
1261 
1268  struct NT_ConnectionNotification* arr, size_t count);
1269 
1275 
1281 void NT_DisposeLogMessageArray(struct NT_LogMessage* arr, size_t count);
1282 
1287 void NT_DisposeLogMessage(struct NT_LogMessage* info);
1288 
1295 unsigned long long NT_Now(void);
1296 
1309 typedef void (*NT_LogFunc)(void* data, const struct NT_LogMessage* msg);
1310 
1325 NT_Logger NT_AddLogger(NT_Inst inst, void* data, NT_LogFunc func,
1326  unsigned int min_level, unsigned int max_level);
1327 
1334 NT_LoggerPoller NT_CreateLoggerPoller(NT_Inst inst);
1335 
1341 void NT_DestroyLoggerPoller(NT_LoggerPoller poller);
1342 
1352 NT_Logger NT_AddPolledLogger(NT_LoggerPoller poller, unsigned int min_level,
1353  unsigned int max_level);
1354 
1362 struct NT_LogMessage* NT_PollLogger(NT_LoggerPoller poller, size_t* len);
1363 
1375 struct NT_LogMessage* NT_PollLoggerTimeout(NT_LoggerPoller poller, size_t* len,
1376  double timeout, NT_Bool* timed_out);
1377 
1383 void NT_CancelPollLogger(NT_LoggerPoller poller);
1384 
1389 void NT_RemoveLogger(NT_Logger logger);
1390 
1401 NT_Bool NT_WaitForLoggerQueue(NT_Inst inst, double timeout);
1402 
1426 char* NT_AllocateCharArray(size_t size);
1427 
1439 NT_Bool* NT_AllocateBooleanArray(size_t size);
1440 
1452 double* NT_AllocateDoubleArray(size_t size);
1453 
1465 struct NT_String* NT_AllocateStringArray(size_t size);
1466 
1472 void NT_FreeCharArray(char* v_char);
1473 
1479 void NT_FreeDoubleArray(double* v_double);
1480 
1486 void NT_FreeBooleanArray(NT_Bool* v_boolean);
1487 
1498 void NT_FreeStringArray(struct NT_String* v_string, size_t arr_size);
1499 
1514 enum NT_Type NT_GetValueType(const struct NT_Value* value);
1515 
1525 NT_Bool NT_GetValueBoolean(const struct NT_Value* value,
1526  unsigned long long* last_change, NT_Bool* v_boolean);
1527 
1537 NT_Bool NT_GetValueDouble(const struct NT_Value* value,
1538  unsigned long long* last_change, double* v_double);
1539 
1554 char* NT_GetValueString(const struct NT_Value* value,
1555  unsigned long long* last_change, size_t* str_len);
1556 
1571 char* NT_GetValueRaw(const struct NT_Value* value,
1572  unsigned long long* last_change, size_t* raw_len);
1573 
1588 NT_Bool* NT_GetValueBooleanArray(const struct NT_Value* value,
1589  unsigned long long* last_change,
1590  size_t* arr_size);
1591 
1606 double* NT_GetValueDoubleArray(const struct NT_Value* value,
1607  unsigned long long* last_change,
1608  size_t* arr_size);
1609 
1626 NT_String* NT_GetValueStringArray(const struct NT_Value* value,
1627  unsigned long long* last_change,
1628  size_t* arr_size);
1629 
1641 NT_Bool NT_GetEntryBoolean(NT_Entry entry, unsigned long long* last_change,
1642  NT_Bool* v_boolean);
1643 
1655 NT_Bool NT_GetEntryDouble(NT_Entry entry, unsigned long long* last_change,
1656  double* v_double);
1657 
1671 char* NT_GetEntryString(NT_Entry entry, unsigned long long* last_change,
1672  size_t* str_len);
1673 
1687 char* NT_GetEntryRaw(NT_Entry entry, unsigned long long* last_change,
1688  size_t* raw_len);
1689 
1703 NT_Bool* NT_GetEntryBooleanArray(NT_Entry entry,
1704  unsigned long long* last_change,
1705  size_t* arr_size);
1706 
1720 double* NT_GetEntryDoubleArray(NT_Entry entry, unsigned long long* last_change,
1721  size_t* arr_size);
1722 
1739 NT_String* NT_GetEntryStringArray(NT_Entry entry,
1740  unsigned long long* last_change,
1741  size_t* arr_size);
1742 
1760 NT_Bool NT_SetDefaultEntryBoolean(NT_Entry entry, unsigned long long time,
1761  NT_Bool default_boolean);
1762 
1773 NT_Bool NT_SetDefaultEntryDouble(NT_Entry entry, unsigned long long time,
1774  double default_double);
1775 
1787 NT_Bool NT_SetDefaultEntryString(NT_Entry entry, unsigned long long time,
1788  const char* default_value, size_t default_len);
1789 
1801 NT_Bool NT_SetDefaultEntryRaw(NT_Entry entry, unsigned long long time,
1802  const char* default_value, size_t default_len);
1803 
1815 NT_Bool NT_SetDefaultEntryBooleanArray(NT_Entry entry, unsigned long long time,
1816  const int* default_value,
1817  size_t default_size);
1818 
1830 NT_Bool NT_SetDefaultEntryDoubleArray(NT_Entry entry, unsigned long long time,
1831  const double* default_value,
1832  size_t default_size);
1833 
1845 NT_Bool NT_SetDefaultEntryStringArray(NT_Entry entry, unsigned long long time,
1846  const struct NT_String* default_value,
1847  size_t default_size);
1848 
1866 NT_Bool NT_SetEntryBoolean(NT_Entry entry, unsigned long long time,
1867  NT_Bool v_boolean, NT_Bool force);
1868 
1879 NT_Bool NT_SetEntryDouble(NT_Entry entry, unsigned long long time,
1880  double v_double, NT_Bool force);
1881 
1893 NT_Bool NT_SetEntryString(NT_Entry entry, unsigned long long time,
1894  const char* str, size_t str_len, NT_Bool force);
1895 
1907 NT_Bool NT_SetEntryRaw(NT_Entry entry, unsigned long long time, const char* raw,
1908  size_t raw_len, NT_Bool force);
1909 
1921 NT_Bool NT_SetEntryBooleanArray(NT_Entry entry, unsigned long long time,
1922  const int* arr, size_t size, NT_Bool force);
1923 
1935 NT_Bool NT_SetEntryDoubleArray(NT_Entry entry, unsigned long long time,
1936  const double* arr, size_t size, NT_Bool force);
1937 
1949 NT_Bool NT_SetEntryStringArray(NT_Entry entry, unsigned long long time,
1950  const struct NT_String* arr, size_t size,
1951  NT_Bool force);
1952 
1956 #ifdef __cplusplus
1957 }
1958 #endif
1959 
1960 #endif /* NTCORE_C_H_ */
NT_Bool NT_SetEntryDouble(NT_Entry entry, unsigned long long time, double v_double, NT_Bool force)
Set Entry Double Sets an entry double.
Definition: ntcore_c.cpp:869
void NT_DisposeConnectionNotification(struct NT_ConnectionNotification *info)
Disposes a single connection notification.
Definition: ntcore_c.cpp:792
NT_Bool * NT_GetEntryBooleanArray(NT_Entry entry, unsigned long long *last_change, size_t *arr_size)
Returns a copy of the boolean array assigned to the entry name.
Definition: ntcore_c.cpp:1130
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:456
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:244
NT_EntryListener listener
Listener that was triggered.
Definition: ntcore_c.h:210
unsigned int protocol_version
The protocol version being used for this connection.
Definition: ntcore_c.h:173
void NT_CancelPollConnectionListener(NT_ConnectionListenerPoller poller)
Cancel a PollConnectionListener call.
Definition: ntcore_c.cpp:394
NT_Bool * NT_GetValueBooleanArray(const struct NT_Value *value, unsigned long long *last_change, size_t *arr_size)
Returns a copy of the boolean array from the NT_Value.
Definition: ntcore_c.cpp:994
void NT_FreeDoubleArray(double *v_double)
Frees an array of doubles.
Definition: ntcore_c.cpp:862
NT_Entry entry
Entry handle.
Definition: ntcore_c.h:134
double * NT_GetValueDoubleArray(const struct NT_Value *value, unsigned long long *last_change, size_t *arr_size)
Returns a copy of the double array from the NT_Value.
Definition: ntcore_c.cpp:1007
NT_Bool NT_SetEntryBooleanArray(NT_Entry entry, unsigned long long time, const int *arr, size_t size, NT_Bool force)
Set Entry Boolean Array Sets an entry boolean array.
Definition: ntcore_c.cpp:912
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:461
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:269
NT_Bool NT_SetEntryDoubleArray(NT_Entry entry, unsigned long long time, const double *arr, size_t size, NT_Bool force)
Set Entry Double Array Sets an entry double array.
Definition: ntcore_c.cpp:925
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:304
NT_Entry NT_GetEntry(NT_Inst inst, const char *name, size_t name_len)
Get Entry Handle.
Definition: ntcore_c.cpp:182
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:685
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:476
void NT_RemoveConnectionListener(NT_ConnectionListener conn_listener)
Remove a connection listener.
Definition: ntcore_c.cpp:398
unsigned int remote_port
The port number of the remote node.
Definition: ntcore_c.h:161
NetworkTables RPC Version 1 Definition Result.
Definition: ntcore_c.h:183
NT_Bool NT_SetDefaultEntryRaw(NT_Entry entry, unsigned long long time, const char *default_value, size_t default_len)
Set Default Entry Raw.
Definition: ntcore_c.cpp:1056
NT_Bool connected
True if event is due to connection being established.
Definition: ntcore_c.h:234
NT_Bool NT_WaitForConnectionListenerQueue(NT_Inst inst, double timeout)
Wait for the connection listener queue to be empty.
Definition: ntcore_c.cpp:402
NetworkTables Connection Information.
Definition: ntcore_c.h:150
void NT_CancelPollLogger(NT_LoggerPoller poller)
Cancel a PollLogger call.
Definition: ntcore_c.cpp:707
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:536
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:440
struct NT_LogMessage * NT_PollLogger(NT_LoggerPoller poller, size_t *len)
Get the next log event.
Definition: ntcore_c.cpp:690
NetworkTables Entry Value.
Definition: ntcore_c.h:108
NT_Entry entry
Entry handle.
Definition: ntcore_c.h:213
unsigned int line
The line number in the source file that generated the message.
Definition: ntcore_c.h:252
NT_Bool NT_GetEntryBoolean(NT_Entry entry, unsigned long long *last_change, NT_Bool *v_boolean)
Returns the boolean currently assigned to the entry name.
Definition: ntcore_c.cpp:1090
void NT_FreeBooleanArray(NT_Bool *v_boolean)
Frees an array of booleans.
Definition: ntcore_c.cpp:863
void(* NT_ConnectionListenerCallback)(void *data, const struct NT_ConnectionNotification *event)
Connection listener callback function.
Definition: ntcore_c.h:630
NetworkTables Entry Information.
Definition: ntcore_c.h:132
NT_LoggerPoller NT_CreateLoggerPoller(NT_Inst inst)
Create a log poller.
Definition: ntcore_c.cpp:677
NetworkTables Entry Notification.
Definition: ntcore_c.h:208
void NT_SetUpdateRate(NT_Inst inst, double interval)
Set the periodic update rate.
Definition: ntcore_c.cpp:615
unsigned int NT_GetEntryFlags(NT_Entry entry)
Get Entry Flags.
Definition: ntcore_c.cpp:236
char * NT_GetEntryString(NT_Entry entry, unsigned long long *last_change, size_t *str_len)
Returns a copy of the string assigned to the entry name.
Definition: ntcore_c.cpp:1108
NT_Bool NT_GetValueDouble(const struct NT_Value *value, unsigned long long *last_change, double *v_double)
Returns the double from the NT_Value.
Definition: ntcore_c.cpp:966
double * NT_AllocateDoubleArray(size_t size)
Allocates an array of doubles.
Definition: ntcore_c.cpp:849
NT_ConnectionListener NT_AddConnectionListener(NT_Inst inst, void *data, NT_ConnectionListenerCallback callback, NT_Bool immediate_notify)
Add a connection listener.
Definition: ntcore_c.cpp:349
void NT_DeleteEntry(NT_Entry entry)
Delete Entry.
Definition: ntcore_c.cpp:240
void(* NT_LogFunc)(void *data, const struct NT_LogMessage *msg)
Log function.
Definition: ntcore_c.h:1309
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:596
NT_Bool NT_WaitForEntryListenerQueue(NT_Inst inst, double timeout)
Wait for the entry listener queue to be empty.
Definition: ntcore_c.cpp:345
NT_Bool NT_SetDefaultEntryString(NT_Entry entry, unsigned long long time, const char *default_value, size_t default_len)
Set Default Entry String.
Definition: ntcore_c.cpp:1049
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:592
char * NT_AllocateCharArray(size_t size)
Allocates an array of chars.
Definition: ntcore_c.cpp:837
void NT_DestroyConnectionListenerPoller(NT_ConnectionListenerPoller poller)
Destroy a connection listener poller.
Definition: ntcore_c.cpp:366
NT_Bool NT_GetEntryDouble(NT_Entry entry, unsigned long long *last_change, double *v_double)
Returns the double currently assigned to the entry name.
Definition: ntcore_c.cpp:1099
double * NT_GetEntryDoubleArray(NT_Entry entry, unsigned long long *last_change, size_t *arr_size)
Returns a copy of the double array assigned to the entry name.
Definition: ntcore_c.cpp:1143
struct NT_EntryNotification * NT_PollEntryListener(NT_EntryListenerPoller poller, size_t *len)
Get the next entry listener event.
Definition: ntcore_c.cpp:318
NT_Bool NT_SetDefaultEntryBoolean(NT_Entry entry, unsigned long long time, NT_Bool default_boolean)
Set Default Entry Boolean.
Definition: ntcore_c.cpp:1037
NetworkTables log message.
Definition: ntcore_c.h:241
NT_ConnectionListener NT_AddPolledConnectionListener(NT_ConnectionListenerPoller poller, NT_Bool immediate_notify)
Create a polled connection listener.
Definition: ntcore_c.cpp:370
unsigned int flags
Update flags.
Definition: ntcore_c.h:225
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:648
void NT_FreeCharArray(char *v_char)
Frees an array of chars.
Definition: ntcore_c.cpp:861
void NT_FreeStringArray(struct NT_String *v_string, size_t arr_size)
Frees an array of NT_Strings.
Definition: ntcore_c.cpp:864
void NT_DestroyInstance(NT_Inst inst)
Destroy an instance.
Definition: ntcore_c.cpp:172
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:586
void NT_Flush(NT_Inst inst)
Flush Entries.
Definition: ntcore_c.cpp:619
NT_Bool NT_SetDefaultEntryStringArray(NT_Entry entry, unsigned long long time, const struct NT_String *default_value, size_t default_size)
Set Default Entry String Array.
Definition: ntcore_c.cpp:1078
NT_Bool NT_IsConnected(NT_Inst inst)
Return whether or not the instance is connected to another node.
Definition: ntcore_c.cpp:621
NT_Bool NT_WaitForLoggerQueue(NT_Inst inst, double timeout)
Wait for the incoming log event queue to be empty.
Definition: ntcore_c.cpp:713
void NT_DisposeEntryArray(NT_Entry *arr, size_t count)
Disposes an entry handle array.
Definition: ntcore_c.cpp:763
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:428
void NT_StartDSClient(NT_Inst inst, unsigned int port)
Starts requesting server address from Driver Station.
Definition: ntcore_c.cpp:609
NT_String * NT_GetValueStringArray(const struct NT_Value *value, unsigned long long *last_change, size_t *arr_size)
Returns a copy of the NT_String array from the NT_Value.
Definition: ntcore_c.cpp:1020
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:758
unsigned int flags
Entry flags.
Definition: ntcore_c.h:143
char * message
The message.
Definition: ntcore_c.h:255
NetworkTables RPC Call Data.
Definition: ntcore_c.h:199
unsigned long long last_change
Timestamp of last change to entry (type or value).
Definition: ntcore_c.h:146
void NT_SetEntryFlags(NT_Entry entry, unsigned int flags)
Set Entry Flags.
Definition: ntcore_c.cpp:232
NT_Logger logger
The logger that generated the message.
Definition: ntcore_c.h:243
void NT_DisposeEntryNotification(struct NT_EntryNotification *info)
Disposes a single entry notification.
Definition: ntcore_c.cpp:782
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:605
void(* NT_EntryListenerCallback)(void *data, const NT_EntryNotification *event)
Entry listener callback function.
Definition: ntcore_c.h:485
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:643
char * NT_GetEntryRaw(NT_Entry entry, unsigned long long *last_change, size_t *raw_len)
Returns a copy of the raw value assigned to the entry name.
Definition: ntcore_c.cpp:1119
void NT_SetEntryTypeValue(NT_Entry entry, const struct NT_Value *value)
Set Entry Type and Value.
Definition: ntcore_c.cpp:228
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:508
NT_Bool * NT_AllocateBooleanArray(size_t size)
Allocates an array of booleans.
Definition: ntcore_c.cpp:843
void NT_DestroyEntryListenerPoller(NT_EntryListenerPoller poller)
Destroy a entry listener poller.
Definition: ntcore_c.cpp:300
void NT_DisposeLogMessage(struct NT_LogMessage *info)
Disposes a single log message.
Definition: ntcore_c.cpp:801
NT_String * NT_GetEntryStringArray(NT_Entry entry, unsigned long long *last_change, size_t *arr_size)
Returns a copy of the NT_String array assigned to the entry name.
Definition: ntcore_c.cpp:1155
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:577
enum NT_Type NT_GetEntryType(NT_Entry entry)
Gets the type for the specified key, or unassigned if non existent.
Definition: ntcore_c.cpp:206
char * NT_GetValueString(const struct NT_Value *value, unsigned long long *last_change, size_t *str_len)
Returns a copy of the string from the NT_Value.
Definition: ntcore_c.cpp:974
void NT_DisposeString(struct NT_String *str)
Frees string memory.
Definition: ntcore_c.cpp:752
NT_EntryListener NT_AddPolledEntryListenerSingle(NT_EntryListenerPoller poller, NT_Entry entry, unsigned int flags)
Create a polled entry listener.
Definition: ntcore_c.cpp:312
void NT_StopDSClient(NT_Inst inst)
Stops requesting server address from Driver Station.
Definition: ntcore_c.cpp:613
const char * filename
The filename of the source file that generated the message.
Definition: ntcore_c.h:249
unsigned long long NT_GetEntryLastChange(NT_Entry entry)
Gets the last time the entry was changed.
Definition: ntcore_c.cpp:208
NT_Bool NT_SetEntryRaw(NT_Entry entry, unsigned long long 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:901
unsigned int level
Log level of the message.
Definition: ntcore_c.h:246
void NT_InitValue(struct NT_Value *value)
Initializes a NT_Value.
Definition: ntcore_c.cpp:747
unsigned long long last_update
The last time any update was received from the remote node (same scale as returned by nt::Now())...
Definition: ntcore_c.h:167
void NT_StopServer(NT_Inst inst)
Stops the server if it is running.
Definition: ntcore_c.cpp:569
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:653
NT_Bool NT_SetDefaultEntryDoubleArray(NT_Entry entry, unsigned long long time, const double *default_value, size_t default_size)
Set Default Entry Double Array.
Definition: ntcore_c.cpp:1070
const char * NT_SavePersistent(NT_Inst inst, const char *filename)
Save persistent values to a file.
Definition: ntcore_c.cpp:639
unsigned long long NT_Now(void)
Returns monotonic current time in 100 ns increments.
Definition: ntcore_c.cpp:663
NT_RpcCallPoller NT_CreateRpcCallPoller(NT_Inst inst)
Create a RPC call poller.
Definition: ntcore_c.cpp:420
void NT_DeleteAllEntries(NT_Inst inst)
Delete All Entries.
Definition: ntcore_c.cpp:242
void NT_DisposeConnectionNotificationArray(struct NT_ConnectionNotification *arr, size_t count)
Disposes a connection notification array.
Definition: ntcore_c.cpp:786
void NT_GetEntryValue(NT_Entry entry, struct NT_Value *value)
Get Entry Value.
Definition: ntcore_c.cpp:212
void NT_CancelRpcResult(NT_Entry entry, NT_RpcCall call)
Ignore the result of a RPC call.
Definition: ntcore_c.cpp:494
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:186
NT_EntryListenerPoller NT_CreateEntryListenerPoller(NT_Inst inst)
Create a entry listener poller.
Definition: ntcore_c.cpp:296
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:564
void NT_StartClientNone(NT_Inst inst)
Starts a client.
Definition: ntcore_c.cpp:571
NT_ConnectionListenerPoller NT_CreateConnectionListenerPoller(NT_Inst inst)
Create a connection listener poller.
Definition: ntcore_c.cpp:362
struct NT_ConnectionNotification * NT_PollConnectionListener(NT_ConnectionListenerPoller poller, size_t *len)
Get the next connection event.
Definition: ntcore_c.cpp:375
void NT_DisposeValue(struct NT_Value *value)
Frees value memory.
Definition: ntcore_c.cpp:717
void(* NT_RpcCallback)(void *data, const struct NT_RpcAnswer *call)
Remote Procedure Call (RPC) callback function.
Definition: ntcore_c.h:745
void NT_SetNetworkIdentity(NT_Inst inst, const char *name, size_t name_len)
Set the network identity of this node.
Definition: ntcore_c.cpp:556
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:573
NT_Inst NT_CreateInstance(void)
Create an instance.
Definition: ntcore_c.cpp:170
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:465
NT_Bool NT_SetEntryValue(NT_Entry entry, const struct NT_Value *value)
Set Entry Value.
Definition: ntcore_c.cpp:224
NT_Inst NT_GetInstanceFromHandle(NT_Handle handle)
Get instance handle from another handle.
Definition: ntcore_c.cpp:174
struct NT_ConnectionInfo * NT_GetConnections(NT_Inst inst, size_t *count)
Get information on the currently established network connections.
Definition: ntcore_c.cpp:623
struct NT_RpcAnswer * NT_PollRpc(NT_RpcCallPoller poller, size_t *len)
Get the next incoming RPC call.
Definition: ntcore_c.cpp:433
void NT_DisposeConnectionInfoArray(struct NT_ConnectionInfo *arr, size_t count)
Disposes a connection info array.
Definition: ntcore_c.cpp:765
void NT_DisposeEntryInfo(struct NT_EntryInfo *info)
Disposes a single entry info (as returned by NT_GetEntryInfoHandle).
Definition: ntcore_c.cpp:775
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:697
NT_Bool NT_SetEntryBoolean(NT_Entry entry, unsigned long long time, NT_Bool v_boolean, NT_Bool force)
Set Entry Boolean Sets an entry boolean.
Definition: ntcore_c.cpp:879
NT_Bool NT_SetEntryStringArray(NT_Entry entry, unsigned long long 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:937
void NT_DisposeEntryNotificationArray(struct NT_EntryNotification *arr, size_t count)
Disposes an entry notification array.
Definition: ntcore_c.cpp:777
void NT_DisposeEntryInfoArray(struct NT_EntryInfo *arr, size_t count)
Disposes an entry info array.
Definition: ntcore_c.cpp:770
A NetworkTables string.
Definition: ntcore_c.h:91
NT_Bool NT_WaitForRpcCallQueue(NT_Inst inst, double timeout)
Wait for the incoming RPC call queue to be empty.
Definition: ntcore_c.cpp:452
NetworkTables RPC Version 1 Definition.
Definition: ntcore_c.h:189
char * NT_GetValueRaw(const struct NT_Value *value, unsigned long long *last_change, size_t *raw_len)
Returns a copy of the raw value from the NT_Value.
Definition: ntcore_c.cpp:984
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:326
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:410
NetworkTables RPC Version 1 Definition Parameter.
Definition: ntcore_c.h:177
void NT_DestroyLoggerPoller(NT_LoggerPoller poller)
Destroy a log poller.
Definition: ntcore_c.cpp:681
struct NT_String * NT_AllocateStringArray(size_t size)
Allocates an array of NT_Strings.
Definition: ntcore_c.cpp:855
void NT_RemoveEntryListener(NT_EntryListener entry_listener)
Remove an entry listener.
Definition: ntcore_c.cpp:341
NT_Inst NT_GetDefaultInstance(void)
Get default instance.
Definition: ntcore_c.cpp:168
char * str
String contents (UTF-8).
Definition: ntcore_c.h:98
void NT_RemoveLogger(NT_Logger logger)
Remove a logger.
Definition: ntcore_c.cpp:711
size_t len
Length of the string in bytes.
Definition: ntcore_c.h:104
unsigned int NT_GetNetworkMode(NT_Inst inst)
Get the current network mode.
Definition: ntcore_c.cpp:560
NT_Bool NT_SetDefaultEntryDouble(NT_Entry entry, unsigned long long time, double default_double)
Set Default Entry Double.
Definition: ntcore_c.cpp:1043
void NT_DisposeRpcDefinition(struct NT_RpcDefinition *def)
Disposes a Rpc Definition structure.
Definition: ntcore_c.cpp:803
void NT_CancelPollEntryListener(NT_EntryListenerPoller poller)
Cancel a PollEntryListener call.
Definition: ntcore_c.cpp:337
char * NT_GetEntryName(NT_Entry entry, size_t *name_len)
Gets the name of the specified entry.
Definition: ntcore_c.cpp:199
enum NT_Type NT_GetValueType(const struct NT_Value *value)
Returns the type of an NT_Value struct.
Definition: ntcore_c.cpp:952
void NT_StopClient(NT_Inst inst)
Stops the client if it is running.
Definition: ntcore_c.cpp:590
void NT_DisposeRpcAnswerArray(struct NT_RpcAnswer *arr, size_t count)
Disposes a Rpc Answer array.
Definition: ntcore_c.cpp:821
NT_Bool NT_GetValueBoolean(const struct NT_Value *value, unsigned long long *last_change, NT_Bool *v_boolean)
Returns the boolean from the NT_Value.
Definition: ntcore_c.cpp:957
void NT_CancelPollRpc(NT_RpcCallPoller poller)
Cancel a PollRpc call.
Definition: ntcore_c.cpp:450
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:283
NT_Bool NT_GetEntryInfoHandle(NT_Entry entry, struct NT_EntryInfo *info)
Get Entry Information.
Definition: ntcore_c.cpp:258
void NT_DisposeRpcAnswer(struct NT_RpcAnswer *answer)
Disposes a Rpc Answer structure.
Definition: ntcore_c.cpp:826
NetworkTables Connection Notification.
Definition: ntcore_c.h:229
void NT_DestroyRpcCallPoller(NT_RpcCallPoller poller)
Destroy a RPC call poller.
Definition: ntcore_c.cpp:424
NT_Bool NT_SetDefaultEntryBooleanArray(NT_Entry entry, unsigned long long time, const int *default_value, size_t default_size)
Set Default Entry Boolean Array.
Definition: ntcore_c.cpp:1062
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:383
NT_Bool NT_SetEntryString(NT_Entry entry, unsigned long long time, const char *str, size_t str_len, NT_Bool force)
Set Entry String Sets an entry string.
Definition: ntcore_c.cpp:889
NT_ConnectionListener listener
Listener that was triggered.
Definition: ntcore_c.h:231
void NT_DisposeLogMessageArray(struct NT_LogMessage *arr, size_t count)
Disposes a log message array.
Definition: ntcore_c.cpp:796
NT_Bool NT_SetDefaultEntryValue(NT_Entry entry, const struct NT_Value *default_value)
Set Default Entry Value.
Definition: ntcore_c.cpp:219
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:665