WriteBytes does not return how many bytes were not written
danielgruber opened this issue · 4 comments
Hello,
At the moment we encountered that writeBytes does not return how many bytes were written. For a CTS / RTS flow, this is absolutly necessary. Is there a reason why this is not needed / or how we use this library correctly with hardware CTS / RTS without losing data in the middle?
Thanks a lot!
Best
Daniel
Hi,
I don't believe this is possible currently. To support this without breaking backwards compatibility, a new function (e.g. write(bytes[])
) would have to be written and the old boolean functions would have to be update to check the return length.
This would require Windows and Unix C++ code to be updated to return jint
and the current functions would be wrapped to still return a boolean.
Disclaimer, this library is mostly in maintenance mode, so any features would have to be authored by the vested/interested parties.
Relevant functions:
Unix:
jssc/src/main/cpp/_nix_based/jssc.cpp
Lines 528 to 535 in 6886b44
Windows:
jssc/src/main/cpp/windows/jssc.cpp
Lines 234 to 257 in 6886b44
Hi @tresf,
Thanks for your update! I’m happy to implement the changes, still I would first want to know if there was a reason behind it not to implement it like this from the beginning?
So is this at all possible with the C stack being used? Or do I have to try?
Thanks!
Best
Daniel
I would first want to know if there was a reason behind it not to implement it like this from the beginning?
Hi, this project is a fork of the original from https://github.com/scream3r/java-simple-serial-connector, so the history behind this decision likely lies there.
So is this at all possible with the C stack being used? Or do I have to try?
I think the Unix code makes it relatively easy, but I'm not sure about the win32 API. Perhaps the answer lies in GetOverlappedResult
returning a zero? I'm not very familiar with hardware flow control and only partially familiar with the C++ portions of the codebase. We do have some other volunteers here as well as a Slack channel if interested. @hiddenalpha has been very helpful with the C++ portions as well.
Looks related to issue #96