@@ -85,26 +85,27 @@ void ec_master_cmd_master(ec_master_t *master)
8585{
8686 unsigned int dev_idx , j ;
8787 uint64_t lost ;
88- double perc ;
8988 int colwidth = 8 ;
89+ ec_netdev_stats_t netdev_stats ;
90+ uintptr_t flags ;
9091
9192 EC_LOG_RAW ("Master%d\n" , master -> index );
9293 EC_LOG_RAW (" Phase: " );
9394 switch (master -> phase ) {
9495 case 0 :
95- EC_LOG_RAW ("Waiting for device(s) ..." );
96+ EC_LOG_RAW ("Waiting for device attached ...\n " );
9697 break ;
9798 case 1 :
98- EC_LOG_RAW ("Idle" );
99+ EC_LOG_RAW ("Idle\n " );
99100 break ;
100101 case 2 :
101- EC_LOG_RAW ("Operation" );
102+ EC_LOG_RAW ("Operation\n " );
102103 break ;
103104 default :
104- EC_LOG_RAW ("???" );
105+ EC_LOG_RAW ("Unknown\n" );
106+ break ;
105107 }
106108
107- EC_LOG_RAW ("\n" );
108109 EC_LOG_RAW (" Slaves: %u\n" , master -> slave_count );
109110 EC_LOG_RAW (" Ethernet net devices:\n" );
110111
@@ -118,89 +119,56 @@ void ec_master_cmd_master(ec_master_t *master)
118119 master -> netdev [dev_idx ]-> mac_addr [4 ],
119120 master -> netdev [dev_idx ]-> mac_addr [5 ]);
120121 EC_LOG_RAW (" Link: %s\n" , master -> netdev [dev_idx ]-> link_state ? "UP" : "DOWN" );
121- EC_LOG_RAW (" Tx frames: %llu\n" , master -> netdev [dev_idx ]-> tx_count );
122- EC_LOG_RAW (" Tx bytes: %llu\n" , master -> netdev [dev_idx ]-> tx_bytes );
123- EC_LOG_RAW (" Rx frames: %llu\n" , master -> netdev [dev_idx ]-> rx_count );
124- EC_LOG_RAW (" Rx bytes: %llu\n" , master -> netdev [dev_idx ]-> rx_bytes );
125- EC_LOG_RAW (" Tx errors: %llu\n" , master -> netdev [dev_idx ]-> tx_errors );
122+
123+ flags = ec_osal_enter_critical_section ();
124+ memcpy (& netdev_stats , & master -> netdev [dev_idx ]-> stats , sizeof (ec_netdev_stats_t ));
125+ ec_osal_leave_critical_section (flags );
126+
127+ EC_LOG_RAW (" Tx frames: %llu\n" , netdev_stats .tx_count );
128+ EC_LOG_RAW (" Tx bytes: %llu\n" , netdev_stats .tx_bytes );
129+ EC_LOG_RAW (" Rx frames: %llu\n" , netdev_stats .rx_count );
130+ EC_LOG_RAW (" Rx bytes: %llu\n" , netdev_stats .rx_bytes );
131+ EC_LOG_RAW (" Tx errors: %llu\n" , netdev_stats .tx_errors );
132+
133+ lost = netdev_stats .loss_count ;
134+ if (lost == 1 )
135+ lost = 0 ;
136+ EC_LOG_RAW (" Lost frames: %llu\n" , lost );
126137
127138 EC_LOG_RAW (" Tx frame rate [1/s]: " );
128139 for (j = 0 ; j < EC_RATE_COUNT ; j ++ ) {
129- EC_LOG_RAW ("%*.*f" , colwidth , 0 , master -> netdev [ dev_idx ] -> tx_frame_rates [j ] / 1000.0 );
140+ EC_LOG_RAW ("%*.*f" , colwidth , 0 , netdev_stats . tx_frame_rates [j ] / 1000.0 );
130141 if (j < EC_RATE_COUNT - 1 )
131142 EC_LOG_RAW (" " );
132143 }
133144 EC_LOG_RAW ("\n Tx rate [KByte/s]: " );
134145 for (j = 0 ; j < EC_RATE_COUNT ; j ++ ) {
135- EC_LOG_RAW ("%*.*f" , colwidth , 1 , master -> netdev [ dev_idx ] -> tx_byte_rates [j ] / 1024.0 );
146+ EC_LOG_RAW ("%*.*f" , colwidth , 1 , netdev_stats . tx_byte_rates [j ] / 1024.0 );
136147 if (j < EC_RATE_COUNT - 1 )
137148 EC_LOG_RAW (" " );
138149 }
139150 EC_LOG_RAW ("\n Rx frame rate [1/s]: " );
140151 for (j = 0 ; j < EC_RATE_COUNT ; j ++ ) {
141- EC_LOG_RAW ("%*.*f" , colwidth , 0 , master -> netdev [ dev_idx ] -> rx_frame_rates [j ] / 1000.0 );
152+ EC_LOG_RAW ("%*.*f" , colwidth , 0 , netdev_stats . rx_frame_rates [j ] / 1000.0 );
142153 if (j < EC_RATE_COUNT - 1 )
143154 EC_LOG_RAW (" " );
144155 }
145156 EC_LOG_RAW ("\n Rx rate [KByte/s]: " );
146157 for (j = 0 ; j < EC_RATE_COUNT ; j ++ ) {
147- EC_LOG_RAW ("%*.*f" , colwidth , 1 , master -> netdev [ dev_idx ] -> rx_byte_rates [j ] / 1024.0 );
158+ EC_LOG_RAW ("%*.*f" , colwidth , 1 , netdev_stats . rx_byte_rates [j ] / 1024.0 );
148159 if (j < EC_RATE_COUNT - 1 )
149160 EC_LOG_RAW (" " );
150161 }
151- EC_LOG_RAW ("\n" );
152- }
153162
154- lost = master -> netdev_stats .tx_count - master -> netdev_stats .rx_count ;
155- if (lost == 1 )
156- lost = 0 ;
157- EC_LOG_RAW (" Common:\n" );
158- EC_LOG_RAW (" Tx frames: %llu\n" , master -> netdev_stats .tx_count );
159- EC_LOG_RAW (" Tx bytes: %llu\n" , master -> netdev_stats .tx_bytes );
160- EC_LOG_RAW (" Rx frames: %llu\n" , master -> netdev_stats .rx_count );
161- EC_LOG_RAW (" Rx bytes: %llu\n" , master -> netdev_stats .rx_bytes );
162- EC_LOG_RAW (" Lost frames: %llu\n" , lost );
163-
164- EC_LOG_RAW (" Tx frame rate [1/s]: " );
165- for (j = 0 ; j < EC_RATE_COUNT ; j ++ ) {
166- EC_LOG_RAW ("%*.*f" , colwidth , 0 , master -> netdev_stats .tx_frame_rates [j ] / 1000.0 );
167- if (j < EC_RATE_COUNT - 1 )
168- EC_LOG_RAW (" " );
169- }
170- EC_LOG_RAW ("\n Tx rate [KByte/s]: " );
171- for (j = 0 ; j < EC_RATE_COUNT ; j ++ ) {
172- EC_LOG_RAW ("%*.*f" , colwidth , 1 , master -> netdev_stats .tx_byte_rates [j ] / 1024.0 );
173- if (j < EC_RATE_COUNT - 1 )
174- EC_LOG_RAW (" " );
175- }
176- EC_LOG_RAW ("\n Rx frame rate [1/s]: " );
177- for (j = 0 ; j < EC_RATE_COUNT ; j ++ ) {
178- EC_LOG_RAW ("%*.*f" , colwidth , 0 , master -> netdev_stats .rx_frame_rates [j ] / 1000.0 );
179- if (j < EC_RATE_COUNT - 1 )
180- EC_LOG_RAW (" " );
181- }
182- EC_LOG_RAW ("\n Rx rate [KByte/s]: " );
183- for (j = 0 ; j < EC_RATE_COUNT ; j ++ ) {
184- EC_LOG_RAW ("%*.*f" , colwidth , 1 , master -> netdev_stats .rx_byte_rates [j ] / 1024.0 );
185- if (j < EC_RATE_COUNT - 1 )
186- EC_LOG_RAW (" " );
187- }
188- EC_LOG_RAW ("\n Loss rate [1/s]: " );
189- for (j = 0 ; j < EC_RATE_COUNT ; j ++ ) {
190- EC_LOG_RAW ("%*.*f" , colwidth , 0 , master -> netdev_stats .loss_rates [j ] / 1000.0 );
191- if (j < EC_RATE_COUNT - 1 )
192- EC_LOG_RAW (" " );
193- }
194- EC_LOG_RAW ("\n Frame loss [%%]: " );
195- for (j = 0 ; j < EC_RATE_COUNT ; j ++ ) {
196- perc = 0.0 ;
197- if (master -> netdev_stats .tx_frame_rates [j ])
198- perc = 100.0 * master -> netdev_stats .loss_rates [j ] / master -> netdev_stats .tx_frame_rates [j ];
199- EC_LOG_RAW ("%*.*f" , colwidth , 1 , perc );
200- if (j < EC_RATE_COUNT - 1 )
201- EC_LOG_RAW (" " );
163+ EC_LOG_RAW ("\n Loss rate [1/s]: " );
164+ for (j = 0 ; j < EC_RATE_COUNT ; j ++ ) {
165+ EC_LOG_RAW ("%*.*f" , colwidth , 0 , netdev_stats .loss_rates [j ] / 1000.0 );
166+ if (j < EC_RATE_COUNT - 1 )
167+ EC_LOG_RAW (" " );
168+ }
169+
170+ EC_LOG_RAW ("\n" );
202171 }
203- EC_LOG_RAW ("\n" );
204172}
205173
206174static void ec_cmd_show_slave_detail (ec_master_t * master , uint32_t slave_idx )
@@ -222,8 +190,8 @@ static void ec_cmd_show_slave_detail(ec_master_t *master, uint32_t slave_idx)
222190
223191 EC_LOG_RAW ("=== Master %d, Slave %d ===\n" , master -> index , slave_idx );
224192
225- if (slave_data .effective_alias != 0 ) {
226- EC_LOG_RAW ("Alias: 0x%04x\n" , slave_data .effective_alias );
193+ if (slave_data .alias_address != 0 ) {
194+ EC_LOG_RAW ("Alias: 0x%04x\n" , slave_data .alias_address );
227195 }
228196
229197 EC_LOG_RAW ("Device: %s\n" , master -> netdev [slave -> netdev_idx ]-> name );
0 commit comments