Hi,
I have a device where the remote control service is a TCP/IP channel and the server is listening on port 50000 of the PC where the device software application is running.
It’s working with some Python code but do you think it’s could be possible to clone the python code below directly in HTBasic language ?
import socket
import sys
def BuildMsg(msgid, msgbody):
# this function takes the raw msg ID and the raw msg body
# and wraps it in the expected token syntax:
# <MSG_ID>msg body<EOM>
return ‘<‘ + msgid + ‘>’ + msgbody + ‘<EOM>’
#————————————
# Main
#————————————
if __name__ == ‘__main__’:
s = socket.socket()
s.settimeout(30.0)
try:
s.connect((‘127.0.0.1’, 50000))
except:
print(“\nDevice not connected !!!”)
sys.exit()
print(‘\nDevice connected\n’)
svoie = str(elt_num)
fullmsg = BuildMsg(‘IMPEDANCE_MEASURE’, svoie)
s.send(fullmsg.encode(‘utf-8’))
rxmsg = s.recv(4096)
fullmsg = BuildMsg(‘IMPEDANCE_CLOSE’, ”)
s.send(fullmsg.encode(‘utf-8’))
rxmsg = s.recv(4096)
print(“—> PYTHON Socket close”)
s.close()