@@ -8,7 +8,7 | |||||
8 |
|
8 | |||
9 | class ABSClient: |
|
9 | class ABSClient: | |
10 |
|
10 | |||
11 |
def __init__(self,ipSource="localhost", ipDestino="192.168.1.1 |
|
11 | def __init__(self,ipSource="localhost", ipDestino="192.168.1.117", portDestino=7000): | |
12 |
|
12 | |||
13 | self.ipSource = ipSource |
|
13 | self.ipSource = ipSource | |
14 | self.ipDestino = ipDestino |
|
14 | self.ipDestino = ipDestino | |
@@ -33,11 +33,13 | |||||
33 |
|
33 | |||
34 | self.commObj.sendData(cmd="SNDF", data=data) |
|
34 | self.commObj.sendData(cmd="SNDF", data=data) | |
35 | self.commObj.waitData() |
|
35 | self.commObj.waitData() | |
|
36 | self.commObj.close_socket() | |||
36 |
|
37 | |||
37 | def changeBeam(self, newBeam): |
|
38 | def changeBeam(self, newBeam): | |
38 |
|
39 | |||
39 | self.commObj.sendData(cmd="CHGB", data=newBeam) |
|
40 | self.commObj.sendData(cmd="CHGB", data=newBeam) | |
40 | self.commObj.waitData() |
|
41 | self.commObj.waitData() | |
|
42 | self.commObj.close_socket() | |||
41 |
|
43 | |||
42 | def __writeFile(self, filename, data): |
|
44 | def __writeFile(self, filename, data): | |
43 |
|
45 | |||
@@ -49,6 +51,7 | |||||
49 |
|
51 | |||
50 | self.commObj.sendData(cmd="ANST", data = data) |
|
52 | self.commObj.sendData(cmd="ANST", data = data) | |
51 | ipSource, ipDestino, cmd, data = self.commObj.waitData() |
|
53 | ipSource, ipDestino, cmd, data = self.commObj.waitData() | |
|
54 | self.commObj.close_socket() | |||
52 | self.__writeFile("report.txt", data) |
|
55 | self.__writeFile("report.txt", data) | |
53 |
|
56 | |||
54 | ########## |
|
57 | ########## |
@@ -86,7 +86,8 | |||||
86 | self.ipDestino = ipDestino |
|
86 | self.ipDestino = ipDestino | |
87 | self.portDestino = portDestino |
|
87 | self.portDestino = portDestino | |
88 | self.addr = (ipDestino,portDestino) |
|
88 | self.addr = (ipDestino,portDestino) | |
89 | self.addr2 = ("none",0) |
|
89 | ||
|
90 | self.sc = "none" | |||
90 | self.answer = "none" #test |
|
91 | self.answer = "none" #test | |
91 | self.mode = "none" |
|
92 | self.mode = "none" | |
92 |
|
93 | |||
@@ -114,16 +115,18 | |||||
114 |
|
115 | |||
115 | self.socket_c.bind(self.addr) |
|
116 | self.socket_c.bind(self.addr) | |
116 | self.socket_c.listen(1) |
|
117 | self.socket_c.listen(1) | |
117 |
s |
|
118 | sc, addr = self.socket_c.accept() | |
|
119 | self.sc = sc | |||
|
120 | self.answer = addr | |||
118 | print "\nServer initialized" |
|
121 | print "\nServer initialized" | |
119 |
|
122 | |||
120 | def waitData(self, nbytes = 16384): |
|
123 | def waitData(self, nbytes = 16384): | |
121 |
|
124 | |||
122 | print "\nWaiting some data" |
|
125 | print "\nWaiting some data" | |
123 | if self.mode == "client": |
|
126 | if self.mode == "client": | |
124 |
trama_rx |
|
127 | trama_rx = self.socket_c.recv(nbytes) | |
125 | else: |
|
128 | else: | |
126 |
trama_rx |
|
129 | trama_rx = self.sc.recv(nbytes) | |
127 |
|
130 | |||
128 | print "\nThis socket has received some data from:" |
|
131 | print "\nThis socket has received some data from:" | |
129 | print self.answer |
|
132 | print self.answer | |
@@ -158,6 +161,10 | |||||
158 |
|
161 | |||
159 | return ipSource, ipDestino, cmd, data |
|
162 | return ipSource, ipDestino, cmd, data | |
160 |
|
163 | |||
|
164 | def close_socket(): | |||
|
165 | self.socket_c.close() | |||
|
166 | ||||
|
167 | ||||
161 | #class FTPComm: |
|
168 | #class FTPComm: | |
162 | # |
|
169 | # | |
163 | # ftp_servidor = 'ftp.servidor.com' |
|
170 | # ftp_servidor = 'ftp.servidor.com' |
General Comments 0
You need to be logged in to leave comments.
Login now