1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
extern crate canadensis_core;
extern crate canadensis_header;
extern crate crc_any;
pub extern crate embedded_nal;
extern crate fallible_collections;
extern crate hash32;
extern crate hash32_derive;
extern crate heapless;
extern crate log;
extern crate nb;
extern crate zerocopy;
use canadensis_core::transport::Transport;
use canadensis_core::{OutOfMemoryError, Priority};
use canadensis_header::{NodeId16, TransferId64};
use core::fmt::Debug;
use crc_any::CRCu32;
pub use crate::rx::{UdpReceiver, UdpSessionData};
pub use crate::tx::UdpTransmitter;
mod address;
pub mod driver;
mod rx;
mod tx;
const TRANSFER_CRC_SIZE: usize = 4;
pub const MIN_PACKET_SIZE: usize = canadensis_header::SIZE + 1 + TRANSFER_CRC_SIZE;
pub const DEFAULT_PORT: u16 = 9382;
pub struct UdpTransport(());
impl Transport for UdpTransport {
type NodeId = UdpNodeId;
type TransferId = UdpTransferId;
type Priority = Priority;
}
pub type UdpNodeId = NodeId16;
pub struct UdpTransferIds([UdpTransferId; u16::MAX as usize + 1]);
impl Default for UdpTransferIds {
fn default() -> Self {
UdpTransferIds([UdpTransferId::default(); u16::MAX as usize + 1])
}
}
impl AsMut<[UdpTransferId]> for UdpTransferIds {
fn as_mut(&mut self) -> &mut [UdpTransferId] {
&mut self.0
}
}
pub type UdpTransferId = TransferId64;
#[derive(Debug)]
pub enum Error<S> {
Memory(OutOfMemoryError),
Socket(S),
}
impl<S> From<OutOfMemoryError> for Error<S> {
fn from(oom: OutOfMemoryError) -> Self {
Error::Memory(oom)
}
}
fn data_crc() -> CRCu32 {
CRCu32::crc32c()
}