// File: /workspace/github_cpp_makefile_star2_O1/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 0x5ecf6
movq %rdi, %rbx
incl 0x30d475(%rip)          # 0x36be14
leaq 0x2e014a(%rip), %rax    # 0x33eaf0
movb $0x0, (%rax)
leaq 0x2e0b30(%rip), %rdi    # 0x33f4e0
movq %rbx, %rsi
callq 0x9340
leaq 0x1b9f11(%rip), %rax    # 0x2188d0
movq (%rax), %rax
cmpq $0x1fffff, %rax         # imm = 0x1FFFFF
jle 0x5ea13
cmpq $0x1fffffff, %rax       # imm = 0x1FFFFFFF
jle 0x5ea4c
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
jg 0x5eab6
cmpq $0x20000000, %rax       # imm = 0x20000000
je 0x5ebea
cmpq $0x40000000, %rax       # imm = 0x40000000
je 0x5ec47
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
jne 0x5eb94
movq %rbx, %rdi
callq 0x5ef13
jmp 0x5ec97
cmpq $0x3fff, %rax           # imm = 0x3FFF
jg 0x5ea81
cmpq $0xf, %rax
jle 0x5eb88
cmpq $0x10, %rax
je 0x5ebcd
cmpq $0x200, %rax            # imm = 0x200
je 0x5ec20
cmpq $0x1000, %rax           # imm = 0x1000
je 0x5ebcd
jmp 0x5eb94
cmpq $0x1ffffff, %rax        # imm = 0x1FFFFFF
jle 0x5eaf4
cmpq $0x2000000, %rax        # imm = 0x2000000
je 0x5ebcd
cmpq $0x8000000, %rax        # imm = 0x8000000
je 0x5ebcd
cmpq $0x10000000, %rax       # imm = 0x10000000
je 0x5ebcd
jmp 0x5eb94
cmpq $0x3ffff, %rax          # imm = 0x3FFFF
jle 0x5ebb9
cmpq $0x40000, %rax          # imm = 0x40000
je 0x5ebcd
cmpq $0x80000, %rax          # imm = 0x80000
je 0x5ec2c
cmpq $0x100000, %rax         # imm = 0x100000
je 0x5ebdf
jmp 0x5eb94
movabsq $0x100000000, %rcx      # imm = 0x100000000
cmpq %rcx, %rax
je 0x5ebf7
movabsq $0x400000000, %rcx      # imm = 0x400000000
cmpq %rcx, %rax
je 0x5ec7b
movabsq $0x1000000000, %rcx     # imm = 0x1000000000
cmpq %rcx, %rax
je 0x5ebcd
jmp 0x5eb94
cmpq $0x200000, %rax         # imm = 0x200000
je 0x5ec09
cmpq $0x1000000, %rax        # imm = 0x1000000
jne 0x5eb94
movq %rbx, %rdi
movl $0x3f, %esi
callq 0x9100
testq %rax, %rax
jne 0x5ebcd
leaq 0x1bbfc3(%rip), %rax    # 0x21aaec
cmpl $0x0, (%rax)
je 0x5eb7e
leaq 0xc45e9(%rip), %rsi     # 0x12311e
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
jne 0x5eb7e
leaq 0xc458c(%rip), %rsi     # 0x1230d5
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
jne 0x5eb7e
leaq 0xc525a(%rip), %rsi     # 0x123db7
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
jne 0x5eb7e
leaq 0xc1826(%rip), %rsi     # 0x120397
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
je 0x5ebcd
movq %rbx, %rdi
movl $0xffffffdb, %esi       # imm = 0xFFFFFFDB
jmp 0x5ebd5
cmpq $0x2, %rax
je 0x5ebdf
cmpq $0x8, %rax
je 0x5ebcd
movabsq $0x5fb3f521a, %rcx      # imm = 0x5FB3F521A
movq %rbx, %rdi
testq %rcx, %rax
je 0x5ed05
movl $0x1, %esi
callq 0x5e8e3
jmp 0x5ec97
cmpq $0x4000, %rax           # imm = 0x4000
je 0x5ec85
cmpq $0x20000, %rax          # imm = 0x20000
jne 0x5eb94
movq %rbx, %rdi
movl $0x25, %esi
callq 0x5ee52
jmp 0x5ec97
cmpb $0x24, (%rbx)
jne 0x5ec16
leaq 0x1(%rbx), %rdi
jmp 0x5ec19
movq %rbx, %rdi
callq 0x5f070
jmp 0x5ec97
cmpb $0x24, (%rbx)
jne 0x5ec8f
leaq 0x1(%rbx), %rdi
jmp 0x5ec92
movq %rbx, %rdi
callq 0x5f2a0
jmp 0x5ec97
movq %rbx, %rdi
callq 0x5f15d
jmp 0x5ec97
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5e92a
jmp 0x5ec5b
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5e92a
movl $0x1, 0x30d1d0(%rip)    # 0x36be10
movl $0xd, %edi
jmp 0x5ec6a
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5e92a
movl $0xd, %edi
callq 0x591af
movl $0x1, 0x30d1ab(%rip)    # 0x36be10
movl $0xa, %edi
callq 0x591af
movl $0x0, 0x30d197(%rip)    # 0x36be10
jmp 0x5ec97
movq %rbx, %rdi
callq 0x5f1e8
jmp 0x5ec97
movq %rbx, %rdi
callq 0x5ede4
jmp 0x5ec97
movq %rbx, %rdi
callq 0x5f340
leaq 0xc16f4(%rip), %r14     # 0x120392
movl 0x30d170(%rip), %ecx    # 0x36be14
leaq 0x2dff95(%rip), %rdi    # 0x33ec40
leaq 0xc16f1(%rip), %rsi     # 0x1203a3
movq %r14, %rdx
movq %rbx, %r8
xorl %eax, %eax
callq 0x9060
leaq 0x1df6ca(%rip), %rax    # 0x23e390
movq (%rax), %rdi
testq %rdi, %rdi
je 0x5ecf6
movl 0x30d140(%rip), %ecx    # 0x36be14
leaq 0xc16da(%rip), %rsi     # 0x1203b5
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
callq 0x9899
xorl %ecx, %ecx
cmpb $0x0, (%rbx)
je 0x5edb2
movl $0x1, %r14d
xorl %r12d, %r12d
xorl %r15d, %r15d
movzbl (%rbx,%r12), %eax
leal -0x30(%rax), %edx
cmpb $0x9, %dl
ja 0x5ed3c
shll $0x4, %r15d
addb $-0x30, %al
movzbl %al, %eax
orl %eax, %r15d
jmp 0x5ed4f
leal -0x41(%rax), %edx
cmpb $0x5, %dl
ja 0x5ed74
shll $0x4, %r15d
addl %eax, %r15d
addl $-0x37, %r15d
movl $0x1, %r13d
movl $0x0, -0x2c(%rbp)
movl %r14d, %r12d
movq %rbx, %rdi
callq 0x9120
incl %r14d
movl %r13d, %ecx
cmpq %r12, %rax
ja 0x5ed21
jmp 0x5edaa
xorl %r13d, %r13d
movb $0x1, %al
testl %ecx, %ecx
jne 0x5ed82
movl %eax, -0x2c(%rbp)
jmp 0x5ed5c
movl %eax, -0x2c(%rbp)
movl $0x1, 0x30d081(%rip)    # 0x36be10
movzbl %r15b, %edi
callq 0x591af
movl $0x0, 0x30d06e(%rip)    # 0x36be10
xorl %r15d, %r15d
xorl %r13d, %r13d
jmp 0x5ed5c
movl %r15d, %ecx
movl -0x2c(%rbp), %eax
jmp 0x5edb4
movb $0x1, %al
leaq 0xc15df(%rip), %r14     # 0x12039a
testb %al, %al
jne 0x5ec9e
movl $0x1, 0x30d043(%rip)    # 0x36be10
movzbl %cl, %edi
callq 0x591af
movl $0x0, 0x30d031(%rip)    # 0x36be10
jmp 0x5ec9e