k3ng / k3ng_cw_keyer

K3NG Arduino CW Keyer
http://blog.radioartisan.com/arduino-cw-keyer/
GNU General Public License v3.0
416 stars 216 forks source link

QRSS mode crash - Funtronics FK-11 hardware #125

Open Olivier-ADLER opened 2 years ago

Olivier-ADLER commented 2 years ago

Each time i try to switch to QRSS mode in CLI, i get a crash and reboot after the watchdog timer. If i disable the avr watchdog function, then the AVR crash and does not reboot.

This exhibit using the latest github version. Does not seem related to this particular version because the original firmware i had on the FK-11 board was a couple years younger and had the same crash problem when enabling QRSS.

Olivier-ADLER commented 2 years ago

After checking the code it seems that the serial_qrss_mode() function check only the primary serial port, but on this board there is a secondary serial port. So i think that the while loop of this function never end because it never receive serial input, and trigger the AVR watchdog.

There is two other problems : the reported dit lenght is wrong, forgetting an ascii string to decimal conversion, and after entering the \q command there is no more serial echo, so we do not see the entered value. I'm working on modified code. First compilation checks are confirming my first finds.

Olivier-ADLER commented 2 years ago

Here is a working dirty code modification (dirty because it does not take into account hardware serial ports definitions).

There is still a watchdog reset problem if return is not pressed 4 seconds after the \q command. I will leave that to someone that better master the code. Other problems have been corrected.

`void serial_qrss_mode() { byte looping = 1; byte incoming_serial_byte; byte numbers[4]; byte numberindex = 0; String numberstring; byte error =0;

while (looping) { if (secondary_serial_port->available() == 0) { // wait for the next keystroke if (keyer_machine_mode == KEYER_NORMAL) { // might as well do something while we're waiting check_paddles(); service_dit_dah_buffers(); //check_the_memory_buttons(); } } else {

  incoming_serial_byte = secondary_serial_port->read();
  secondary_serial_port->write(incoming_serial_byte);
  if ((incoming_serial_byte > 47) && (incoming_serial_byte < 58)) {    // ascii 48-57 = "0" - "9")
    numberstring = numberstring + incoming_serial_byte;
    numbers[numberindex] = incoming_serial_byte;

// primary_serial_port->write("numberindex:"); // primary_serial_port->print(numberindex,DEC); // primary_serial_port->write(" numbers:"); // primary_serial_port->println(numbers[numberindex],DEC); numberindex++; if (numberindex > 2) { looping = 0; error = 1; } } else { if (incoming_serial_byte == 13) { // carriage return - get out looping = 0; } else { // bogus input - error out looping = 0; error = 1; } } } }

if (error) { secondary_serial_port->println(F("Error...")); while (secondary_serial_port->available() > 0) { incoming_serial_byte = secondary_serial_port->read(); } // clear out buffer return; } else { if (speed_mode != SPEED_QRSS) { secondary_serial_port->print(F(" Setting keyer to QRSS Mode, Enter \R to leave. Dit length : ")); } else { secondary_serial_port->print(F(" Changing QRSS speed. Dit length : ")); } int y = 1; int set_dit_length = 0; for (int x = (numberindex - 1); x >= 0 ; x = x - 1) { set_dit_length = set_dit_length + ((numbers[x]-48) y); y = y 10; } if (set_dit_length == 0) { qrss_dit_length = initial_qrss_dit_length; } else { qrss_dit_length = set_dit_length; } speed_mode = SPEED_QRSS; secondary_serial_port->print(qrss_dit_length); secondary_serial_port->println(F(" seconds")); } }`