Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hal/halmodule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ static PyObject *pyhal_port_read_peek(pyhalitem *item, PyObject *o, bool isread)
b = hal_port_read(item->pin.u->p, PyBytes_AsString(bts), (unsigned)l);
else
b = hal_port_peek(item->pin.u->p, PyBytes_AsString(bts), (unsigned)l);
if(b) {
if(!b) {
Py_DECREF(bts);
Py_INCREF(Py_False);
return Py_False;
Expand Down
1 change: 1 addition & 0 deletions tests/halmodule/port/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pass
19 changes: 19 additions & 0 deletions tests/halmodule/port/porttest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python3
# Port pins: write, then peek/peek_commit/read the same bytes back.
import hal
c = hal.component("porttest")
wr = c.newpin("out", hal.Type.PORT, hal.Dir.OUT)
rd = c.newpin("in", hal.Type.PORT, hal.Dir.IN)
c.ready()
hal.new_sig("portsig", hal.Type.PORT)
hal.connect("porttest.out", "portsig")
hal.connect("porttest.in", "portsig")
hal.set_s("portsig", "16")

assert wr.write(b"hello world")
assert rd.peek(5) == b"hello"
assert rd.peek_commit(6)
assert rd.read(5) == b"world"
assert rd.read(1) is False
c.exit()
print("pass")
1 change: 1 addition & 0 deletions tests/halmodule/port/test.hal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loadusr -w ./porttest.py
Loading