@@ -5,7 +5,9 @@ use embedded_can::{ExtendedId, Frame as _, Id, StandardId};
55use tokio:: try_join;
66use tracing:: info;
77
8- use crate :: tests:: { initialize_test, invert_frame} ;
8+ use crate :: tests:: {
9+ initialize_test, invert_frame, SERIAL_BAUD_RATE_DEFAULT , SERIAL_BAUD_RATE_STABLE ,
10+ } ;
911use crate :: tokio:: Usb2CanBuilder ;
1012use crate :: {
1113 tokio:: Usb2Can , CanBaudRate , Frame , SerialBaudRate , StoredIdFilter , Usb2CanConfiguration ,
@@ -27,6 +29,15 @@ async fn stored_id_filter() -> Result<()> {
2729 let ( mut usb2can_a, mut usb2can_b) =
2830 open_adapters ( & serial_path, & second_serial_path, & usb2can_conf) . await ?;
2931
32+ info ! ( "Configure to the stable serial baud rate value..." ) ;
33+ reconfigure_adapters ( & mut usb2can_a, & mut usb2can_b, |usb2can| async {
34+ usb2can
35+ . set_serial_baud_rate ( SERIAL_BAUD_RATE_STABLE )
36+ . await
37+ . context ( "Failed to set serial baud rate of USB2CAN device to stable value" )
38+ } )
39+ . await ?;
40+
3041 // Blocklist filter.
3142 let filter = StoredIdFilter :: new_block ( vec ! [ ExtendedId :: ZERO . into( ) ] )
3243 . context ( "Failed to create blocklist filter" ) ?;
@@ -71,6 +82,15 @@ async fn stored_id_filter() -> Result<()> {
7182
7283 self_test ( & mut usb2can_a, & mut usb2can_b, false , true ) . await ?;
7384
85+ info ! ( "Resetting to the original serial baud rate value..." ) ;
86+ reconfigure_adapters ( & mut usb2can_a, & mut usb2can_b, |usb2can| async {
87+ usb2can
88+ . set_serial_baud_rate ( SERIAL_BAUD_RATE_DEFAULT )
89+ . await
90+ . context ( "Failed to set serial baud rate of USB2CAN device to original value" )
91+ } )
92+ . await ?;
93+
7494 Ok ( ( ) )
7595}
7696
@@ -90,6 +110,15 @@ async fn can_rates_frame_types_and_filtering() -> Result<()> {
90110 let ( mut usb2can_a, mut usb2can_b) =
91111 open_adapters ( & serial_path, & second_serial_path, & usb2can_conf) . await ?;
92112
113+ info ! ( "Configure to the stable serial baud rate value..." ) ;
114+ reconfigure_adapters ( & mut usb2can_a, & mut usb2can_b, |usb2can| async {
115+ usb2can
116+ . set_serial_baud_rate ( SERIAL_BAUD_RATE_STABLE )
117+ . await
118+ . context ( "Failed to set serial baud rate of USB2CAN device to stable value" )
119+ } )
120+ . await ?;
121+
93122 for variable_encoding in [ false , true ] {
94123 for can_baud_rate in [
95124 CanBaudRate :: R5kBd ,
@@ -167,6 +196,15 @@ async fn can_rates_frame_types_and_filtering() -> Result<()> {
167196 }
168197 }
169198
199+ info ! ( "Resetting to the original serial baud rate value..." ) ;
200+ reconfigure_adapters ( & mut usb2can_a, & mut usb2can_b, |usb2can| async {
201+ usb2can
202+ . set_serial_baud_rate ( SERIAL_BAUD_RATE_DEFAULT )
203+ . await
204+ . context ( "Failed to set serial baud rate of USB2CAN device to original value" )
205+ } )
206+ . await ?;
207+
170208 Ok ( ( ) )
171209}
172210
@@ -213,7 +251,7 @@ async fn serial_rates() -> Result<()> {
213251 info ! ( "Resetting to the original serial baud rate value..." ) ;
214252 reconfigure_adapters ( & mut usb2can_a, & mut usb2can_b, |usb2can| async {
215253 usb2can
216- . set_serial_baud_rate ( SerialBaudRate :: R2000000Bd )
254+ . set_serial_baud_rate ( SERIAL_BAUD_RATE_DEFAULT )
217255 . await
218256 . context ( "Failed to set serial baud rate of USB2CAN device to original value" )
219257 } )
0 commit comments