@@ -10,8 +10,8 @@ use rppal::gpio::{Gpio, OutputPin};
10
10
#[ derive( thiserror:: Error , Debug ) ]
11
11
pub enum SerialConfigError {
12
12
#[ cfg( feature = "raspberry" ) ]
13
- #[ error( "You need to specify DTR when using an internal UART peripheral" ) ]
14
- MissingDtrForInternalUart ,
13
+ #[ error( "You need to specify both DTR and RTS pins when using an internal UART peripheral" ) ]
14
+ MissingDtrRtsForInternalUart ,
15
15
16
16
#[ cfg( feature = "raspberry" ) ]
17
17
#[ error( "GPIO {0} is not available" ) ]
@@ -54,9 +54,11 @@ impl Interface {
54
54
let rts_gpio = opts. rts . or ( config. rts ) ;
55
55
let dtr_gpio = opts. dtr . or ( config. dtr ) ;
56
56
57
- if port_info. port_type == serialport:: SerialPortType :: Unknown && dtr_gpio. is_none ( ) {
58
- // Assume internal UART, which has no DTR pin.
59
- return Err ( Error :: from ( SerialConfigError :: MissingDtrForInternalUart ) ) ;
57
+ if port_info. port_type == serialport:: SerialPortType :: Unknown
58
+ && ( dtr_gpio. is_none ( ) || rts_gpio. is_none ( ) )
59
+ {
60
+ // Assume internal UART, which has no DTR pin and usually no RTS either.
61
+ return Err ( Error :: from ( SerialConfigError :: MissingDtrRtsForInternalUart ) ) ;
60
62
}
61
63
62
64
let mut gpios = Gpio :: new ( ) . unwrap ( ) ;
0 commit comments