Skip to content

Commit

Permalink
calling variables bytesxxx was historic and bad. renamed to pointsxxx
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Zachmann authored and Mark Zachmann committed Jun 9, 2020
1 parent 1aa3118 commit 25746fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 7 additions & 7 deletions NanoVNASaver/Hardware/NanoVNA_V2.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,24 @@ def readValues(self, value) -> List[str]:
# cmd: write register 0x30 to clear FIFO
self.serial.write([0x20, 0x30, 0x00])

bytesleft = self.datapoints
while bytesleft > 0 :
pointstodo = self.datapoints
while pointstodo > 0 :

logger.info("reading values")
bytestoread = min(255, bytesleft)
pointstoread = min(255, pointstodo)
# cmd: read FIFO, addr 0x30
self.serial.write([0x18, 0x30, bytestoread])
self.serial.write([0x18, 0x30, pointstoread])

# each value is 32 bytes
nBytes = bytestoread * 32
nBytes = pointstoread * 32

# serial .read() will wait for exactly nBytes bytes
arr = self.serial.read(nBytes)
if nBytes != len(arr):
logger.error("expected %d bytes, got %d", nBytes, len(arr))
return []

for i in range(bytestoread):
for i in range(pointstoread):
b = arr[i*32:]
fwd = complex(_unpackSigned32(b[0:]), _unpackSigned32(b[4:]))
refl = complex(_unpackSigned32(b[8:]), _unpackSigned32(b[12:]))
Expand All @@ -131,7 +131,7 @@ def readValues(self, value) -> List[str]:
#print('freqIndex', freqIndex)
self.sweepData[freqIndex] = (refl / fwd, thru / fwd)

bytesleft = bytesleft - bytestoread
pointstodo = pointstodo - pointstoread

ret = [x[0] for x in self.sweepData]
ret = [str(x.real) + ' ' + str(x.imag) for x in ret]
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ A multiplatform tool to save Touchstone files from the NanoVNA, sweep frequency

Copyright 2019, 2020 Rune B. Broberg

## Changes in this fork
This fork adds support for the saa2, a vna loosely based on the original nanovna with frequency range up to 3Ghz.

## Introduction
This software connects to a NanoVNA and extracts the data for display on a computer, and for saving to Touchstone files.

Expand Down

0 comments on commit 25746fb

Please sign in to comment.