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

Strip newlines from StreamHandler #85

Closed
wants to merge 1 commit into from
Closed

Conversation

OwenArnold
Copy link
Contributor

@MikeHart85 stripping the newlines from the input stream makes life a lot easier when connecting via a telnet client.

@OwenArnold
Copy link
Contributor Author

I think that this is supposed to work via in_terminator, out_terminator specifications in the bindings, but even with the toggle crlf modes applied. I couldn't reach the right combination that stripped out the \n from my commands.

@MichaelWedel
Copy link
Contributor

I'm not sure this is the right thing to do. Telnet seems to specify CRLF as EOL-character, but the device is not talking telnet. Telnet is just very similar by chance. I made this small client: https://gist.github.com/MichaelWedel/fd288ac19ef1d08d994e639be78aadd0

Connect to the device like this:

$> python stream_client.py -x -c localhost 9999

@MichaelWedel
Copy link
Contributor

The original gist had some very unfortunately named variables, I made an update.

@MikeHart85
Copy link
Contributor

I agree with @MichaelWedel, this doesn't feel like the right way to deal with this. Sending the wrong line-endings is technically an error... If we sanitize the input, we're potentially hiding an issue.

Allegedly this is supposed to force telnet to use \r (CR) as a line terminator (relying on the fact that if you copy-paste text with CR, telnet will send it exactly as-is without adding NL):

$ sed -u 's/$/\r/' | telnet [IP] [PORT]

But I couldn't get it (or any variation of this strategy using tr or paste, or replacing telnet with nc) to work for me on Ubuntu. Maybe it will give one of you guys ideas though.

@OwenArnold
Copy link
Contributor Author

OwenArnold commented Aug 29, 2016

@MichaelWedel @MikeHart85. Having read your responses, I am forced to agree that this (the changes I provided) is not the right fix.

The stream editor approach above didn't work for me. I haven't tried @MichaelWedel's tool yet, but I do like the idea of interacting with the device + adapter using the native interface via some kind client. I'm sure that this is beneficial for development and deployment. Should we think about distributing these kinds of tools alongside plankton?

@MikeHart85
Copy link
Contributor

I like the idea of shipping a tool like this with plankton. It could be in the same image, and even part of plankton itself. That way, you could just specify the device you're connecting to and it could figure out the correct line-endings to use by itself.

@MichaelWedel
Copy link
Contributor

What's a good way to handle a protocol like the Linkam with all this status byte stuff? In the example above this just gets printed as 0x80 and so on in lack of a better solution.

@OwenArnold
Copy link
Contributor Author

@MichaelWedel @MikeHart85 I think this issue goes away with the work that @MichaelWedel will be doing in the control.py RPC direction. I'm closing this PR.

@OwenArnold OwenArnold closed this Sep 5, 2016
@MikeHart85 MikeHart85 deleted the newline_strip branch September 8, 2016 13:21
@OwenArnold OwenArnold restored the newline_strip branch October 10, 2016 10:10
@OwenArnold OwenArnold deleted the newline_strip branch October 10, 2016 10:11
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

Successfully merging this pull request may close these issues.

None yet

3 participants