@@ -44,11 +44,17 @@ pub trait Frame {
44
44
}
45
45
46
46
/// A Can-FD Frame
47
+ ///
48
+ /// A "ordinary" Can-Frame must also be representable by this type.
47
49
#[ cfg( feature = "unproven" ) ]
48
50
pub trait FdFrame {
49
51
/// The Id type of this Frame
50
52
type Id : Id ;
51
53
54
+ /// Returns true if this frame would/has be(en) transmitted as a Can-Fd frame.
55
+ /// Returns false if this frame would/has be(en) transmitted as a "ordinary" Can frame.
56
+ fn is_fd_frame ( & self ) -> bool ;
57
+
52
58
/// Returns the Can-ID
53
59
fn id ( & self ) -> Self :: Id ;
54
60
@@ -67,47 +73,39 @@ pub trait Interface {
67
73
/// The Interface Error type
68
74
type Error ;
69
75
70
- /// Read the available `Frame` with the highest priority (lowest ID).
76
+ /// Return the available `Frame` with the highest priority (lowest ID).
71
77
///
72
78
/// NOTE: Can-FD Frames will not be received using this function.
73
79
fn receive ( & mut self ) -> nb:: Result < Self :: Frame , Self :: Error > ;
74
80
75
81
/// Put a `Frame` in the transmit buffer (or a free mailbox).
76
82
///
77
83
/// If the buffer is full, this function will try to replace a lower priority `Frame`
78
- /// and return it.
84
+ /// and return it. This is to avoid the priority inversion problem.
79
85
fn transmit ( & mut self , frame : & Self :: Frame ) -> nb:: Result < Option < Self :: Frame > , Self :: Error > ;
80
86
81
- /// Put a `Frame` in the transmit buffer (or a free mailbox).
82
- ///
83
- /// A high priority `Frame` is prone to being blocked when this function is used.
84
- fn transmit_without_priority ( & mut self , frame : & Self :: Frame ) -> nb:: Result < ( ) , Self :: Error > ;
87
+ /// Returns true if a call to `transmit(frame)` (and if the interface supports Can-FD)
88
+ /// `transmit_fd(fd_frame)` would return a `Frame` or `WouldBlock`.
89
+ fn transmit_buffer_full ( & self ) -> bool ;
85
90
86
91
}
87
92
88
- /// A CAN-FD interface
93
+ /// A CAN interface also supporting Can-FD
89
94
#[ cfg( feature = "unproven" ) ]
90
- pub trait FdInterface {
95
+ pub trait FdInterface : Interface {
91
96
/// The Can Frame this Interface operates on
92
- type Frame : FdFrame ;
93
-
94
- /// The Interface Error type
95
- type Error ;
97
+ type FdFrame : FdFrame ;
96
98
97
99
/// Read the available `FdFrame` with the highest priority (lowest ID).
98
- ///
99
- /// NOTE: ordinary Can Frames will not be received using this function.
100
- fn receive_fd ( & mut self ) -> nb:: Result < Self :: Frame , Self :: Error > ;
100
+ fn receive ( & mut self ) -> nb:: Result < Self :: FdFrame , Self :: Error > ;
101
101
102
102
/// Put a `FdFrame` in the transmit buffer (or a free mailbox).
103
103
///
104
104
/// If the buffer is full, this function will try to replace a lower priority `FdFrame`
105
- /// and return it.
106
- fn transmit_fd ( & mut self , frame : & Self :: Frame ) -> nb:: Result < Option < Self :: Frame > , Self :: Error > ;
107
-
108
- /// Put a `FdFrame` in the transmit buffer (or a free mailbox).
109
- ///
110
- /// A high priority `FdFrame` is prone to being blocked when this function is used.
111
- fn transmit_fd_without_priority ( & mut self , frame : & Self :: Frame ) -> nb:: Result < ( ) , Self :: Error > ;
105
+ /// and return it. This is to avoid the priority inversion problem.
106
+ fn transmit ( & mut self , frame : & Self :: FdFrame ) -> nb:: Result < Option < Self :: FdFrame > , Self :: Error > ;
112
107
108
+ /// Returns true if a call to `transmit(frame)` or `transmit_fd(fd_frame)`
109
+ /// would return a `FdFrame` or `WouldBlock`.
110
+ fn transmit_buffer_full ( & self ) -> bool ;
113
111
}
0 commit comments