Skip to content

Commit 5784288

Browse files
committed
minor receive optimisation
1 parent 0925860 commit 5784288

File tree

1 file changed

+10
-6
lines changed
  • software/glasgow/applet/interface/gpib_controller

1 file changed

+10
-6
lines changed

software/glasgow/applet/interface/gpib_controller/__init__.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,17 @@ def elaborate(self, platform):
209209
m.next = "Control: Read data"
210210

211211
with m.State("Control: Read data"):
212-
m.d.sync += self.status.eq(GPIBStatus.Control)
213-
m.d.comb += self.out_fifo.r_en.eq(1)
214-
with m.If(self.out_fifo.r_rdy):
215-
m.d.sync += l_data.eq(self.out_fifo.r_data)
212+
# If it's listen, we do not have to modify any data
213+
# lines, so there's no point in expecting a second
214+
# byte.
215+
with m.If(l_control.listen):
216216
m.next = "Control: Parse"
217+
with m.Else():
218+
m.d.sync += self.status.eq(GPIBStatus.Control)
219+
m.d.comb += self.out_fifo.r_en.eq(1)
220+
with m.If(self.out_fifo.r_rdy):
221+
m.d.sync += l_data.eq(self.out_fifo.r_data)
222+
m.next = "Control: Parse"
217223

218224
with m.State("Control: Parse"):
219225
m.d.sync += [
@@ -338,7 +344,6 @@ async def read(self, *, to_eoi=True):
338344
eoi = False
339345
while not eoi:
340346
await self.interface.write(bytes([GPIBMessage.Listen.value]))
341-
await self.interface.write(bytes([0]))
342347

343348
eoi = bool((await self.interface.read(1))[0] & 2)
344349
if not to_eoi:
@@ -357,7 +362,6 @@ async def read_from(self, address, *, to_eoi=True):
357362
all = bytes([])
358363
async for data in self.read(to_eoi=to_eoi):
359364
all += data
360-
361365
return all
362366

363367
async def iter_from(self, address, *, to_eoi=True):

0 commit comments

Comments
 (0)