Rodbus-FFI  0.1.1
Idiomatic C API to the Rodbus crate via Rust FFI
rodbus.h
Go to the documentation of this file.
1 #ifndef RODBUS_FFI_H
2 #define RODBUS_FFI_H
3 
4 /* Generated with cbindgen:0.12.1 */
5 
6 /* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */
7 
8 #include <stdarg.h>
9 #include <stdbool.h>
10 #include <stdint.h>
11 #include <stdlib.h>
12 #include "prelude.h"
13 
14 #define MAX_READ_COILS_COUNT 2000
15 
16 #define MAX_READ_REGISTERS_COUNT 125
17 
18 #define MAX_WRITE_COILS_COUNT 1968
19 
20 #define MAX_WRITE_REGISTERS_COUNT 123
21 
25 enum Exception {
70 };
71 typedef uint8_t Exception;
72 
76 enum Level {
82 };
83 typedef uint8_t Level;
84 
88 enum Status {
129 };
130 typedef uint8_t Status;
131 
135 typedef struct Session {
147  uint8_t unit_id;
151  uint32_t timeout_ms;
152 } Session;
153 
157 typedef struct RuntimeConfig {
163 } RuntimeConfig;
164 
168 typedef struct Result {
177  uint8_t exception;
178 } Result;
179 
192  Channel *channel,
193  uint8_t unit_id,
194  uint32_t timeout_ms);
195 
210  const char *address,
211  uint16_t max_queued_requests);
212 
225 
238 
252 
265 Result read_coils(Session *session,
266  uint16_t start,
267  uint16_t count,
268  bool *output);
269 
281 void read_coils_cb(Session *session,
282  uint16_t start,
283  uint16_t count,
284  void (*callback)(Result, const bool*, uint16_t, void*),
285  void *user_data);
286 
300  uint16_t start,
301  uint16_t count,
302  bool *output);
303 
315 void read_discrete_inputs_cb(Session *session,
316  uint16_t start,
317  uint16_t count,
318  void (*callback)(Result, const bool*, uint16_t, void*),
319  void *user_data);
320 
334  uint16_t start,
335  uint16_t count,
336  uint16_t *output);
337 
349 void read_holding_registers_cb(Session *session,
350  uint16_t start,
351  uint16_t count,
352  void (*callback)(Result, const uint16_t*, uint16_t, void*),
353  void *user_data);
354 
368  uint16_t start,
369  uint16_t count,
370  uint16_t *output);
371 
383 void read_input_registers_cb(Session *session,
384  uint16_t start,
385  uint16_t count,
386  void (*callback)(Result, const uint16_t*, uint16_t, void*),
387  void *user_data);
388 
397 bool set_log_callback(void (*callback)(Level level, const char *message));
398 
404 void set_max_level(Level level);
405 
419 Result write_multiple_coils(Session *session, uint16_t start, const bool *values, uint16_t count);
420 
435 void write_multiple_coils_cb(Session *session,
436  uint16_t start,
437  const bool *values,
438  uint16_t count,
439  void (*callback)(Result, void*),
440  void *user_data);
441 
456  uint16_t start,
457  const uint16_t *values,
458  uint16_t count);
459 
475  uint16_t start,
476  const uint16_t *values,
477  uint16_t count,
478  void (*callback)(Result, void*),
479  void *user_data);
480 
491 Result write_single_coil(Session *session, uint16_t index, bool value);
492 
504 void write_single_coil_cb(Session *session,
505  uint16_t index,
506  bool value,
507  void (*callback)(Result, void*),
508  void *user_data);
509 
520 Result write_single_register(Session *session, uint16_t index, uint16_t value);
521 
533 void write_single_register_cb(Session *session,
534  uint16_t index,
535  uint16_t value,
536  void (*callback)(Result, void*),
537  void *user_data);
538 
539 #endif /* RODBUS_FFI_H */
void read_coils_cb(Session *session, uint16_t start, uint16_t count, void(*callback)(Result, const bool *, uint16_t, void *), void *user_data)
perform a non-blocking operation to read coils
void destroy_channel(Channel *channel)
Destroy a previously created channel instance.
Definition: rodbus.h:80
Struct that bundles together the types needed to make requests on a channel.
Definition: rodbus.h:135
Definition: rodbus.h:79
Runtime * runtime
Definition: rodbus.h:139
Definition: rodbus.h:29
Definition: rodbus.h:108
struct RuntimeConfig RuntimeConfig
Optional non-default configuration of the Tokio runtime.
Optional non-default configuration of the Tokio runtime.
Definition: rodbus.h:157
Definition: rodbus.h:33
Definition: rodbus.h:92
Definition: rodbus.h:58
Session build_session(Runtime *runtime, Channel *channel, uint8_t unit_id, uint32_t timeout_ms)
Convenience function to build a session struct.
void write_multiple_registers_cb(Session *session, uint16_t start, const uint16_t *values, uint16_t count, void(*callback)(Result, void *), void *user_data)
perform a non-blocking operation to write multiple registers
Channel * channel
Definition: rodbus.h:143
Definition: rodbus.h:116
Definition: rodbus.h:78
Definition: rodbus.h:64
bool set_log_callback(void(*callback)(Level level, const char *message))
set the callback to invoke when an enabled level is logged
Definition: rodbus.h:124
Result read_input_registers(Session *session, uint16_t start, uint16_t count, uint16_t *output)
perform a blocking operation to read input registers
Definition: rodbus.h:47
Definition: rodbus.h:77
Definition: rodbus.h:42
struct Result Result
Type that describes the success or failure of an operation.
Definition: rodbus.h:81
Result write_single_register(Session *session, uint16_t index, uint16_t value)
perform a blocking operation to write a single register
Result read_discrete_inputs(Session *session, uint16_t start, uint16_t count, bool *output)
perform a blocking operation to read discrete inputs
struct Runtime Runtime
Opaque pointer type for the Tokio runtime.
Definition: prelude.h:8
Definition: rodbus.h:100
void destroy_runtime(Runtime *runtime)
Destroy a previously created runtime instance.
uint16_t num_core_threads
Definition: rodbus.h:162
Definition: rodbus.h:37
void read_holding_registers_cb(Session *session, uint16_t start, uint16_t count, void(*callback)(Result, const uint16_t *, uint16_t, void *), void *user_data)
perform a non-blocking operation to read holding registers
void write_single_coil_cb(Session *session, uint16_t index, bool value, void(*callback)(Result, void *), void *user_data)
perform a non-blocking operation to write a single coil
void write_multiple_coils_cb(Session *session, uint16_t start, const bool *values, uint16_t count, void(*callback)(Result, void *), void *user_data)
perform a non-blocking operation to write multiple coils
Runtime * create_threaded_runtime(const RuntimeConfig *config)
create an instance of the multi-threaded work-stealing Tokio runtime
Definition: rodbus.h:120
uint8_t exception
Definition: rodbus.h:177
Channel * create_tcp_client(Runtime *runtime, const char *address, uint16_t max_queued_requests)
Create an instance of a TCP client channel.
Definition: rodbus.h:128
Definition: rodbus.h:52
Result read_holding_registers(Session *session, uint16_t start, uint16_t count, uint16_t *output)
perform a blocking operation to read holding registers
Definition: rodbus.h:112
void set_max_level(Level level)
set the maximum log level
struct Session Session
Struct that bundles together the types needed to make requests on a channel.
uint8_t unit_id
Definition: rodbus.h:147
Status status
Definition: rodbus.h:172
Definition: rodbus.h:104
void read_input_registers_cb(Session *session, uint16_t start, uint16_t count, void(*callback)(Result, const uint16_t *, uint16_t, void *), void *user_data)
perform a non-blocking operation to read input registers
Exception
Definition: rodbus.h:25
Status
Definition: rodbus.h:88
uint32_t timeout_ms
Definition: rodbus.h:151
Result write_single_coil(Session *session, uint16_t index, bool value)
perform a blocking operation to write a single coil
void read_discrete_inputs_cb(Session *session, uint16_t start, uint16_t count, void(*callback)(Result, const bool *, uint16_t, void *), void *user_data)
perform a non-blocking operation to read discrete inputs
Definition: rodbus.h:96
struct Channel Channel
Opaque pointer type for the Channel.
Definition: prelude.h:11
Result write_multiple_coils(Session *session, uint16_t start, const bool *values, uint16_t count)
perform a blocking operation to write multiple coils
void write_single_register_cb(Session *session, uint16_t index, uint16_t value, void(*callback)(Result, void *), void *user_data)
perform a non-blocking operation to write a single register
Level
Definition: rodbus.h:76
Result write_multiple_registers(Session *session, uint16_t start, const uint16_t *values, uint16_t count)
perform a blocking operation to write multiple registers
Result read_coils(Session *session, uint16_t start, uint16_t count, bool *output)
perform a blocking operation to read coils
Type that describes the success or failure of an operation.
Definition: rodbus.h:168