MCPcopy Create free account
hub / github.com/ExpressLRS/ExpressLRS / main

Function main

src/python/binary_configurator.py:176–281  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

174 delattr(namespace, self.dest)
175
176def main():
177 parser = argparse.ArgumentParser(description="Configure Binary Firmware")
178 # firmware/targets directory
179 parser.add_argument('--dir', action=readable_dir, default=None, help='The directory that contains the "hardware" and other firmware directories')
180 parser.add_argument('--fdir', action=readable_dir, default=None, help='If specified, then the firmware files are loaded from this directory')
181 # Bind phrase
182 parser.add_argument('--phrase', type=str, help='Your personal binding phrase')
183 parser.add_argument('--flash-discriminator', type=int, default=randint(1,2**32-1), dest='flash_discriminator', help='Force a fixed flash-descriminator instead of random')
184 # WiFi Params
185 parser.add_argument('--ssid', type=length_check(32, "ssid"), required=False, help='Home network SSID')
186 parser.add_argument('--password', type=length_check(64, "password"), required=False, help='Home network password')
187 parser.add_argument('--auto-wifi', type=int, help='Interval (in seconds) before WiFi auto starts, if no connection is made')
188 parser.add_argument('--no-auto-wifi', action='store_true', help='Disables WiFi auto start if no connection is made')
189 # AirPort
190 parser.add_argument('--airport-baud', type=int, const=None, nargs='?', action='store', help='If configured as an AirPort device then this is the baud rate to use')
191 # RX Params
192 parser.add_argument('--rx-baud', type=int, const=420000, nargs='?', action='store', help='The receiver baudrate talking to the flight controller')
193 parser.add_argument('--lock-on-first-connection', dest='lock_on_first_connection', action='store_true', help='Lock RF mode on first connection')
194 parser.add_argument('--no-lock-on-first-connection', dest='lock_on_first_connection', action='store_false', help='Do not lock RF mode on first connection')
195 parser.set_defaults(lock_on_first_connection=None)
196 # TX Params
197 parser.add_argument('--tlm-report', type=int, const=240, nargs='?', action='store', help='The interval (in milliseconds) between telemetry packets')
198 parser.add_argument('--fan-min-runtime', type=int, const=30, nargs='?', action='store', help='The minimum amount of time the fan should run for (in seconds) if it turns on')
199 # Regulatory domain
200 parser.add_argument('--domain', type=RegulatoryDomain, choices=list(RegulatoryDomain), default=None, help='For SX127X based devices, which regulatory domain is being used')
201 # Unified target
202 parser.add_argument('--target', type=str, help='Unified target JSON path')
203 # Flashing options
204 parser.add_argument("--flash", type=UploadMethod, choices=list(UploadMethod), help="Flashing Method")
205 parser.add_argument("--erase", action='store_true', default=False, help="Full chip erase before flashing on ESP devices")
206 parser.add_argument('--out', action=writeable_dir, default=None)
207 parser.add_argument("--port", type=str, help="SerialPort or WiFi address to flash firmware to")
208 parser.add_argument("--baud", type=int, default=0, help="Baud rate for serial communication")
209 parser.add_argument("--force", action='store_true', default=False, help="Force upload even if target does not match")
210 parser.add_argument("--confirm", action='store_true', default=False, help="Confirm upload if a mismatched target was previously uploaded")
211 parser.add_argument("--tx", action='store_true', default=False, help="Flash a TX module, RX if not specified")
212 parser.add_argument("--lbt", action='store_true', default=False, help="Use LBT firmware, default is FCC (only for 2.4GHz firmware)")
213 parser.add_argument('--rx-as-tx', type=TXType, choices=list(TXType), required=False, default=None, help="Flash an RX module with TX firmware, either internal (full-duplex) or external (half-duplex)")
214 # Deprecated options, left for backward compatibility
215 parser.add_argument('--uart-inverted', action=deprecate_action, nargs=0, help='Deprecated')
216 parser.add_argument('--no-uart-inverted', action=deprecate_action, nargs=0, help='Deprecated')
217
218 #
219 # Firmware file to patch/configure
220 parser.add_argument("file", nargs="?", type=argparse.FileType("r+b"))
221
222 args = parser.parse_args()
223
224 if args.dir is not None:
225 os.chdir(args.dir)
226
227 if args.file is None:
228 args.target, config = ask_for_firmware(args)
229 try:
230 file = config['firmware']
231 if args.rx_as_tx is not None:
232 if config['platform'].startswith('esp32') or config['platform'].startswith('esp8285') and args.rx_as_tx == TXType.internal:
233 file = file.replace('_RX', '_TX')

Callers 1

Calls 5

FirmwareOptionsClass · 0.90
length_checkFunction · 0.85
ask_for_firmwareFunction · 0.85
patch_unifiedFunction · 0.85
uploadMethod · 0.80

Tested by

no test coverage detected