java-native / jssc

Java library for talking to serial ports (with added build support for maven, cmake, MSVC)
https://discord.gg/RBsUfE9sX9
GNU Lesser General Public License v3.0
170 stars 53 forks source link

How to set inter-character gap #172

Closed devaskim closed 2 months ago

devaskim commented 2 months ago

Hi,

We found out that OPC server can poll our device with 115200 baudrate, but only with non-zero inter-character gap. Now we use 1ms.

Is there any API to set inter character gap? Details about this parameter on StackOverflow thread

Thanks in advance

tresf commented 2 months ago

@devaskim hi, I've read the linked StackOverflow article but I do not completely understand the requirement (e.g. 3.5 characters). I think the high-level answer is "no, it does not". Perhaps a better question, and one I would need a better understand of the question is if it can be modified to support this. Any help in understanding this requirement is appreciated.

devaskim commented 2 months ago

@tresf Thanks for quick answer. Maybe this will help in understanding (Modbus specs) Скриншот 13-08-2024 194700

tresf commented 2 months ago

@devaskim thanks however I'm still unsure what's being asked.

What I think is being asked is can JSSC read data in non-byte aligned ways. The answer here is "yes, and no".

If the expectation is for this to be handled internally in the API, the answer is "not yet". Since we're an open source application, any special handling routines can theoretically be added to the codebase by a contributor.

devaskim commented 2 months ago

What I think is being asked is can JSSC read data in non-byte aligned ways

No, it is a about time gap or time delay between sending consequent bytes (just look again on the "chart" above, there is time scale on horizontal axis).

JSSC is a about serial port, so each byte has been sent one by one, thus there is time gap between each two sending and it is called inter-character gap or inter-character timeout

tresf commented 2 months ago

I've studied the chart several times, but it describes much more than a character gap and it's not clear which portion of this protocol must live in JSSC (redundancy check, error handling) and which portions are the responsibility of the programmer. It also makes mention of varying delays at different baud levels. This is all to say that it's not this project's obligation to research and/or implement any particular feature, but we're receptive to contributions.

This is best handled as a pull request/feature. Other developers here may have more patience to study this protocol, but the fastest way to get a feature added it to this software is for one to add it themselves. We're just a bunch of volunteers here. We'd happily accept a pull request adding this feature.

devaskim commented 2 months ago

This is all to say that it's not this project's obligation to research and/or implement any particular feature

@tresf Seems like I hurt you, really sorry. Thanks for your time and patience.

I had explored the code of this library and didn't find something similar to that I asked, so before making any improvements or searching for another COMM/Modbus implementation in Java I decided to ask the community.

tresf commented 2 months ago

I had explored the code of this library and didn't find something similar to that I asked, so before making any improvements

I believe the question "how to set inter-character gap" is a bit misleading of a title, especially if research on the codebase was done prior to asking.

@tresf Seems like I hurt you, really sorry.

I do not feel that any damage was done, however the intent of "[author] making improvements" was never clear in the question. The project would welcome such an addition. I'm still unsure about what portions of the protocol are needed JSSC-side versus which portions are handled within the implementing code. If this is something that you can help explain (e.g. in a PR), this may be easier to discuss there as it's a very technical implementation.

I would assume that the modbus requirements are for both transmission and receiving data and I'm not sure how this would impact the codebase. If this is something you or someone else is interested in helping out with, we would be receptive to the change.

devaskim closed this as completed 3 hours ago

I believe the intent was to close this as "not planned", but the status incorrectly shows "completed". I've reopened the bug report so that it can be closed as "not planned' if that is the OP's wish, or left open if work is to begin on implementation.

devaskim commented 2 months ago

I believe the intent was to close this as "not planned", but the status incorrectly shows "completed". I've reopened the bug report so that it can be closed as "not planned' if that is the OP's wish, or left open if work is to begin on implementation.

The Github Issues is for questions, bug reporting and feature suggestions. This issue is a question type, the title and the description indicate unambiguously about that. I got the answer - no such feature, or even it is out of scope of this library. So the main goal of this issue is achieved, thus completed. Others words here are about "what, where and when", i.e. details.

I believe the question "how to set inter-character gap" is a bit misleading of a title, especially if research on the codebase was done prior to asking.

It is a normal practice of whole our life - to ask, i.e. re-check, if mine assumptions are true. And me, as issue reporter (note, issue, not bug) shouldn't explain the whole way I have done before creating issue, at least, if it isn't the rule of the project, as on StackOverflow.