我正在尝试发送Hex命令" ABBA05B80000AF11"到一台使用TCP / IP通信的机器,指示机器执行一个命令。看起来像我发送的Hex命令无法通过,任何人都可以帮助我。谢谢
import socket
import sys
import struct
import time
import binascii
host = '192.168.1.40'
port = 800
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
inputHex = binascii.unhexlify("ABBA05B80000AF11")
try:
remote_ip = socket.gethostbyname(host)
s.connect((host, port))
except socket.gaierror:
print('Hostname could not be resolved Exiting')
sys.exit()
print('Socket connected to ' + host + ' on ip '+remote_ip)
try:
while True:
s.send(inputHex)
print('Message sent Successfully')
time.sleep(1)
print('sending')
except socket.error:
print('send fail')
` enter code here`sys.exit()
s.close()