Created
July 20, 2020 17:51
-
-
Save TiltMeSenpai/3ac9cd3da6a198f046c93500fa7a40a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requires https://pypi.org/project/python-vxi11/, python 3.6+ | |
import vxi11 | |
import socketserver | |
TARGET_SCOPE_IP = "10.0.0.214" | |
LOCAL_ADDR = ("127.0.0.1",1234) | |
class VXI11TcpServer(socketserver.StreamRequestHandler): | |
def handle(self): | |
instr = vxi11.Instrument(TARGET_SCOPE_IP) | |
while(True): | |
self.data = self.rfile.readline().strip() | |
print(f"> {self.data}") | |
instr.write_raw(self.data) | |
if b"?" in self.data: | |
resp = instr.read_raw() | |
print(f"< {resp}") | |
self.wfile.write(resp) | |
if __name__=="__main__": | |
with socketserver.TCPServer(LOCAL_ADDR, VXI11TcpServer) as server: | |
server.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment