Browse Source

transmit command: configure transceiver after reading from stdin to avoid delay between configuration and transmission, if pipe is slow

Fabian Peter Hammerle 3 years ago
parent
commit
6908fb3511
2 changed files with 7 additions and 1 deletions
  1. 4 0
      CHANGELOG.md
  2. 3 1
      cc1101/_cli.py

+ 4 - 0
CHANGELOG.md

@@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
 ## [Unreleased]
+### Fixed
+- `cc1101-transmit` command:
+  - configure transceiver after reading from stdin
+    to avoid delay between configuration and transmission, if pipe is slow
 
 ## [2.5.0] - 2020-12-30
 ### Added

+ 3 - 1
cc1101/_cli.py

@@ -56,6 +56,9 @@ def _transmit():
         datefmt="%Y-%m-%dT%H:%M:%S%z",
     )
     _LOGGER.debug("args=%r", args)
+    payload = sys.stdin.buffer.read()
+    # configure transceiver after reading from stdin
+    # to avoid delay between configuration and transmission if pipe is slow
     with cc1101.CC1101() as transceiver:
         if args.base_frequency_hertz:
             transceiver.set_base_frequency_hertz(args.base_frequency_hertz)
@@ -65,7 +68,6 @@ def _transmit():
             transceiver.set_sync_mode(
                 cc1101.options.SyncMode[args.sync_mode.upper().replace("-", "_")]
             )
-        payload = sys.stdin.buffer.read()
         if args.packet_length_mode:
             packet_length_mode = cc1101.options.PacketLengthMode[
                 args.packet_length_mode.upper()