Closed tinitus91 closed 2 years ago
In your serialEvent()
callback, you are testing for a flow control flag and not the LISTENING_EVENT_CTS
flag. Change your test to event.getEventType() == SerialPort.LISTENING_EVENT_CTS
(or just remove the test altogether since you're only listening for a single event type), and you should be good to go.
Thanks for return yes it was an old try I corrected it. Did you execute this code ? the problem is Eclipse cannot resolve "SerialPort.LISTENING_EVENT_CTS" Only those 3 : data available, data received , data written are accessible like if others listening methods don't exist. is there a special release to use to have it all ?
No special release. If those are the only three listening event options available to you, then somehow your setup/configuration in Eclipse is using an older jSerialComm release from before this functionality was added (I believe it was added in 2.8.0).
ok thank you I had two versions in the buildpath. Now I can trigger cts events but using RTS output through a switch it mainly detects "ON" transition vs OFF ratio is 90% vs 10% !
I can't really speak to the low-level behavior of the CTS events you're seeing as that's very hardware-, software-, and setup-dependent, but from a very high level, if you're already in the event handler for a CTS event and the CTS line status changes while you're still handling the previous state change, you won't receive another notification (in other words, the event callback is not reentrant).
My guess would be that you are getting an event when the CTS line goes low, but by the time you check its status, it has already been pulled high again. One of the big problems with using Java for very low-level bit-banging in serial programming is that the required interface going back and forth between Java and native code is quite slow (relatively speaking to the speed of the transmissions). Unfortunately, there's not really much that can be done on that front from this library. The callbacks you are seeing and their timings are coming directly from the OS and underlying device driver.
I understand but switch period is very large , about 2 seconds. I also tried with jssc library and even if there is lacks during transient period ( switch boucing) ratio approach 50/50 for ON and OFF and I never miss the first Off edge of a serie ( considering each Off , on, off, on ...) as a serie.
Are you using Windows? If so, I think I see the problem.
Yes I'm using Windows 10
Gotcha - when I get a second, I'll make a fix and get to you for testing.
Sure with pleasure !
Hello, do you think it could be possible to apply this modifications within the current month ? Thank you
Sorry for the delay. Please test the following updated version and see if it corrects your issue:
https://www.dropbox.com/t/qQJEhdFDRfEsnI8z
If so, I will check in the fix and include it in the next release (coming out shortly).
thanks, i'll let you know you as soon as possible.
Any update on whether your issue was resolved? I'd like to include it in the next release if so. An updated test version is here:
Hello, After testing jSerialComm-2.9.2-beta5, behaviour seems to be good. Could you say in few word what was the problem ?
Glad to hear! The problem was that the library was only sending a CTS notification event when the line went high instead of on any change.
This fix was included in today's jSerialComm v2.9.2 release. Thanks!
Especially thanks to you ! This will allow me to continue to use this same library and same project classes without any modification with all serial events in my application !
I would like to detect CTS events but I don't succeed in implementing the code : Here is what I wrote for now but the "LISTENING_EVENT_CTS" mentionned in the documentation seems not to be reachable.
What am I doing wrong ?
Thank you