Jim Lux 2021/05/13 06:47
On 5/13/21 6:25 AM, TomS wrote:
> Hello Jim Lux,
> you are right. That's the way I tried with putty, but I'm quite sure I
> use the wrong settings, because I do not get a promt, just a cursor.
> And the only answer I get is the response to the 0x0D character which
> is the INDICATE command ( = 2) at the same time. Have you used putty
> for testing the communication?
>
> If the terminal works on the original version, like I use today, there
> is a big question for me. How are the terminal commands separated form
> the hex commands described by nanorfe.? Or do the nanovna accept all
> commands at the same time? I don't think so, but I'm not sure.
>
> I assume there are two different ways of communication, based on the
> com port. The terminal mode (how I can enter it with putty ???) and
> the hex command mode which i try to realize with LV?
>
> best regards
> TomS
> I
I would look in the NanoVNASaver/Hardware subdirectory of the
NanoVNA-Saver install - there's python code there for all the flavors,
and NanoVNA_V2.py might give you some clues about what you need to send.
NanoVNA.py seems to use text commands:
def resetSweep(self, start: int, stop: int):
list(self.exec_command(f"sweep {start} {stop} {self.datapoints}"))
list(self.exec_command("resume"))
NanoVNA_V2.py uses byte commands:
def setSweep(self, start, stop):
step = (stop - start) / (self.datapoints - 1)
if start == self.sweepStartHz and step == self.sweepStepHz:
return
self.sweepStartHz = start
self.sweepStepHz = step
logger.info('NanoVNAV2: set sweep start %d step %d',
self.sweepStartHz, self.sweepStepHz)
self._updateSweep()
return
def _updateSweep(self):
cmd = pack("<BBQ", _CMD_WRITE8,
_ADDR_SWEEP_START, int(self.sweepStartHz))
cmd += pack("<BBQ", _CMD_WRITE8,
_ADDR_SWEEP_STEP, int(self.sweepStepHz))
cmd += pack("<BBH", _CMD_WRITE2,
_ADDR_SWEEP_POINTS, self.datapoints)
cmd += pack("<BBH", _CMD_WRITE2,
_ADDR_SWEEP_VALS_PER_FREQ, 1)
with self.serial.lock:
self.serial.write(cmd)
sleep(WRITE_SLEEP)