jsnyder / stm32loader

Python script to load firmware using STM32 bootloader
324 stars 238 forks source link

When not provided with no argument, it should report an error and usage example #7

Open zoobab opened 6 years ago

zoobab commented 6 years ago

When not provided with no argument, it should report an error and usage example.

Right now, it throws an error saying it cannot find "/dev/tty.usbserial-ftCYPMYJ":

$ ./stm32loader.py 
Traceback (most recent call last):
  File "./stm32loader.py", line 427, in <module>
    cmd.open(conf['port'], conf['baud'])
  File "./stm32loader.py", line 71, in open
    timeout=5               # set a timeout value, None for waiting forever
  File "/usr/lib64/python2.7/site-packages/serial/serialutil.py", line 236, in __init__
    self.open()
  File "/usr/lib64/python2.7/site-packages/serial/serialposix.py", line 268, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/tty.usbserial-ftCYPMYJ: [Errno 2] No such file or directory: '/dev/tty.usbserial-ftCYPMYJ'
florisla commented 6 years ago

Running without any option is a valid use case: in that case stm32loader prints the bootloader version and device ID.

It's just unfortunate that the default port has a low chance of being correct (and 0% chance on non-Unix platforms).

Basically, what you're asking is to make the -p [port] option mandatory.

I've done this in a branch (note: requires Python3): https://github.com/florisla/stm32loader/tree/require-option-p