5 from BFinitPassthrough
import *
8 def send_model_command(args
):
9 dbg_print("======== SEND SET MODEL 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 TelemSeq
= bootloader
.get_model_seq(args
.model
)
20 if __name__
== '__main__':
21 parser
= argparse
.ArgumentParser(
22 description
="Initialize BetaFlight passthrough and send the 'enter bind mode' command")
24 'model', metavar
='int', nargs
=1, type=int,
25 help='The model match number to set')
26 parser
.add_argument("-b", "--baud", type=int, default
=420000,
27 help="Baud rate for passthrough communication")
28 parser
.add_argument("-p", "--port", type=str,
29 help="Override serial port autodetection and use PORT")
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_model_command(args
)