-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatt_socket.py
58 lines (41 loc) · 1.09 KB
/
att_socket.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#30/05/2017
#VELLEYEN Stephane
############################# Config socket
import socket
import time
import sys
ip="192.168.1.11" #Attenuator IP adress [set by Stephane on LPNWS5222 with LanTronix DeviceInstaller]
port=10001 # Attenuator Port [set by Vincent]
instr=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
instr.connect((ip,port))
############################# Valeur par defaut & demande d'id
ch=1
att=10
instr.send('*IDN?\r')
name=instr.recv(2048)
print name
chancmd = "CHAN {0}\r".format(ch)
instr.send(chancmd) #set ask?id
#############################
choix=sys.argv[1]
att=sys.argv[2]
att=int(att)
if choix=="1": #Mode Attenuation fixe
print "Mode Attenuation fixe"
attcmd = "ATTN {0}\r".format(att)
print "Setting:",attcmd
instr.send(attcmd) #set attenuation
elif choix=="2": #Mode Incrementation
print "Mode Incrementation"
attcmd = "ATTN {0}\r".format(att)
print "Setting:",attcmd
instr.send(attcmd) #set attenuation
time.sleep(1)
i=att
while i < 80:
incrcmd = 'INCR\r'
instr.send(incrcmd) #set incrementation
time.sleep(1)
i=i+1
else:
print "Erreur"