Closed rusefillc closed 2 years ago
Ah, I assume you're seeing this after trying to stop your application without first closing the serial ports? That's a bug, although a relatively harmless one. I will make sure the event listeners do not fire if the application is in a state of shutting down. (And luckily, this is one I can reproduce and test myself!)
Oh, and the updated library I just posted in your other thread also has the fix for this issue included. So please test that update (https://www.dropbox.com/t/75SarQc7JO5C92Wm) for this issue.
test failed I guess?
on the one side LISTENING_EVENT_PORT_DISCONNECTED did not happen on application close on that above mentioned custom .jar on application close
on the other side LISTENING_EVENT_PORT_DISCONNECTED did not happen on cable removal from USB port with following loggin
E 220216 150330.878 [communication executor1] BinaryProtocol - output channels: executeCommand failed: java.io.IOException: write failed: wrote 0 but expected 11
writeFooter logs/rusEFI_trigger_log_2022-02-16_15_03_24_337.logicdata
I 220216 150330.884 [communication executor1] SerialIoStream - COM33: Closing port...
[COM?]: In closePortNative()
[\\.\COM33]: Purging all active port operations
[\\.\COM33]: Closing port
[\\.\COM33]: Entering closePortNative critical section #1
[\\.\COM33]: Leaving closePortNative critical section #1
I 220216 150330.885 [communication executor1] SerialIoStream - COM33: Closed port.
I 220216 150330.917 [text pull1] BinaryProtocol - Stopping text pull
I 220216 150335.779 [communication executor1] ConsoleUI - ConnectionWatchdog.reconnectTimer restarting: 5000
Hmmm...I think this is okay. It looks like your code is detecting a problem based on an incorrect number of bytes written and then closing the port before the port has a chance to fire the disconnected event. The way it's set up now, the event won't fire if the port was already successfully closed.
Do you think it makes more sense to have the disconnected event fire even if your code has already handled the closing of the port? That's an easy change to make, but I'm not sure if it makes the most sense to have a closed port fire an event.
I do not have an opinion I have to trust your judgement on that. I can also poke @mck1117 :)
I think I'm going to leave it as-is for now for correctness sake, but if it becomes something that people need in the future, I'll revisit it at that time. For now, I have created a beta2 version of the library that I'm going to stress test before making a new release. Feel free to test as well if you'd like:
Closing this as resolved with today's release v2.9.1.
We've added
and now when I attempt to stop my application I get a few hundreds of these callbacks. just wanted to check if that's a feature or a bug