@@ -10,8 +10,8 @@ use rppal::gpio::{Gpio, OutputPin};
1010#[ derive( thiserror:: Error , Debug ) ]
1111pub enum SerialConfigError {
1212 #[ 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 ,
1515
1616 #[ cfg( feature = "raspberry" ) ]
1717 #[ error( "GPIO {0} is not available" ) ]
@@ -46,9 +46,11 @@ impl Interface {
4646 let rts_gpio = opts. rts . or ( config. rts ) ;
4747 let dtr_gpio = opts. dtr . or ( config. dtr ) ;
4848
49- if port_info. port_type == serialport:: SerialPortType :: Unknown && dtr_gpio. is_none ( ) {
50- // Assume internal UART, which has no DTR pin.
51- return Err ( SerialConfigError :: MissingDtrForInternalUart ) ;
49+ if port_info. port_type == serialport:: SerialPortType :: Unknown
50+ && ( dtr_gpio. is_none ( ) || rts_gpio. is_none ( ) )
51+ {
52+ // Assume internal UART, which has no DTR pin and usually no RTS either.
53+ return Err ( Error :: from ( SerialConfigError :: MissingDtrRtsForInternalUart ) ) ;
5254 }
5355
5456 let mut gpios = Gpio :: new ( ) . unwrap ( ) ;
0 commit comments