我有以下脚本,我希望连接到我们的产品,发送 tcl 命令(设置频率和其他一些命令),但它只显示:
导入服务器
服务器.ScktConn()
频率(450-2500):600
接收:0 ace_set_frequency C1 600
这是第一个命令,但它甚至没有设置频率(只显示 cmd,但不应用它)!
这是脚本:
import socket
import threading
import time
address = ('127.0.0.1', 5426)
def ScktRecv():
r = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
r.bind(address)
r.listen(5)
conn, _ = r.accept()
csvid = conn.recv(4096)
print "recv: %s" % csvid
conn.close()
def ScktConn():
recv_thread = threading.Thread(target=ScktRecv)
recv_thread.start()
time.sleep(1)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(address)
# our local IP is 192.168.2.1, but it works even with 127.0.0.1, I don't know from where #it is coming
Freq=raw_input('Frequency(450-2500): ')
CmdF='0 ace_set_frequency C1 '+str(Freq)+' \r\n'
s.send(CmdF)
s.send('0 ace_azplayer_remove_player AzPlayer1 \r\n')
s.send('0 ace_azplayer_add_player \r\n')
s.send('0 ace_azplayer_add_ace AzPlayer1 C1\r\n')
Path='C:/Users/amir_rajaee/Desktop/gridview_script/PBF/4x4U_wocorr_SNR.csv'
s.send('0 ace_azplayer_load_csvfile AzPlayer1 '+Path+' \r\n')
s.close()
但是当我使用以下脚本时,它会设置频率,但我的问题是,我没有接收器;我需要输出最后一个命令(加载 csv 文件)!:
import socket
def ScktConn():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.1', 5006))
Freq=raw_input('Frequency(450-2500): ')
CmdF='0 ace_set_frequency C1 '+str(Freq)+' \r\n'
s.send(CmdF)
s.send('0 ace_azplayer_remove_player AzPlayer1 \r\n')
s.send('0 ace_azplayer_add_player \r\n')
s.send('0 ace_azplayer_add_ace AzPlayer1 C1\r\n')
Path='C:/Users/amir_rajaee/Desktop/gridview_script/PBF/4x4U_wocorr_SNR.csv'
s.send('0 ace_azplayer_load_csvfile AzPlayer1 '+Path+' \r\n')