Skip to content
This repository has been archived by the owner on Jan 27, 2024. It is now read-only.

Disabled input processing #17

Merged
merged 1 commit into from
Jan 26, 2020
Merged

Disabled input processing #17

merged 1 commit into from
Jan 26, 2020

Conversation

mri-scanomat
Copy link
Contributor

Hi

We had an issue on Linux that some input characters were converted on the input side, like 0x0D -> 0x0A, which was a problem for us as we are working with a binary protocol. So we had to ensure to disable all input processing to avoid problem with currupt packages and wrong checksums.

So please see the suggested change and judge if it can be useful to you. Otherwise we would suggest adding a "processInput" flag and make that disable or enable this feature so that it is clear what is happening.

But thanks for a otherwise very functional library :)

@yeokm1
Copy link
Owner

yeokm1 commented Jan 11, 2020

Hi @mri-scanomat, thanks for your PR. Give me some time to look into it and test your improvement on both Mac and Linux. If I can't replicate it, your suggestion to make it into an option is great and I'll probably do that.

I would like to clarify though, when you say the characters are changed on the input side. Was it changed on the sender or receiver? That is, when you used this library on Linux, is the Linux system the transmitting or receiving party?

@mri-scanomat
Copy link
Contributor Author

Hi @yeokm1, Sound good.

In our case we look at linux as the receiver. So linux <-> embedded device.
We would send some data from linux to our embedded device. The embedded device would receive the data successfully and process it. The embedded device would then send a reply, that in some cases would contain the hex value 0x0D as part of its response. like "0x11 0x22 0x33 0x0D 0x44". We could with a digital analyser verify that the data on the wire where correct, but what we received inside the swift app was ""0x11 0x22 0x33 0x0A 0x44". So the character 0x0D was changed to 0x0A. This fits with the flag ICRNL being set as it is described as

ICRNL - Translate carriage return to newline on input

To ensure this did not happen and that other input changed also did not happen, we added the three flags to the c_iflag. As minimum, we had to disable the "ICRNL" flag to not get the above behaviour on Linux. The two others were more of a precaution.

Hope it makes sense and that you can reproduce it :)

@yeokm1
Copy link
Owner

yeokm1 commented Jan 22, 2020

Hi @mri-scanomat, apologise I'm busy this few weeks. I can only look into this issue 2 weekends from now. Any hurry to get this resolved?

@mri-scanomat
Copy link
Contributor Author

Hi @yeokm1, No problem, we are not in a hurry. We have a local Fork that we are using right now so no worry. We just wanted to push back this change to help others :)

@yeokm1 yeokm1 merged commit 46a834e into yeokm1:master Jan 26, 2020
@yeokm1
Copy link
Owner

yeokm1 commented Jan 26, 2020

@mri-scanomat Hi, I can replicate your issue and your solution works.

Updated the release code to 0.1.2.

I also included an additional test example for binary data. https://github.com/yeokm1/SwiftSerial/tree/master/Examples/SwiftSerialBinary

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

Successfully merging this pull request may close these issues.

2 participants