I got an instrument (Vötsch climate chamber VT 4002) connected via TCP/IP and pyVISA as SOCKET and i can query it using *IDN?. Now I need to send a command to it that includes the ASCII 182 character combined with a normal string:
instr = rm.open_resource(TCPIP::...::SOCKET', read_termination='\r')
instr.write('11001'+u'\xb6')
But I get the Error:
UnicodeEncodeError; 'ascii' codec can't encode character u'\xb6' in position 5: ordinal not in range(128)
I know that the ASCII value is above 128, but how to write it to the instrument? Is write even the right command (although the *IDN? query works)? I am new to python and pyVISA, so please answer for newbies :) Thanks!
PS:
# -*- coding: utf-8 -*-
did not work
PPS: I think the problem is that the write() method always uses the ASCII decoding. So no matter which format my string had before the write() method will always decode to ASCII (which can't be done with >128). But is there an alternative to sending the command via TCP/IP without using the write() method?