vpi: cleanup (thanks sb)
This commit is contained in:
parent
98cf103c65
commit
76302d7aa6
|
@ -190,10 +190,8 @@ class Initiator:
|
||||||
def send(self, message):
|
def send(self, message):
|
||||||
self.conn.send(_pack(message))
|
self.conn.send(_pack(message))
|
||||||
|
|
||||||
def recv(self):
|
def recv_packet(self, maxlen):
|
||||||
maxlen = 2048
|
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
def recv_packet():
|
|
||||||
while len(self.ipc_rxbuffer) < header_len:
|
while len(self.ipc_rxbuffer) < header_len:
|
||||||
self.ipc_rxbuffer += self.conn.recv(maxlen)
|
self.ipc_rxbuffer += self.conn.recv(maxlen)
|
||||||
packet_len = struct.unpack("<H", self.ipc_rxbuffer[:header_len])[0]
|
packet_len = struct.unpack("<H", self.ipc_rxbuffer[:header_len])[0]
|
||||||
|
@ -201,10 +199,13 @@ class Initiator:
|
||||||
self.ipc_rxbuffer += self.conn.recv(maxlen)
|
self.ipc_rxbuffer += self.conn.recv(maxlen)
|
||||||
packet = self.ipc_rxbuffer[header_len:packet_len]
|
packet = self.ipc_rxbuffer[header_len:packet_len]
|
||||||
self.ipc_rxbuffer = self.ipc_rxbuffer[packet_len:]
|
self.ipc_rxbuffer = self.ipc_rxbuffer[packet_len:]
|
||||||
return packet
|
|
||||||
packet = recv_packet()
|
|
||||||
else:
|
else:
|
||||||
packet = self.conn.recv(maxlen)
|
packet = self.conn.recv(maxlen)
|
||||||
|
return packet
|
||||||
|
|
||||||
|
def recv(self):
|
||||||
|
maxlen = 2048
|
||||||
|
packet = self.recv_packet(maxlen)
|
||||||
if len(packet) < 1:
|
if len(packet) < 1:
|
||||||
return None
|
return None
|
||||||
if len(packet) >= maxlen:
|
if len(packet) >= maxlen:
|
||||||
|
|
|
@ -139,7 +139,7 @@ static int ipc_receive_packet(struct ipc_softc *sc, unsigned char *buffer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* compute packet length and ensure we have the payload */
|
/* compute packet length and ensure we have the payload */
|
||||||
packet_len = ((ipc_rxbuffer[1] << 8) | (ipc_rxbuffer[0]));
|
packet_len = (ipc_rxbuffer[1] << 8) | ipc_rxbuffer[0];
|
||||||
while(ipc_rxlen < packet_len) {
|
while(ipc_rxlen < packet_len) {
|
||||||
len = recv(sc->socket, (char *)&ipc_rxbuffer[ipc_rxlen], MAX_LEN, 0);
|
len = recv(sc->socket, (char *)&ipc_rxbuffer[ipc_rxlen], MAX_LEN, 0);
|
||||||
if(len)
|
if(len)
|
||||||
|
|
Loading…
Reference in New Issue