update bindings again
This commit is contained in:
parent
75672c79b4
commit
776da7b55e
@ -1,5 +1,5 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"libcsp-cargo-build", "libcsp-rust", "libcsp-sys", "examples"
|
"libcsp-cargo-build", "libcsp", "libcsp-sys", "examples"
|
||||||
]
|
]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
3766
clib/bindings.rs
3766
clib/bindings.rs
File diff suppressed because it is too large
Load Diff
@ -1,2 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
bindgen --use-core wrapper.h -- "-I./libcsp/include" "-I./cfg" "-I./libcsp/src" > bindings.rs
|
bindgen_cmd="bindgen --use-core wrapper.h -- '-I./libcsp/include' '-I./cfg' '-I./libcsp/src' > bindings.rs"
|
||||||
|
echo "Running: $bindgen_cmd"
|
||||||
|
eval $bindgen_cmd
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
#include "csp/csp.h"
|
#include "csp/csp.h"
|
||||||
|
#include "csp/interfaces/csp_if_lo.h"
|
||||||
|
#include "csp/interfaces/csp_if_udp.h"
|
||||||
#include "csp_conn.h"
|
#include "csp_conn.h"
|
||||||
|
@ -6,8 +6,8 @@ fn main() {
|
|||||||
let out_dir = env::var("OUT_DIR").unwrap_or_default();
|
let out_dir = env::var("OUT_DIR").unwrap_or_default();
|
||||||
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap_or_default();
|
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap_or_default();
|
||||||
let manifest_path = PathBuf::from(&manifest_dir);
|
let manifest_path = PathBuf::from(&manifest_dir);
|
||||||
let lib_cfg_dir = "../lib/cfg/csp";
|
let lib_cfg_dir = "../clib/cfg/csp";
|
||||||
let libcsp_path = "../lib/libcsp";
|
let libcsp_path = "../clib/libcsp";
|
||||||
|
|
||||||
// This helper structure will take care of the majority of work to compile libcsp using the
|
// This helper structure will take care of the majority of work to compile libcsp using the
|
||||||
// cc crate.
|
// cc crate.
|
||||||
|
@ -350,6 +350,21 @@ pub fn csp_read_guarded(conn: &mut CspConnRef, timeout: Duration) -> Option<CspP
|
|||||||
Some(CspPacketRefGuard(Some(csp_read(conn, timeout)?)))
|
Some(CspPacketRefGuard(Some(csp_read(conn, timeout)?)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Rust wrapper for [ffi::csp_recvfrom].
|
||||||
|
pub fn csp_recvfrom(socket: &mut CspSocket, timeout: u32) -> Option<CspPacketRef> {
|
||||||
|
let opt_packet = unsafe { ffi::csp_recvfrom(&mut socket.0, timeout) };
|
||||||
|
if opt_packet.is_null() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
Some(CspPacketRef(unsafe { &mut *opt_packet }))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Rust wrapper for [ffi::csp_recvfrom] which returns a guarded packet reference. This packet
|
||||||
|
/// will cleaned up automatically with [csp_buffer_free] on drop.
|
||||||
|
pub fn csp_recvfrom_guarded(socket: &mut CspSocket, timeout: u32) -> Option<CspPacketRefGuard> {
|
||||||
|
Some(CspPacketRefGuard(Some(csp_recvfrom(socket, timeout)?)))
|
||||||
|
}
|
||||||
|
|
||||||
/// Rust wrapper for [ffi::csp_conn_dport].
|
/// Rust wrapper for [ffi::csp_conn_dport].
|
||||||
pub fn csp_conn_dport(conn: &CspConnRef) -> i32 {
|
pub fn csp_conn_dport(conn: &CspConnRef) -> i32 {
|
||||||
// SAFETY: FFI call.
|
// SAFETY: FFI call.
|
||||||
@ -507,3 +522,38 @@ pub fn csp_transaction_persistent(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Rust wrapper for [ffi::csp_transaction_w_opts].
|
||||||
|
///
|
||||||
|
/// # Parameters
|
||||||
|
///
|
||||||
|
/// * `in_len`: Use [None] if the length is unknown, and the expected reply length otherwise.
|
||||||
|
///
|
||||||
|
/// # Returns
|
||||||
|
///
|
||||||
|
/// 1 or reply size on success, 0 otherwise.
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
pub fn csp_transaction_w_opts(
|
||||||
|
prio: MsgPriority,
|
||||||
|
dst: u16,
|
||||||
|
dst_port: u8,
|
||||||
|
timeout: Duration,
|
||||||
|
out_data: &[u8],
|
||||||
|
in_data: &mut [u8],
|
||||||
|
in_len: Option<usize>,
|
||||||
|
opts: ConnectOpts,
|
||||||
|
) -> i32 {
|
||||||
|
unsafe {
|
||||||
|
ffi::csp_transaction_w_opts(
|
||||||
|
prio as u8,
|
||||||
|
dst,
|
||||||
|
dst_port,
|
||||||
|
timeout.as_millis() as u32,
|
||||||
|
out_data.as_ptr() as *const core::ffi::c_void,
|
||||||
|
out_data.len() as i32,
|
||||||
|
in_data.as_ptr() as *mut core::ffi::c_void,
|
||||||
|
in_len.map(|v| v as i32).unwrap_or(-1),
|
||||||
|
opts.bits(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user