// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: send_user_cmd(char*)
void send_user_cmd(char *s)
{
unsigned i;
int val;
int p;
char *u;
int show_user_cmd;

   // send a user specified (ASCII) command to a receiver
   if(s == 0) return;
   // NEW_RCVR
   ++user_msg_num;

   debug_text2[0] = 0;
   show_user_cmd = 0;
   u = "user";

   strcpy(last_user_cmd, s);
   if(rcvr_type == ACRON_RCVR) {
      send_acron_cmd(s);
      show_user_cmd = 2;
   }
   else if(rcvr_type == BRANDY_RCVR) {
      if(s[0] == '$') queue_brandy_cmd(&s[0], SCPI_USER_MSG);
      else            queue_brandy_cmd(&s[0], SCPI_USER_MSG); 
      show_user_cmd = 1;
   }
   else if(rcvr_type == CS_RCVR) {
      queue_cs_cmd(s, SCPI_USER_MSG);
      show_user_cmd = 1;
   }
   else if(rcvr_type == ESIP_RCVR) {
      send_esip_cmd(s);
      show_user_cmd = 2;
   }
   else if(rcvr_type == FURUNO_RCVR) {
      send_furuno_cmd(s);
      show_user_cmd = 2;
   }
   else if(rcvr_type == GPSD_RCVR) { // send ascii string
      send_nmea_string(s, 0);
      eom_flag = EOM;
      send_byte(0x0A);
      eom_flag = ADD_CHAR;
      show_user_cmd = 2;
   }
   else if(rcvr_type == LPFRS_RCVR) {
      queue_sro_cmd(s, SCPI_USER_MSG);
      show_user_cmd = 1;
   }
   else if(rcvr_type == NMEA_RCVR) {
      if(s[0] == '$') send_nmea_cmd(&s[1]);
      else            send_nmea_cmd(&s[0]);
      show_user_cmd = 2;
   }
   else if(rcvr_type == PRS_RCVR) {
      if(strchr(s, '?'))       queue_prs_cmd(s, SCPI_USER_MSG);
      else if(prs_vb == 0)     queue_prs_cmd(s, -SCPI_USER_MSG);  // commands have no response
      else if(strstr(s, "LM")) queue_prs_cmd(s, -SCPI_USER_MSG);
      else if(strstr(s, "lm")) queue_prs_cmd(s, -SCPI_USER_MSG);
      else if(strstr(s, "LO")) queue_prs_cmd(s, -SCPI_USER_MSG);
      else if(strstr(s, "lo")) queue_prs_cmd(s, -SCPI_USER_MSG);
      else                     queue_prs_cmd(s, SCPI_USER_MSG);
      show_user_cmd = 1;
   }
   else if(rcvr_type == SA35_RCVR) {
      queue_sa35_cmd(s, SCPI_USER_MSG);
      show_user_cmd = 1;
   }
   else if(rcvr_type == SCPI_RCVR) {
      queue_scpi_cmd(s, SCPI_USER_MSG);
      show_user_cmd = 1;
   }
   else if(rcvr_type == SRO_RCVR) {
      queue_sro_cmd(s, SCPI_USER_MSG);
      show_user_cmd = 1;
   }
   else if(rcvr_type == STAR_RCVR) {
      queue_star_cmd(s, SCPI_USER_MSG);
      show_user_cmd = 1;
   }
   else if(rcvr_type == THERMO_RCVR) { // send ascii string
      send_nmea_string(s, 0);
      eom_flag = EOM;
      send_byte(0x0D);
      eom_flag = ADD_CHAR;
      show_user_cmd = 2;
   }
   else if(rcvr_type == TM4_RCVR) {
      send_tm4_cmd(s);
      show_user_cmd = 2;
   }
   else if(rcvr_type == TRUE_RCVR) {
      send_true_cmd(s);   // send a user specified message
      show_user_cmd = 2;
   }
   else if(rcvr_type == TSERVE_RCVR) {
      send_nmea_string(s, 0);
      send_byte(0x0D);
      eom_flag = EOM;
      send_byte(0x0A);
      eom_flag = ADD_CHAR;
      show_user_cmd = 2;
   }
   else if(rcvr_type == UCCM_RCVR) {
      queue_uccm_cmd(s, SCPI_USER_MSG);
      show_user_cmd = 1;
   }
   else if(rcvr_type == X72_RCVR) {
      queue_x72_cmd(s, SCPI_USER_MSG);
      show_user_cmd = 2;
   }
   else if(rcvr_type == Z12_RCVR) {
      if(s[0] == '$') send_z12_cmd(&s[1]);
      else            send_z12_cmd(&s[0]);
      show_user_cmd = 2;
   }
   else if(rcvr_type == ZYFER_RCVR) {
      if(s[0] == '$') send_nmea_cmd(&s[1]);
      else            send_nmea_cmd(&s[0]);
      show_user_cmd = 2;
   }
   else if(ASCII_RCVR) { // send ascii string
      send_ascii_string(s, 1);
      show_user_cmd = 2;
   }
   else if(1) {  // send hex string
      strupr(s);
      p = 0;
      val = 0;
      for(i=0; i<strlen(s); i++) {
         if((s[i] >= '0') && (s[i] <= '9')) {
            val = (val*16) + (s[i] - '0');
            p = 1;
         }
         else if((s[i] >= 'A') && (s[i] <= 'F')) {
            val = (val*16) + (s[i] - 'A' + 10);
            p = 1;
         }
         else if(p) {
            eom_flag = EOM;
            send_byte(val & 0xFF);
            eom_flag = ADD_CHAR;
            val = 0;
            p = 0;
         }
      }
      if(p) {
         eom_flag = EOM;
         send_byte(val & 0xFF);
         eom_flag = ADD_CHAR;
         val = 0;
         p = 0;
      }
      show_user_cmd = 3;
      u = "user hex";
   }

   if(show_user_cmd) {
      sprintf(debug_text3, "sent %s cmd %d:%s", u, user_msg_num, s);
      if(debug_file) fprintf(debug_file, "sent %s cmd %d:%s\n", u, user_msg_num, s);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x57532
movq %rdi, %rbx
incl 0x2feb59(%rip)          # 0x355e14
leaq 0x2d182e(%rip), %rax    # 0x328af0
movb $0x0, (%rax)
leaq 0x2d2214(%rip), %rdi    # 0x3294e0
movq %rbx, %rsi
callq 0x9330
leaq 0x1ab5f5(%rip), %rax    # 0x2028d0
movq (%rax), %rax
cmpq $0x2, %rax
je 0x573e8
cmpq $0x8, %rax
je 0x574c8
cmpq $0x10, %rax
je 0x574c8
cmpq $0x200, %rax            # imm = 0x200
je 0x5748f
cmpq $0x1000, %rax           # imm = 0x1000
je 0x574c8
movabsq $0x1000000000, %rcx     # imm = 0x1000000000
cmpq %rcx, %rax
je 0x574c8
cmpq $0x20000, %rax          # imm = 0x20000
je 0x574c8
cmpq $0x40000, %rax          # imm = 0x40000
je 0x574c8
cmpq $0x80000, %rax          # imm = 0x80000
je 0x5746d
cmpq $0x100000, %rax         # imm = 0x100000
je 0x573e8
cmpq $0x200000, %rax         # imm = 0x200000
je 0x573f3
cmpq $0x1000000, %rax        # imm = 0x1000000
je 0x574b4
cmpq $0x2000000, %rax        # imm = 0x2000000
je 0x574c8
cmpq $0x8000000, %rax        # imm = 0x8000000
je 0x574c8
cmpq $0x10000000, %rax       # imm = 0x10000000
je 0x574c8
cmpq $0x20000000, %rax       # imm = 0x20000000
je 0x57485
cmpq $0x40000000, %rax       # imm = 0x40000000
je 0x57459
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
je 0x57400
movabsq $0x100000000, %rcx      # imm = 0x100000000
cmpq %rcx, %rax
je 0x57427
movabsq $0x400000000, %rcx      # imm = 0x400000000
cmpq %rcx, %rax
je 0x5740d
cmpq $0x4000, %rax           # imm = 0x4000
jne 0x57439
movq %rbx, %rdi
callq 0x57665
jmp 0x574d3
cmpb $0x24, (%rbx)
jne 0x5741a
leaq 0x1(%rbx), %rdi
jmp 0x5741d
movq %rbx, %rdi
callq 0x57acc
jmp 0x574d3
movq %rbx, %rdi
callq 0x57791
jmp 0x574d3
movq %rbx, %rdi
callq 0x57a21
jmp 0x574d3
movq %rbx, %rdi
callq 0x579af
jmp 0x574d3
cmpb $0x24, (%rbx)
jne 0x57541
leaq 0x1(%rbx), %rdi
jmp 0x57544
movabsq $0x5fb3f521a, %rcx      # imm = 0x5FB3F521A
testq %rcx, %rax
je 0x5754b
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x5720b
jmp 0x574d3
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5724b
pushq $0xd
popq %rdi
callq 0x523f2
jmp 0x57499
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5724b
movl $0x1, 0x2fe98f(%rip)    # 0x355e10
pushq $0xd
jmp 0x574a5
movq %rbx, %rdi
callq 0x578d5
jmp 0x574d3
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5724b
movl $0x1, 0x2fe96d(%rip)    # 0x355e10
pushq $0xa
popq %rdi
callq 0x523f2
andl $0x0, 0x2fe95e(%rip)    # 0x355e10
jmp 0x574d3
pushq $0x3f
popq %rsi
movq %rbx, %rdi
callq 0x9100
testq %rax, %rax
je 0x575fe
pushq $0x25
popq %rsi
movq %rbx, %rdi
callq 0x576d4
leaq 0xb2ee0(%rip), %r14     # 0x10a3ba
movl 0x2fe934(%rip), %ecx    # 0x355e14
leaq 0x2d1759(%rip), %rdi    # 0x328c40
leaq 0xb2edd(%rip), %rsi     # 0x10a3cb
movq %r14, %rdx
movq %rbx, %r8
xorl %eax, %eax
callq 0x9060
leaq 0x1d0e8e(%rip), %rax    # 0x228390
movq (%rax), %rdi
testq %rdi, %rdi
je 0x57532
movl 0x2fe904(%rip), %ecx    # 0x355e14
leaq 0xb2ec6(%rip), %rsi     # 0x10a3dd
movq %r14, %rdx
movq %rbx, %r8
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9560
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x57b55
jmp 0x574d3
movq %rbx, %rdi
callq 0x988f
xorl %r14d, %r14d
pushq $0x1
popq %r12
xorl %r15d, %r15d
xorl %r13d, %r13d
movl %r14d, %r14d
movq %rbx, %rdi
callq 0x9120
cmpq %r14, %rax
jbe 0x575cf
movzbl (%rbx,%r14), %eax
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0x57589
shll $0x4, %r15d
movzbl %cl, %eax
orl %eax, %r15d
jmp 0x5759c
leal -0x41(%rax), %ecx
cmpb $0x5, %cl
ja 0x575a7
shll $0x4, %r15d
addl %eax, %r15d
addl $-0x37, %r15d
movl %r12d, %eax
incl %r14d
movl %eax, %r13d
jmp 0x57560
xorl %eax, %eax
testl %r13d, %r13d
je 0x5759f
movl $0x1, 0x2fe858(%rip)    # 0x355e10
movzbl %r15b, %edi
callq 0x523f2
andl $0x0, 0x2fe848(%rip)    # 0x355e10
xorl %r15d, %r15d
xorl %eax, %eax
jmp 0x5759f
leaq 0xb2dec(%rip), %r14     # 0x10a3c2
testl %r13d, %r13d
je 0x574da
movl $0x1, 0x2fe827(%rip)    # 0x355e10
movzbl %r15b, %edi
callq 0x523f2
andl $0x0, 0x2fe817(%rip)    # 0x355e10
jmp 0x574da
leaq 0x1ad4e7(%rip), %rax    # 0x204aec
cmpl $0x0, (%rax)
je 0x5765e
leaq 0xb5b35(%rip), %rsi     # 0x10d146
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
jne 0x5765e
leaq 0xb5ad8(%rip), %rsi     # 0x10d0fd
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
jne 0x5765e
leaq 0xb67a6(%rip), %rsi     # 0x10dddf
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
jne 0x5765e
leaq 0xb2d72(%rip), %rsi     # 0x10a3bf
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
je 0x574c8
pushq $-0x25
jmp 0x574ca