iceman1001 / ChameleonMini-rebootedGUI

Windows based GUI for Chameleon Mini, the contactless smartcard emulator (NFC/RFID)
GNU General Public License v3.0
290 stars 72 forks source link

Sendcommand timeoutfix #113

Closed securechicken closed 4 years ago

securechicken commented 4 years ago

Chasing #111 slowness sources, I discovered that I used a SendCommand instead of SendCommandWithoutResult to set UID in GUI with "Apply". This introduced many delay, because the "SendCommand" used to get its result data in an possible infinite loop: SendCommand looped on serial ReadLine while received string was empty, but was also emptying strings from all return codes from FW. As so, using "SendCommand" with a command that just returned a standard code looped indefinitely, until a manually set timeout triggered. Removing this bad timeout trick, that was by the way overloading the original "timeout" settings from the SerialPort, I also discovered the SendCommandWithoutResult was not catching standard return codes (because most if not all command have at least a return code as a result...), which were then popping on read serial buffers from time to time, making the SendCommand logic deal with data from nowhere. Fixed.

That main point, plus some "active slot restore" and UID read factoring, make the GUI dialogue with Chameleon more responsive.

iceman1001 commented 4 years ago

Valiant effort to fight off the delays.

securechicken commented 4 years ago

@iceman1001 thanks but I forgot to set proper Serial timeouts back to long enough to deal with long commands while ticking "VERSION" is knocking every 2s. I'll fix...

iceman1001 commented 4 years ago

Small PR's is good. Changing one thing at a time.