Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: GlasgowEmbedded/glasgow
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 509052b0851a
Choose a base ref
...
head repository: GlasgowEmbedded/glasgow
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 51cbff9128be
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Nov 18, 2019

  1. Copy the full SHA
    51cbff9 View commit details
Showing with 18 additions and 6 deletions.
  1. +18 −6 software/glasgow/applet/radio/nrf24l01/__init__.py
24 changes: 18 additions & 6 deletions software/glasgow/applet/radio/nrf24l01/__init__.py
Original file line number Diff line number Diff line change
@@ -164,13 +164,25 @@ async def run(self, device, args):
@classmethod
def add_interact_arguments(cls, parser):
def channel(value):
return int(value, 10)
value = int(value, 10)
if value not in range(126):
raise argparse.ArgumentTypeError(
"invalid channel: {} (choose from 0..125)".format(value))
return value
def address(value):
return bytes.fromhex(value)
def length(value):
return int(value, 10)
value = int(value, 10)
if value not in range(33):
raise argparse.ArgumentTypeError(
"invalid length: {} (choose from 0..32)".format(value))
return value
def payload(value):
return bytes.fromhex(value)
payload = bytes.fromhex(value)
if len(payload) not in range(33):
raise argparse.ArgumentTypeError(
"invalid payload length: {} (must be between 0..32)".format(len(value)))
return payload

parser.add_argument(
"-c", "--channel", metavar="RF-CHANNEL", type=channel, required=True,
@@ -202,7 +214,7 @@ def payload(value):
"transmit", help="transmit a packet")
p_transmit.add_argument(
"address", metavar="ADDRESS", type=address,
help="transmit packet with address ADDRESS")
help="transmit packet with hex address ADDRESS")
p_transmit.add_argument(
"payload", metavar="DATA", type=payload,
help="transmit DATA as packet payload")
@@ -223,9 +235,9 @@ def payload(value):
"receive", help="receive a packet")
p_receive.add_argument(
"address", metavar="ADDRESS", type=address,
help="receive packet with address ADDRESS")
help="receive packet with hex address ADDRESS")
p_receive.add_argument(
"-l", "--length", metavar="LENGTH", type=int,
"-l", "--length", metavar="LENGTH", type=length,
help="receive packet with length LENGTH (mutually exclusive with --dynamic-length)")

async def interact(self, device, args, nrf24l01_iface):