From: Florent Kermarrec Date: Wed, 13 May 2015 08:13:14 +0000 (+0200) Subject: vpi: cleanup (thanks sb) X-Git-Tag: 24jan2021_ls180~2099^2~61 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=76302d7aa644f9e9a3c852b16de83562391f63c4;p=litex.git vpi: cleanup (thanks sb) --- diff --git a/migen/sim/ipc.py b/migen/sim/ipc.py index 4e0fa529..c6124bb6 100644 --- a/migen/sim/ipc.py +++ b/migen/sim/ipc.py @@ -190,21 +190,22 @@ class Initiator: def send(self, message): self.conn.send(_pack(message)) - def recv(self): - maxlen = 2048 + def recv_packet(self, maxlen): if sys.platform == "win32": - def recv_packet(): - while len(self.ipc_rxbuffer) < header_len: - self.ipc_rxbuffer += self.conn.recv(maxlen) - packet_len = struct.unpack("= maxlen: diff --git a/vpi/ipc.c b/vpi/ipc.c index 21b1efe0..55de27e9 100644 --- a/vpi/ipc.c +++ b/vpi/ipc.c @@ -132,17 +132,17 @@ static int ipc_receive_packet(struct ipc_softc *sc, unsigned char *buffer) { int len; int packet_len; /* ensure we have packet header */ - while (ipc_rxlen < WIN32_HEADER_LEN) { + while(ipc_rxlen < WIN32_HEADER_LEN) { len = recv(sc->socket, (char *)&ipc_rxbuffer[ipc_rxlen], MAX_LEN, 0); - if (len) + if(len) ipc_rxlen += len; } /* compute packet length and ensure we have the payload */ - packet_len = ((ipc_rxbuffer[1] << 8) | (ipc_rxbuffer[0])); - while (ipc_rxlen < packet_len) { - len = recv(sc->socket, (char *) &ipc_rxbuffer[ipc_rxlen], MAX_LEN, 0); - if (len) + packet_len = (ipc_rxbuffer[1] << 8) | ipc_rxbuffer[0]; + while(ipc_rxlen < packet_len) { + len = recv(sc->socket, (char *)&ipc_rxbuffer[ipc_rxlen], MAX_LEN, 0); + if(len) ipc_rxlen += len; }