Module output not quite working
walksanatora opened this issue ยท 6 comments
so i have the following stepOutput function
private void stepOutput() {
this.cancelWrite();
if (outbuf.size() > 0) {
boolean hasWritten = false;
short val = outbuf.get(0);
TISString.LOGGER.info("Writing value {} mode {}",val,mode);
for (final Port port : Port.VALUES) {
final Pipe sendingPipe = getCasing().getSendingPipe(getFace(), port);
if (!sendingPipe.isWriting()) {
TISString.LOGGER.info("writing {} {}",val,port);
sendingPipe.beginWrite(val);
hasWritten = true;
}
}
if (hasWritten) {outbuf.remove(0);}
}
}
any in my logs i get
[02Mar2023 16:17:03.894] [Server thread/INFO] [tisstring/]: Writing value 50 mode INT
[02Mar2023 16:17:03.901] [Server thread/INFO] [tisstring/]: writing 50 LEFT
[02Mar2023 16:17:03.901] [Server thread/INFO] [tisstring/]: writing 50 RIGHT
[02Mar2023 16:17:03.904] [Server thread/INFO] [tisstring/]: writing 50 UP
[02Mar2023 16:17:03.907] [Server thread/INFO] [tisstring/]: writing 50 DOWN
[02Mar2023 16:17:03.911] [Server thread/INFO] [tisstring/]: Writing value 45 mode UNIT
[02Mar2023 16:17:03.913] [Server thread/INFO] [tisstring/]: writing 45 LEFT
[02Mar2023 16:17:03.915] [Server thread/INFO] [tisstring/]: writing 45 RIGHT
[02Mar2023 16:17:03.916] [Server thread/INFO] [tisstring/]: writing 45 UP
[02Mar2023 16:17:03.916] [Server thread/INFO] [tisstring/]: writing 45 DOWN
[02Mar2023 16:17:03.942] [Server thread/INFO] [tisstring/]: Writing value 53 mode INT
[02Mar2023 16:17:03.943] [Server thread/INFO] [tisstring/]: writing 53 LEFT
[02Mar2023 16:17:03.944] [Server thread/INFO] [tisstring/]: writing 53 RIGHT
[02Mar2023 16:17:03.945] [Server thread/INFO] [tisstring/]: writing 53 UP
[02Mar2023 16:17:03.945] [Server thread/INFO] [tisstring/]: writing 53 DOWN
[02Mar2023 16:17:03.946] [Server thread/INFO] [tisstring/]: Writing value 50 mode UNIT
[02Mar2023 16:17:03.946] [Server thread/INFO] [tisstring/]: writing 50 LEFT
[02Mar2023 16:17:03.947] [Server thread/INFO] [tisstring/]: writing 50 RIGHT
[02Mar2023 16:17:03.948] [Server thread/INFO] [tisstring/]: writing 50 UP
[02Mar2023 16:17:03.948] [Server thread/INFO] [tisstring/]: writing 50 DOWN
[02Mar2023 16:17:03.991] [Server thread/INFO] [tisstring/]: Writing value 0 mode INT
[02Mar2023 16:17:03.991] [Server thread/INFO] [tisstring/]: writing 0 LEFT
[02Mar2023 16:17:03.992] [Server thread/INFO] [tisstring/]: writing 0 RIGHT
[02Mar2023 16:17:03.992] [Server thread/INFO] [tisstring/]: writing 0 UP
[02Mar2023 16:17:03.993] [Server thread/INFO] [tisstring/]: writing 0 DOWN
[02Mar2023 16:17:03.993] [Server thread/INFO] [tisstring/]: Writing value 53 mode UNIT
[02Mar2023 16:17:03.993] [Server thread/INFO] [tisstring/]: writing 53 LEFT
[02Mar2023 16:17:03.994] [Server thread/INFO] [tisstring/]: writing 53 RIGHT
[02Mar2023 16:17:03.994] [Server thread/INFO] [tisstring/]: writing 53 UP
[02Mar2023 16:17:03.994] [Server thread/INFO] [tisstring/]: writing 53 DOWN
[02Mar2023 16:17:04.040] [Server thread/INFO] [tisstring/]: Writing value 0 mode UNIT
[02Mar2023 16:17:04.041] [Server thread/INFO] [tisstring/]: writing 0 LEFT
[02Mar2023 16:17:04.041] [Server thread/INFO] [tisstring/]: writing 0 RIGHT
[02Mar2023 16:17:04.042] [Server thread/INFO] [tisstring/]: writing 0 UP
[02Mar2023 16:17:04.042] [Server thread/INFO] [tisstring/]: writing 0 DOWN
but then the Terminal
module which i placed above has no text displayed on it
(UNIT and INT are two diffrent modules, and two seperate displays)
the module impl is at https://github.com/walksanatora/tis-stringify/blob/master/src/main/java/net/walksanator/tisstring/modules/stringmodule/StringModule.java
What's the motivation behind the cancelWrite
?
Why I'm asking: writes are not immediate, they need to be consumed by a read. Think of it as kind of a handshake. I know it's a bit awkward, but this system is required to ensure consistency in the number of cycles moves take, independent of module update order.
So as I understand it, this module is beginning writes but never allows the reading module to finish the read.
If it's to ensure the code point is only written to one side, consider using the hooks for finished writes instead. See the queue module for reference on that. Edit: saw that's already in there. Should be enough I think.