¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

NanoVNA-H batch processing by nVargs #test-jig


 

This draft recipe is missing ingredients and wants baking.
Comments are invited:


 

Oristo,
"nVargs.py" is a nice little beginners Python skeleton script without the complexities of Class modules. For new writers modeling their scripts based on "nVargs.py", the following would be helpful.

"nVargs.py" returns the echoed command as part of the returned data (i.e. "# frequencies" below) :

python nVargs.py frequencies
# frequencies
50000
9049500
18049000
¡­..

I understand the echoed command is used for commenting in your gnuplots, but for more general use it would be nice to include commented code in your script showing how to return data without the echoed command. Having the echoed command as part of the returned data can be an impediment to further processing, where a string is contained in an otherwise numerical array.

Really appreciate your contributions to the group, especially your documentation efforts that must feel like trying to hit a moving target. The pace of on-going development with the NanoVNA is remarkable.

-Herb


 

without the complexities of Class modules
a history of shell scripting in bash and embedded drivers in C...
Classes mostly make sense, IMO, for GUI apps.

for more general use it would be nice to include commented code in your script
showing how to return data without the echoed command
.. or nanoVNA shell could honor `echo off`...

Dead code becomes quickly dangerous, in my experience.
I cannot tell you how many times I have dealt with
code that was rewritten around comments
so that those comments became worse than nothing.

Searching for "\r" may anyway become an issue when using linux `paste`
for combining output columns to build more elaborate pseudo-Touchstone,
that enable more complex gnuplot comparison graphs, my key goal.

.. but I first want to break out the port I/O kernel (really stolen from Rune)
so that multiple nanoVNA commands may be sent in a single nVargs.py invocation,
given Python's invocation overhead.
For my purpose, having those foreplay commands as addition comments
helps avoid very complicated filenames.


 

return data without the echoed command
By popular demand, a dedicated script:



I needed to sort Python string handling anyway..


 

I first want to break out the port I/O kernel (really stolen from Rune)
so that multiple nanoVNA commands may be sent in a single nVargs.py invocation
nVargs.py now implements multiple commands per invocation, surrounded by (unlogged) `pause` and `resume`
Both it and nVcmd.py are tweaked to eliminate redundant trailing newline.


If e.g. nanVNA is calibrated for four frequency bands:
50-658, 666-8660, 9800-114000, 126000-1500000

.. then a single invocation can collect data for all four bands, e.g.

py nVargs.py "recall 0" "data 0" "recall 1" "data 0" recall 2" "data 0" "recall 3" "data 0"

Double-quotes are required for passing multi-word commands to the script as e.g. 8, rather than 16, arguments..


Output for all for sets of data redirect to a single file.


 

Oristo,
Your use of List slicing, "result[1+d.start():])", to trim the blank and echoed command line from the returned data trumps my idea of:

ser.write(command.encode('ascii'))
sleep(0.1) # mark time
ser.readline() # discard blank line
sleep(0.1)
ser.readline#() # discard echoed command line
¡­..


The above works but has timing issues on my i7, 2 GHz PC without the additional "sleep" statements. List slicing is a much more generalized solution. Thanks for sharing.

- Herb


 

Thanks for sharing
Thank Rune's Hardware.py for that core IO routine.
Once anything that interacts with hardware gets stable,
I go out of my way to avoid breaking it.

After surrendering to Python string handling, the rest appeared
by searching DuckDuckGo with appropriate keywords
and discarding uglier examples.

If Python supported macros,
I would create one to approximate C# Substring().
I consider list slicing syntax ugly.


 

By popular demand, a dedicated script:

I created bash alias 'nt' for this and no longer bother using a serial terminal.
This allows using bash history to recall commands.
Of course, the same could be done for Windows cmd.exe using a one line batch file..

$ nt trace
0 LOGMAG CH0 15.000000000 7.000000000
1 SMITH CH0 1.000000000 0.000000000
2 POLAR CH1 0.100000001 0.000000000
3 LINEAR CH1 0.200000002 0.000000000
$ nt "recall 2"
$ nt trace
0 LOGMAG CH0 15.000000000 7.000000000
1 SMITH CH0 1.000000000 0.000000000
$ nt sweep
666000 8660000 101
$ nt "recall 3"
$ nt sweep
9800000 114000000 101