Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1041

Python PyVISA UnicodeDecodeError

$
0
0

I would like to use a RIGOL MSO5000 Series Scope as a 4 Channel DMM.

The device responds to *IDN? as expected, but there is a decoding issue for :WAV:DATA?

import pyvisarm = pyvisa.ResourceManager()scope = rm.open_resource("USB0::0x1AB1::0x0515::MS5A233404321::0::INSTR")print("" + scope.query("*IDN?"))scope.write(":RUN")scope.write(":WAV:SOUR CHAN1")scope.write(":WAV:MODE NORMal")scope.write(":WAV:FORM BYTE")print(scope.query(":WAV:DATA?"))scope.close()

Error

Exception has occurred: UnicodeDecodeError'ascii' codec can't decode byte 0x80 in position 11: ordinal not in range(128)UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 11: ordinal not in range(128)

The error persists even if I try

print(scope.query(":WAV:DATA?").decode(errors='ignore'))print(scope.query(":WAV:DATA?").decode('utf8', errors='ignore'))print(scope.query(":WAV:DATA?").read(encoding='CP-1252'))

Viewing all articles
Browse latest Browse all 1041

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>