rbtest: timed small messages, one 50 kB message, and MT checks
`rbtest` in the shell sample sends test messages with a 16-byte header and a counting ramp, so every byte can be checked at the other end. `rbtest small` sends a few 32-byte messages and logs how long each took, `rbtest large` sends one of up to 50000 bytes and only with `confirm`, and `rbtest mt` shows the last MT and checks it. `rb9704 pattern make` and `check` in python/ make and check the same messages. rb9704_send_fill writes a message straight into the module's buffer, so a large generated one is not held twice. overlay-large.conf raises the limit to 50000 bytes; on the M5Stamp-C3 that links on the USB console and not beside WiFi, which overflows by 11 kB. Run against the fake modem on native_sim only; not yet on a real modem.
This commit is contained in:
1 parent
9f68104ac6
commit
144efe683e
15 files changed
+798
-6
No files matched your search
@@ -12,6 +12,8 @@ rb9704 - drive a RockBLOCK 9704 from the host over its USB-C port.
|
||||
rb9704 [-p PORT] listen [--out DIR] [--for S]
|
||||
rb9704 [-p PORT] session (--text T | --hex H | --file F) [--quiet S] [--yes]
|
||||
rb9704 cloud ping | things | mo | msg ID | mt ... | status ID
|
||||
rb9704 pattern make [--size N] [--seq N] [--count N] [--out F]
|
||||
rb9704 pattern check (--hex H | --b64 B | --file F)
|
||||
|
||||
The modem side uses Ground Control's rockblock9704 package, a binding of
|
||||
the same C library this repository builds into Zephyr, so what works here
|
||||
@@ -23,6 +25,10 @@ the provisioning when a message is sent, and asking that way is free.
|
||||
question. Everything else on the modem side is local serial traffic and
|
||||
costs nothing. `cloud mt` costs airtime too.
|
||||
|
||||
`pattern` makes and checks the test message the shell sample's `rbtest`
|
||||
sends (rb9704tools/pattern.py): `check` takes the bytes Cloudloop shows,
|
||||
in hex or Base64, and `make` gives a message to queue with `cloud mt`.
|
||||
|
||||
The port is -p, or $RB9704_PORT, or the one FTDI FT234XD attached (the
|
||||
9704's USB-C bridge, 0403:6015). --log FILE appends every event as a JSON
|
||||
line, for the bench log.
|
||||
@@ -42,6 +48,8 @@ import urllib.error
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
from rb9704tools import pattern
|
||||
|
||||
FTDI_VID, FT234X_PID = 0x0403, 0x6015
|
||||
BAUD = 230400
|
||||
RAW_TOPIC = 244
|
||||
@@ -570,6 +578,38 @@ def cmd_cloud(a):
|
||||
ev("cloud_mt", bytes=len(data), topic=a.topic, result=json.dumps(r))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- pattern
|
||||
|
||||
def cmd_pattern(a):
|
||||
if a.verb == "make":
|
||||
data = pattern.make(a.size, seq=a.seq, count=a.count)
|
||||
if a.out:
|
||||
with open(a.out, "wb") as f:
|
||||
f.write(data)
|
||||
else:
|
||||
print(data.hex())
|
||||
return
|
||||
if a.hex is not None:
|
||||
data = bytes.fromhex(a.hex)
|
||||
elif a.b64 is not None:
|
||||
# Cloudloop leaves the padding off
|
||||
data = base64.b64decode(a.b64 + "=" * (-len(a.b64) % 4))
|
||||
else:
|
||||
with open(a.file, "rb") as f:
|
||||
data = f.read()
|
||||
r = pattern.check(data)
|
||||
if r is None:
|
||||
die(f"{len(data)} bytes, not a test message: {data[:16].hex()}")
|
||||
print(f"{r['kind']} {r['seq']}/{r['count']}, {r['got']} bytes, made at uptime "
|
||||
f"{r['uptime_ms'] / 1000:.3f} s")
|
||||
if r["ok"]:
|
||||
print("every byte as expected")
|
||||
elif r["bad_at"] == 8:
|
||||
die(f"the header says {r['length']} bytes, {r['got']} arrived")
|
||||
else:
|
||||
die(f"wrong from byte {r['bad_at']}")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- main
|
||||
|
||||
def add_payload(p, required=True):
|
||||
@@ -660,6 +700,20 @@ def main():
|
||||
add_payload(q)
|
||||
p.set_defaults(fn=cmd_cloud)
|
||||
|
||||
p = sub.add_parser("pattern", help="make or check an `rbtest` test message (free)")
|
||||
ps = p.add_subparsers(dest="verb", required=True)
|
||||
q = ps.add_parser("make", help="one test message, as hex or to a file")
|
||||
q.add_argument("--size", type=int, default=32)
|
||||
q.add_argument("--seq", type=int, default=1)
|
||||
q.add_argument("--count", type=int, default=1)
|
||||
q.add_argument("--out", help="write the bytes here; default hex on stdout")
|
||||
q = ps.add_parser("check", help="every byte of one, as Cloudloop shows it")
|
||||
g = q.add_mutually_exclusive_group(required=True)
|
||||
g.add_argument("--hex")
|
||||
g.add_argument("--b64")
|
||||
g.add_argument("--file")
|
||||
p.set_defaults(fn=cmd_pattern)
|
||||
|
||||
a = ap.parse_args()
|
||||
LOG = a.log
|
||||
a.fn(a)
|
||||
|
||||
Reference in new issue
Block a user