Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

capture error - wrong screen size using nanovna_capture.py (Windows 10, NanoVNA H) #4

Closed
krupis opened this issue Oct 19, 2023 · 3 comments
Assignees
Labels
Not reproducible This cannot be solved unless you give more info Serial Communication Communication protocol

Comments

@krupis
Copy link

krupis commented Oct 19, 2023

We have discussed about this a little bit:
NanoVNA-Saver/nanovna-saver#676

After I have replaced:

#if bytestream == b'capture?\r\nch> ': # error message

with:

if captured_bytes == b'capture?\r\nch> ': # error message

to fix my initial issue:

 NameError: name 'bytestream' is not defined

I still cannot get to run this script on NanoVNA -H due to the following error:

C:\Users\petrikas.lu\Downloads\nanovna-tools-main\nanovna-tools-main>python nanovna_capture.py
capture error - wrong screen size?

Have you tried to run this on NanoVNA-H? Is that an issue related to NanoVNA - H? I tried using --help but does not seem to give any information regarding screen size.

@Ho-Ro
Copy link
Owner

Ho-Ro commented Oct 19, 2023

Have you tried to run this on NanoVNA-H?

The script was developed on my NanoVNA-H.
I just checked it with my NanoVNA-H on a Windows 10 system (only user account, no special setup, nada).
The script should run out of the box, even the fixed typo was not seen unless something goes wrong with the communication.

c:\Users\...\projects\NanoVNA\nanovna-tools>python nanovna_capture.py

c:\Users\...\projects\NanoVNA\nanovna-tools>dir *.png
 ...
19.10.2023  20:57             8.295 NanoVNA-H_20231019_205757.png

NanoVNA-H_20231019_205757

Sorry, I do not know what's wrong with your system, you should try to debug a little bit to help me to support you. You should anyhow be familiar with python and the serial communication syntay when you want to roll your own analysis software.

Just spread some print(...) statements into the code, e.g. after line 114 (if len( captured_bytes ) != 2 * size:)

    print( captured_bytes )
    print( len( captured_bytes ) )

This should give you a long output like this (only last part of the very long line shown), the last number may be different (my example shows the correct len).

...
\xff\xff\xff\xff\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\x00\x00\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00A@'
153600
capture error - wrong screen size?

If the output looks very different, please post here.

I tried using --help but does not seem to give any information regarding screen size.

Screen size is automatically set for the detected (or forced by option) device, default is NanoVNA-H (tinySA has the same screen size and the same command structure). The device setting also changes the name of the png file.

# The size of the screen (2.8" devices)
width = 320
height = 240

# set by option
if options.tinysa:
    devicename = 'tinySA'
elif options.ultra:
    devicename = 'tinySA Ultra'
    width = 480
    height = 320
elif options.h4:
    devicename = 'NanoVNA-H4'
    width = 480
    height = 320
# get it from USB descriptor (supported by newer FW from DiSlord or Erik)
elif device and 'tinySA4' in device.description:
    devicename = 'tinySA Ultra'
    width = 480
    height = 320
elif device and 'tinySA' in device.description:
    devicename = 'tinySA'
elif device and 'NanoVNA-H4' in device.description:
    devicename = 'NanoVNA-H4'
    width = 480
    height = 320
# fall back to default name
else:
    devicename = 'NanoVNA-H'

@Ho-Ro
Copy link
Owner

Ho-Ro commented Oct 20, 2023

As an extra service for @krupis I built the script nanovna_communication_template.py.

Command line template to send a serial shell command to NanoVNA:
- Connect via USB serial
- Encode the command string to bytearray
- Send the command + CR
- Get the command echo + CRLF
- Get the response + CRLF + prompt
- Format the response (remove CRLF + prompt)
- Decode the response bytearray to string
- Write the response string to stdout

Please play with this tool to debug your system issues.

@Ho-Ro Ho-Ro added Serial Communication Communication protocol Not reproducible This cannot be solved unless you give more info labels Oct 24, 2023
@Ho-Ro
Copy link
Owner

Ho-Ro commented Oct 31, 2023

Either @krupis has solved his problem or is no longer interested in this topic - either way, I'm closing here. You can contact me here if you are still interested. I cannot reproduce the error, neither under Linux nor under Windows.

@Ho-Ro Ho-Ro closed this as completed Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Not reproducible This cannot be solved unless you give more info Serial Communication Communication protocol
Projects
None yet
Development

No branches or pull requests

2 participants