13 |
13 |
14 #include <linux/list.h> |
14 #include <linux/list.h> |
15 |
15 |
16 #include "device.h" |
16 #include "device.h" |
17 #include "slave.h" |
17 #include "slave.h" |
18 #include "frame.h" |
|
19 #include "domain.h" |
18 #include "domain.h" |
|
19 |
|
20 /*****************************************************************************/ |
|
21 |
|
22 /** |
|
23 EtherCAT-Rahmen-Statistiken. |
|
24 */ |
|
25 |
|
26 typedef struct |
|
27 { |
|
28 unsigned int timeouts; /**< Kommando-Timeouts */ |
|
29 unsigned int delayed; /**< Verzögerte Kommandos */ |
|
30 unsigned int corrupted; /**< Verfälschte Rahmen */ |
|
31 unsigned int unmatched; /**< Unpassende Kommandos */ |
|
32 cycles_t t_last; /**< Timestamp-Counter bei der letzten Ausgabe */ |
|
33 } |
|
34 ec_stats_t; |
20 |
35 |
21 /*****************************************************************************/ |
36 /*****************************************************************************/ |
22 |
37 |
23 /** |
38 /** |
24 EtherCAT-Master |
39 EtherCAT-Master |
29 |
44 |
30 struct ec_master |
45 struct ec_master |
31 { |
46 { |
32 ec_slave_t *slaves; /**< Array von Slaves auf dem Bus */ |
47 ec_slave_t *slaves; /**< Array von Slaves auf dem Bus */ |
33 unsigned int slave_count; /**< Anzahl Slaves auf dem Bus */ |
48 unsigned int slave_count; /**< Anzahl Slaves auf dem Bus */ |
34 ec_device_t device; /**< EtherCAT-Gerät */ |
49 ec_device_t *device; /**< EtherCAT-Gerät */ |
35 unsigned int device_registered; /**< Ein Geraet hat sich registriert. */ |
50 struct list_head commands; /**< Kommando-Liste */ |
36 uint8_t command_index; /**< Aktueller Kommando-Index */ |
51 uint8_t command_index; /**< Aktueller Kommando-Index */ |
37 struct list_head domains; /**< Liste der Prozessdatendomänen */ |
52 struct list_head domains; /**< Liste der Prozessdatendomänen */ |
38 int debug_level; /**< Debug-Level im Master-Code */ |
53 int debug_level; /**< Debug-Level im Master-Code */ |
39 unsigned int bus_time; /**< Letzte Bus-Zeit in Mikrosekunden */ |
54 ec_stats_t stats; /**< Rahmen-Statistiken */ |
40 unsigned int frames_lost; /**< Anzahl verlorener Frames */ |
|
41 unsigned int frames_delayed; /**< Anzahl verzögerter Frames */ |
|
42 unsigned long t_last_cyclic_output; /**< Timer-Ticks bei den letzten |
|
43 zyklischen Ausgaben */ |
|
44 }; |
55 }; |
45 |
56 |
46 /*****************************************************************************/ |
57 /*****************************************************************************/ |
47 |
58 |
48 // Master creation and deletion |
59 // Master creation and deletion |
49 void ec_master_init(ec_master_t *); |
60 void ec_master_init(ec_master_t *); |
50 void ec_master_clear(ec_master_t *); |
61 void ec_master_clear(ec_master_t *); |
51 void ec_master_reset(ec_master_t *); |
62 void ec_master_reset(ec_master_t *); |
52 void ec_master_clear_slaves(ec_master_t *); |
63 |
|
64 // IO |
|
65 void ec_master_receive(ec_master_t *, const uint8_t *, size_t); |
|
66 void ec_master_queue_command(ec_master_t *, ec_command_t *); |
|
67 int ec_master_simple_io(ec_master_t *, ec_command_t *); |
53 |
68 |
54 // Registration of devices |
69 // Registration of devices |
55 int ec_master_open(ec_master_t *); |
70 int ec_master_open(ec_master_t *); |
56 void ec_master_close(ec_master_t *); |
71 void ec_master_close(ec_master_t *); |
57 |
72 |
58 // Slave management |
73 // Slave management |
59 int ec_scan_for_slaves(ec_master_t *); |
74 int ec_master_bus_scan(ec_master_t *); |
60 ec_slave_t *ec_address(const ec_master_t *, const char *); |
75 ec_slave_t *ec_master_slave_address(const ec_master_t *, const char *); |
61 |
76 |
62 // Misc |
77 // Misc |
63 void ec_output_debug_data(const ec_master_t *); |
78 void ec_master_debug(const ec_master_t *); |
64 void ec_cyclic_output(ec_master_t *); |
79 void ec_master_output_stats(ec_master_t *); |
65 |
80 |
66 /*****************************************************************************/ |
81 /*****************************************************************************/ |
67 |
82 |
68 #endif |
83 #endif |
69 |
84 |