5 from BFinitPassthrough
import *
8 def send_bind_command(args
):
9 dbg_print("======== SEND BIND COMMAND ========")
10 s
= serial
.Serial(port
=args
.port
, baudrate
=args
.baud
,
11 bytesize
=8, parity
='N', stopbits
=1,
12 timeout
=1, xonxoff
=0, rtscts
=0)
13 BindInitSeq
= bootloader
.get_bind_seq(args
.type)
14 dbg_print(" * Using full duplex (CRSF)")
21 if __name__
== '__main__':
22 parser
= argparse
.ArgumentParser(
23 description
="Initialize BetaFlight passthrough and send the 'enter bind mode' command")
24 parser
.add_argument("-b", "--baud", type=int, default
=420000,
25 help="Baud rate for passthrough communication")
26 parser
.add_argument("-p", "--port", type=str,
27 help="Override serial port autodetection and use PORT")
28 parser
.add_argument("-t", "--type", type=str, default
="ESP82",
29 help="Defines flash target type which is sent to target in reboot command")
30 args
= parser
.parse_args()
32 if (args
.port
== None):
33 args
.port
= serials_find
.get_serial_port()
36 bf_passthrough_init(args
.port
, args
.baud
)
37 except PassthroughEnabled
as err
:
40 send_bind_command(args
)