Skip to content

Commit

Permalink
Added pyserial read timeout checks per FaradayRF#30
Browse files Browse the repository at this point in the history
* Check for integer and NoneType values, however, Nonetype is currently
impossible to get per design of argparse options
* Check for integer value creater than or equal to zero
  • Loading branch information
kb1lqc committed Mar 11, 2018
1 parent 3494383 commit 03b6067
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions faradayio_cli/faradayio_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,19 @@ def checkUserInput(args):
if not isinstance(args.port, str):
raise TypeError("serial port path must be a string")

# Check timeout
# Expect and integer
if not isinstance(args.timeout, int):
if not isinstance(args.timeout, type(None)):
# TODO: Likely cannot be NoneType yet per argparse design
raise TypeError("id must be an integer or Nonetype")
# Expect a value between 68-65535 per RFC 791
if isinstance(args.timeout, int):
if not 0 <= args.mtu
raise ValueError("read timeout must be a positive value")




def setupSerialPort(loopback, port, baud, readtimeout, writetimeout):
"""Sets up serial port by connecting to phsyical or software port.
Expand Down

0 comments on commit 03b6067

Please sign in to comment.