MCPcopy Create free account
hub / github.com/Hamlib/Hamlib / morse_data_handler

Function morse_data_handler

src/rig.c:8751–8892  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8749}
8750
8751static void *morse_data_handler(void *arg)
8752{
8753 struct morse_data_handler_args_s *args =
8754 (struct morse_data_handler_args_s *) arg;
8755 RIG *rig = args->rig;
8756 const struct rig_state *rs = STATE(rig);
8757 int result;
8758
8759 rig_debug(RIG_DEBUG_VERBOSE, "%s: Starting morse data handler thread\n",
8760 __func__);
8761
8762 if (STATE(rig)->fifo_morse == NULL)
8763 {
8764 // Can't use rs-> 'cuz it's const
8765 STATE(rig)->fifo_morse = calloc(1, sizeof(FIFO_RIG));
8766 }
8767
8768 initFIFO(rs->fifo_morse);
8769
8770 char *c;
8771 int qsize = rig->caps->morse_qsize; // if backend overrides qsize
8772
8773 if (qsize == 0) { qsize = 20; } // shortest length of any rig's CW morse capability
8774
8775 c = calloc(1, qsize + 1);
8776
8777 while (rs->morse_data_handler_thread_run || (hl_peek(rs->fifo_morse) >= 0))
8778 {
8779 int n = 0;
8780 memset(c, 0, qsize);
8781
8782 for (n = 0; n < qsize; n++)
8783 {
8784 int d = hl_peek(rs->fifo_morse);
8785
8786 if (d < 0)
8787 {
8788 break;
8789 }
8790
8791 d = hl_pop(rs->fifo_morse);
8792 c[n] = (char) d;
8793 }
8794
8795 if (n > 0)
8796 {
8797#if 0
8798// this does not work well at all -- rigs do not queue keyspd so any change is immediate
8799// don't know if we can ever implement this
8800 char *p;
8801 // if we have + or - we will adjust speed and send before/speed/after which hopefully works
8802 // I suspect some rigs will change speed immediately and not wait for queued character to flush
8803 morse_data_handler_priv_data *morse_data_handler_priv =
8804 (morse_data_handler_priv_data *) rs->morse_data_handler_priv_data;
8805 value_t keyspd;
8806 keyspd.i = morse_data_handler_priv->keyspd;
8807 rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): keyspd=%d\n", __func__, __LINE__,
8808 keyspd.i);

Callers

nothing calls this directly

Calls 10

rig_debugFunction · 0.85
initFIFOFunction · 0.85
hl_peekFunction · 0.85
hl_popFunction · 0.85
rig_set_levelFunction · 0.85
rig_lockFunction · 0.85
rigerrorFunction · 0.85
resetFIFOFunction · 0.85
hl_usleepFunction · 0.85
pthread_exitFunction · 0.85

Tested by

no test coverage detected