// File: 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
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x827d8
jmp 0x82f38
movl 0x348816(%rip), %eax    # 0x3caff4
addl $0x1, %eax
movl %eax, 0x34880d(%rip)    # 0x3caff4
leaq 0x31b4e2(%rip), %rax    # 0x39dcd0
movb $0x0, (%rax)
movl $0x0, -0x24(%rbp)
leaq 0x100ef3(%rip), %rax    # 0x1836f2
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rsi
leaq 0x31beb2(%rip), %rdi    # 0x39e6c0
callq 0x9350
leaq 0x1f5296(%rip), %rax    # 0x277ab0
cmpq $0x4000, (%rax)         # imm = 0x4000
jne 0x82838
movq -0x8(%rbp), %rdi
callq 0x82f40
movl $0x2, -0x24(%rbp)
jmp 0x82eda
leaq 0x1f5271(%rip), %rax    # 0x277ab0
cmpq $0x40000, (%rax)        # imm = 0x40000
jne 0x8287e
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x24, %eax
jne 0x82864
movq -0x8(%rbp), %rdi
movl $0x25, %esi
callq 0x82fd0
jmp 0x82872
movq -0x8(%rbp), %rdi
movl $0x25, %esi
callq 0x82fd0
movl $0x1, -0x24(%rbp)
jmp 0x82ed8
leaq 0x1f522b(%rip), %rax    # 0x277ab0
cmpq $0x20000, (%rax)        # imm = 0x20000
jne 0x828a8
movq -0x8(%rbp), %rdi
movl $0x25, %esi
callq 0x82fd0
movl $0x1, -0x24(%rbp)
jmp 0x82ed6
movl $0x80000000, %ecx       # imm = 0x80000000
leaq 0x1f51fc(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0x828ce
movq -0x8(%rbp), %rdi
callq 0x830d0
movl $0x2, -0x24(%rbp)
jmp 0x82ed4
leaq 0x1f51db(%rip), %rax    # 0x277ab0
cmpq $0x20000000, (%rax)     # imm = 0x20000000
jne 0x828f3
movq -0x8(%rbp), %rdi
callq 0x83270
movl $0x2, -0x24(%rbp)
jmp 0x82ed2
leaq 0x1f51b6(%rip), %rax    # 0x277ab0
cmpq $0x200, (%rax)          # imm = 0x200
jne 0x82938
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x82750
movl $0x1, 0x3486d8(%rip)    # 0x3caff0
movl $0xa, %edi
callq 0x7b210
movl $0x0, 0x3486c4(%rip)    # 0x3caff0
movl $0x2, -0x24(%rbp)
jmp 0x82ed0
leaq 0x1f5171(%rip), %rax    # 0x277ab0
cmpq $0x10000000, (%rax)     # imm = 0x10000000
jne 0x82962
movq -0x8(%rbp), %rdi
movl $0x25, %esi
callq 0x82fd0
movl $0x1, -0x24(%rbp)
jmp 0x82ece
leaq 0x1f5147(%rip), %rax    # 0x277ab0
cmpq $0x2, (%rax)
jne 0x8299f
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x24, %eax
jne 0x8298a
movq -0x8(%rbp), %rdi
addq $0x1, %rdi
callq 0x833e0
jmp 0x82993
movq -0x8(%rbp), %rdi
callq 0x833e0
movl $0x2, -0x24(%rbp)
jmp 0x82ecc
leaq 0x1f510a(%rip), %rax    # 0x277ab0
cmpq $0x1000000, (%rax)      # imm = 0x1000000
jne 0x82ab8
movq -0x8(%rbp), %rdi
movl $0x3f, %esi
callq 0x9100
cmpq $0x0, %rax
je 0x829da
movq -0x8(%rbp), %rdi
movl $0x25, %esi
callq 0x82fd0
jmp 0x82aac
leaq 0x1f72eb(%rip), %rax    # 0x279ccc
cmpl $0x0, (%rax)
jne 0x829f9
movq -0x8(%rbp), %rdi
movl $0xffffffdb, %esi       # imm = 0xFFFFFFDB
callq 0x82fd0
jmp 0x82aaa
movq -0x8(%rbp), %rdi
leaq 0x103aa1(%rip), %rsi    # 0x1864a5
callq 0x9090
cmpq $0x0, %rax
je 0x82a22
movq -0x8(%rbp), %rdi
movl $0xffffffdb, %esi       # imm = 0xFFFFFFDB
callq 0x82fd0
jmp 0x82aa8
movq -0x8(%rbp), %rdi
leaq 0x103a2f(%rip), %rsi    # 0x18645c
callq 0x9090
cmpq $0x0, %rax
je 0x82a48
movq -0x8(%rbp), %rdi
movl $0xffffffdb, %esi       # imm = 0xFFFFFFDB
callq 0x82fd0
jmp 0x82aa6
movq -0x8(%rbp), %rdi
leaq 0x104731(%rip), %rsi    # 0x187184
callq 0x9090
cmpq $0x0, %rax
je 0x82a6e
movq -0x8(%rbp), %rdi
movl $0xffffffdb, %esi       # imm = 0xFFFFFFDB
callq 0x82fd0
jmp 0x82aa4
movq -0x8(%rbp), %rdi
leaq 0x100c7e(%rip), %rsi    # 0x1836f7
callq 0x9090
cmpq $0x0, %rax
je 0x82a94
movq -0x8(%rbp), %rdi
movl $0xffffffdb, %esi       # imm = 0xFFFFFFDB
callq 0x82fd0
jmp 0x82aa2
movq -0x8(%rbp), %rdi
movl $0x25, %esi
callq 0x82fd0
jmp 0x82aa4
jmp 0x82aa6
jmp 0x82aa8
jmp 0x82aaa
jmp 0x82aac
movl $0x1, -0x24(%rbp)
jmp 0x82eca
movabsq $0x1000000000, %rcx     # imm = 0x1000000000
leaq 0x1f4fe7(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0x82ae8
movq -0x8(%rbp), %rdi
movl $0x25, %esi
callq 0x82fd0
movl $0x1, -0x24(%rbp)
jmp 0x82ec8
leaq 0x1f4fc1(%rip), %rax    # 0x277ab0
cmpq $0x10, (%rax)
jne 0x82b0f
movq -0x8(%rbp), %rdi
movl $0x25, %esi
callq 0x82fd0
movl $0x1, -0x24(%rbp)
jmp 0x82ec6
leaq 0x1f4f9a(%rip), %rax    # 0x277ab0
cmpq $0x8000000, (%rax)      # imm = 0x8000000
jne 0x82b39
movq -0x8(%rbp), %rdi
movl $0x25, %esi
callq 0x82fd0
movl $0x1, -0x24(%rbp)
jmp 0x82ec4
leaq 0x1f4f70(%rip), %rax    # 0x277ab0
cmpq $0x1000, (%rax)         # imm = 0x1000
jne 0x82b63
movq -0x8(%rbp), %rdi
movl $0x25, %esi
callq 0x82fd0
movl $0x1, -0x24(%rbp)
jmp 0x82ec2
leaq 0x1f4f46(%rip), %rax    # 0x277ab0
cmpq $0x80000, (%rax)        # imm = 0x80000
jne 0x82ba8
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x82750
movl $0x1, 0x348468(%rip)    # 0x3caff0
movl $0xd, %edi
callq 0x7b210
movl $0x0, 0x348454(%rip)    # 0x3caff0
movl $0x2, -0x24(%rbp)
jmp 0x82ec0
movabsq $0x400000000, %rcx      # imm = 0x400000000
leaq 0x1f4ef7(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0x82bd3
movq -0x8(%rbp), %rdi
callq 0x83490
movl $0x2, -0x24(%rbp)
jmp 0x82ebe
leaq 0x1f4ed6(%rip), %rax    # 0x277ab0
cmpq $0x200000, (%rax)       # imm = 0x200000
jne 0x82bf8
movq -0x8(%rbp), %rdi
callq 0x83580
movl $0x2, -0x24(%rbp)
jmp 0x82ebc
leaq 0x1f4eb1(%rip), %rax    # 0x277ab0
cmpq $0x40000000, (%rax)     # imm = 0x40000000
jne 0x82c47
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x82750
movl $0xd, %edi
callq 0x7b210
movl $0x1, 0x3483c9(%rip)    # 0x3caff0
movl $0xa, %edi
callq 0x7b210
movl $0x0, 0x3483b5(%rip)    # 0x3caff0
movl $0x2, -0x24(%rbp)
jmp 0x82eba
leaq 0x1f4e62(%rip), %rax    # 0x277ab0
cmpq $0x8, (%rax)
jne 0x82c6e
movq -0x8(%rbp), %rdi
movl $0x25, %esi
callq 0x82fd0
movl $0x1, -0x24(%rbp)
jmp 0x82eb8
leaq 0x1f4e3b(%rip), %rax    # 0x277ab0
cmpq $0x2000000, (%rax)      # imm = 0x2000000
jne 0x82c98
movq -0x8(%rbp), %rdi
movl $0x25, %esi
callq 0x82fd0
movl $0x2, -0x24(%rbp)
jmp 0x82eb6
movabsq $0x100000000, %rcx      # imm = 0x100000000
leaq 0x1f4e07(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0x82cde
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x24, %eax
jne 0x82cc9
movq -0x8(%rbp), %rdi
addq $0x1, %rdi
callq 0x83630
jmp 0x82cd2
movq -0x8(%rbp), %rdi
callq 0x83630
movl $0x2, -0x24(%rbp)
jmp 0x82eb4
leaq 0x1f4dcb(%rip), %rax    # 0x277ab0
cmpq $0x100000, (%rax)       # imm = 0x100000
jne 0x82d1e
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x24, %eax
jne 0x82d09
movq -0x8(%rbp), %rdi
addq $0x1, %rdi
callq 0x833e0
jmp 0x82d12
movq -0x8(%rbp), %rdi
callq 0x833e0
movl $0x2, -0x24(%rbp)
jmp 0x82eb2
leaq 0x1f4d8b(%rip), %rcx    # 0x277ab0
movabsq $0x5fb3f521a, %rax      # imm = 0x5FB3F521A
andq (%rcx), %rax
cmpq $0x0, %rax
je 0x82d52
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x826f0
movl $0x2, -0x24(%rbp)
jmp 0x82eb0
movq -0x8(%rbp), %rdi
callq 0x9890
movl $0x0, -0x14(%rbp)
movl $0x0, -0x10(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x9120
movq %rax, %rcx
movq -0x30(%rbp), %rax
cmpq %rcx, %rax
jae 0x82e66
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x30, %eax
jl 0x82dd5
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x39, %eax
jg 0x82dd5
movl -0x10(%rbp), %eax
shll $0x4, %eax
movq -0x8(%rbp), %rcx
movl -0xc(%rbp), %edx
movsbl (%rcx,%rdx), %ecx
subl $0x30, %ecx
addl %ecx, %eax
movl %eax, -0x10(%rbp)
movl $0x1, -0x14(%rbp)
jmp 0x82e56
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x41, %eax
jl 0x82e1a
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x46, %eax
jg 0x82e1a
movl -0x10(%rbp), %eax
shll $0x4, %eax
movq -0x8(%rbp), %rcx
movl -0xc(%rbp), %edx
movsbl (%rcx,%rdx), %ecx
subl $0x41, %ecx
addl $0xa, %ecx
addl %ecx, %eax
movl %eax, -0x10(%rbp)
movl $0x1, -0x14(%rbp)
jmp 0x82e54
cmpl $0x0, -0x14(%rbp)
je 0x82e52
movl $0x1, 0x3481c6(%rip)    # 0x3caff0
movl -0x10(%rbp), %eax
andl $0xff, %eax
movzbl %al, %edi
callq 0x7b210
movl $0x0, 0x3481ac(%rip)    # 0x3caff0
movl $0x0, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
jmp 0x82e54
jmp 0x82e56
jmp 0x82e58
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x82d70
cmpl $0x0, -0x14(%rbp)
je 0x82e9e
movl $0x1, 0x34817a(%rip)    # 0x3caff0
movl -0x10(%rbp), %eax
andl $0xff, %eax
movzbl %al, %edi
callq 0x7b210
movl $0x0, 0x348160(%rip)    # 0x3caff0
movl $0x0, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl $0x3, -0x24(%rbp)
leaq 0x10084e(%rip), %rax    # 0x1836fa
movq %rax, -0x20(%rbp)
jmp 0x82eb2
jmp 0x82eb4
jmp 0x82eb6
jmp 0x82eb8
jmp 0x82eba
jmp 0x82ebc
jmp 0x82ebe
jmp 0x82ec0
jmp 0x82ec2
jmp 0x82ec4
jmp 0x82ec6
jmp 0x82ec8
jmp 0x82eca
jmp 0x82ecc
jmp 0x82ece
jmp 0x82ed0
jmp 0x82ed2
jmp 0x82ed4
jmp 0x82ed6
jmp 0x82ed8
jmp 0x82eda
cmpl $0x0, -0x24(%rbp)
je 0x82f38
movq -0x20(%rbp), %rdx
movl 0x34810a(%rip), %ecx    # 0x3caff4
movq -0x8(%rbp), %r8
leaq 0x31af2b(%rip), %rdi    # 0x39de20
leaq 0x100807(%rip), %rsi    # 0x183703
movb $0x0, %al
callq 0x9060
leaq 0x21a666(%rip), %rax    # 0x29d570
cmpq $0x0, (%rax)
je 0x82f36
leaq 0x21a659(%rip), %rax    # 0x29d570
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
movl 0x3480d0(%rip), %ecx    # 0x3caff4
movq -0x8(%rbp), %r8
leaq 0x1007e6(%rip), %rsi    # 0x183715
movb $0x0, %al
callq 0x9550
jmp 0x82f38
addq $0x30, %rsp
popq %rbp
retq
nop