NanoVNA icon indicating copy to clipboard operation
NanoVNA copied to clipboard

Extra "0." in string returned from data() method

Open InventoryTech opened this issue 4 years ago • 0 comments

I have (infrequently) been getting exceptions when calling data() method. I added some debug logging:

def data(self, array = 0):
    self.send_command("data %d\r" % array)
    data = self.fetch_data()
    x = []
    for line in data.split('\n'):
        if line:
            try:                                           # added try..catch block to debug
                d = line.strip().split(' ')
                x.append(float(d[0])+float(d[1])*1.j)
            except Exception as e:
                print(e)
                print("line was " + line)
    return np.array(x)

And when the problem occurs:

could not convert string to float: '0.0.1359530' line was 0.108219824 0.0.1359530

InventoryTech avatar Jan 12 '20 23:01 InventoryTech