Skip to content

Commit

Permalink
Add support for tinySA Ultra+ ZS-407, ZS-406, ZS-405 and tinySA and f…
Browse files Browse the repository at this point in the history
…ix crashing due to operations on Integer (#755)

* Add support for TinySA Ultra+ ZS-407, ZS-405, ZS-406 that firmware version and hardware revision can be shown in app, screen-capture is alive and fix crashing caused by operations on Integer
  • Loading branch information
xros authored Jan 19, 2025
1 parent 3fa625e commit 49fcbd8
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion src/NanoVNASaver/Hardware/TinySA.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from NanoVNASaver.Hardware.Serial import Interface, drain_serial
from NanoVNASaver.Hardware.VNA import VNA
from NanoVNASaver.Version import Version

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -110,7 +111,7 @@ def setSweep(self, start, stop):

def read_frequencies(self) -> list[int]:
logger.debug("readFrequencies")
return [int(line.real) for line in self.exec_command("frequencies")]
return [int(line).real for line in self.exec_command("frequencies")]

def readValues(self, value) -> list[complex]:
def conv2complex(data: str) -> complex:
Expand All @@ -132,6 +133,7 @@ class TinySA_Ultra(TinySA): # noqa: N801
screenwidth = 480
screenheight = 320
valid_datapoints = (450, 51, 101, 145, 290)
hardware_revision = None

def __init__(self, iface: Interface):
super().__init__(iface)
Expand All @@ -141,3 +143,37 @@ def __init__(self, iface: Interface):
self.sweep_max_freq_Hz = 5.4e9
self._sweepdata = []
self.validateInput = False
self.version = self.read_firmware_version()
self.hardware_revision = self.read_hardware_revision()
# detect model versions of tinySA Ultra including ZS-405, ZS406 (Ultra+), ZS407 (Ultra+)
if self.hardware_revision >= Version("0.5.3"):
self.name = "tinySA Ultra+ ZS-407"
self.sweep_max_freq_Hz = 7.3e9
elif self.hardware_revision >= Version("0.4.6"):
self.name = "tinySA Ultra+ ZS-406"
self.sweep_max_freq_Hz = 5.4e9
elif self.hardware_revision >= Version("0.4.5"):
self.name = "tinySA Ultra ZS-405"
self.sweep_max_freq_Hz = 5.3e9
else:
# version 0.3.x is for tinySA
self.name = "tinySA"
self.sweep_max_freq_Hz = 0.96e9


def read_firmware_version(self) -> "Version":
'''For example, command version in TinySA returns as this
tinySA4_v1.4-193-g6ff182b
HW Version:V0.5.4 max2871
'''
result = list(self.exec_command("version"))
logger.debug("firmware version result:\n%s", result[0])
# transform from tinySA4_v1.4-193-g6ff182b to 1.4.193
major_minor_version, revision_version, hash = result[0].split("_v")[1].split("-")
revision_version = revision_version.split("-")[0]
return Version(major_minor_version+"."+revision_version)

def read_hardware_revision(self) -> str:
result = list(self.exec_command("version"))
logger.debug("hardware version result:\n%s", result[1])
return Version(result[1])

0 comments on commit 49fcbd8

Please sign in to comment.