ethercat_soem_ctx/group.rs
1use ethercat_soem_sys as sys;
2use std::{fmt, mem};
3
4/// SOEM `ec_group` wrapper
5#[repr(C)]
6pub struct Group(pub(crate) sys::ec_group);
7
8impl Default for Group {
9 fn default() -> Self {
10 Group(unsafe { mem::zeroed() })
11 }
12}
13
14impl Group {
15 // TODO:
16 // logical start address for this group
17 //pub logstartaddr: uint32,
18
19 // TODO:
20 // output bytes, if Obits < 8 then Obytes = 0
21 //pub Obytes: uint32,
22
23 // TODO:
24 // output pointer in IOmap buffer
25 //pub outputs: *mut uint8,
26
27 // TODO:
28 // input bytes, if Ibits < 8 then Ibytes = 0
29 //pub Ibytes: uint32,
30
31 // TODO:
32 // input pointer in IOmap buffer
33 //pub inputs: *mut uint8,
34
35 // TODO:
36 // has DC capability
37 // pub hasdc: boolean,
38
39 // TODO:
40 // next DC slave
41 // pub DCnext: uint16,
42
43 // TODO:
44 // E-bus current
45 // pub Ebuscurrent: int16,
46
47 // TODO:
48 // if >0 block use of LRW in processdata
49 // pub blockLRW: uint8,
50
51 // TODO:
52 // IO segments used
53 // pub nsegments: uint16,
54
55 // TODO:
56 // 1st input segment
57 // pub Isegment: uint16,
58
59 // TODO:
60 // Offset in input segment
61 // pub Ioffset: uint16,
62
63 /// Expected workcounter outputs
64 pub const fn outputs_wkc(&self) -> u16 {
65 self.0.outputsWKC
66 }
67 /// Expected workcounter inputs"]
68 pub const fn inputs_wkc(&self) -> u16 {
69 self.0.inputsWKC
70 }
71
72 // TODO:
73 // check slave states
74 // pub docheckstate: boolean,
75
76 // TODO:
77 // IO segmentation list. Datagrams must not break SM in two.
78 // pub IOsegment: [uint32; 64usize],
79}
80
81impl fmt::Debug for Group {
82 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
83 // TODO: add missing fields
84 f.debug_struct("Group")
85 .field("outputs_wkc", &self.outputs_wkc())
86 .field("inputs_wkc", &self.inputs_wkc())
87 .finish()
88 }
89}