Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Binärika": byte level Erika mock #76

Open
ArchibaldBienetre opened this issue Jan 18, 2020 · 2 comments
Open

"Binärika": byte level Erika mock #76

ArchibaldBienetre opened this issue Jan 18, 2020 · 2 comments

Comments

@ArchibaldBienetre
Copy link

ArchibaldBienetre commented Jan 18, 2020

With the current AbstractErikaMock + subclasses, we had issues in the past that the mock interface and the real interface would drift apart.

As a mitigation, we added ugly meta code to the constructors... This does not feel right / not feel python-y.
Instead, there's one level of abstraction where we cannot drift apart, that's the actual bytes as understood by the Erika device.

The BinErika implementation should

  • offer a simple interface, just sending and receiving bytes / a byte stream
    • and, of course, a way to close the connection properly
  • internally, it should mirror the behavior of the real device to the extent that we already support for the real Erika class
  • some bytes start commands that will require at least one more byte - this behavior should match, BinErika should expect another related byte
    • Unclear: how will the real Erika deal with invalid commands? Will there ever be such a case?
      • E.g., the left / right microstep movement needs a second byte as parameter for the number of steps to move - but there's no issue with invalid input because all values are allowed
  • Hitting physical boundaries is a whole different issue - by default, the device will just stop when reaching a physical boundary (left margin / right margin) - BinErika should mirror this behavior, but deliver some output that this situation happened
  • the visible rendering output of this simulation class should use curses (like already used by the other mocks)
  • optional: wholly unknown commands should result in hard failure, so we know early if a feature is missing completely
  • optional: Of course, should we support different type wheels, there will have to be an adjustment.
    This can be considered in the code: offer a distinction between which byte mappings are inherent, and which are type wheel-dependent.
@ArchibaldBienetre
Copy link
Author

Implementation can happen in small steps

  • let's make it work for simple left-to-write text output + newlines first
  • with this as a basis, we can work in parallel for other features

@cyroxx
Copy link
Member

cyroxx commented Jan 18, 2020

Parts of what you are trying to achieve here could be tackled by (re-)implementing the DDR-ASCII codec on top of the Python codecs framework: https://docs.python.org/3/library/codecs.html
When we include support for (custom) ANSI escape sequences, we could "translate" all supported characters and control codes the Erika has.
Other thoughts:

  • Different type wheels could be represented as different codecs
  • The interfaces of the codecs package already allow for extension. For example, you can use/implement the error handlers strict or ignoreor you can register new ones.
  • IncrementalEncoder/IncrementalDecoder are allowed to be stateful and could be used in cases like your microstep example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants