// File: jkingan[P]ladyheather/heathgps.cpp
// Function: get_uccm_status(unsigned char)
void get_uccm_status(u08 c)
{
char *s;

   // get values from SYST:STAT message response
   if(c == 0x0D) return;   // samsung
   if(c == 0x00) return;

   if(c == 0x0A) {  // end-of-line,  process it
      strupr(scpi_status_line);
      if(uccm_time_line(1)) return;  // time code message in middle of the status message

      if(strstr(scpi_status_line, "SETTLING")) {
         discipline_mode = DIS_MODE_WARMUP;
         saw_uccm_dmode = 1;
      }
      else if(strstr(scpi_status_line, "WARMUP")) {
         discipline_mode = DIS_MODE_WARMUP;
         saw_uccm_dmode = 2;
      }
      else if(strstr(scpi_status_line, "UNLOCK")) {
         discipline_mode = DIS_MODE_UNLOCK;
         saw_uccm_dmode = 3;
      }
      else if(strstr(scpi_status_line, "LOCK")) {
         discipline_mode = DIS_MODE_NORMAL;
         saw_uccm_dmode = 3;
      }
      else if(strstr(scpi_status_line, "NORMAL")) {
         discipline_mode = DIS_MODE_NORMAL;
         saw_uccm_dmode = 3;
      }
      else if(strstr(scpi_status_line, "SURVEY")) {
         discipline_mode = DIS_MODE_NORMAL;
         saw_uccm_dmode = 3;
      }

      if(strstr(scpi_status_line, "COMMAND COMPLETE")) {
//       scpi_status = 0;
      }
      else if(strstr(scpi_status_line, "TFOM")) {
         s = strstr(scpi_status_line, "TFOM");
         if(s) {
            tfom = atoi(s+4);
            have_tfom = 3;
         }
         s = strstr(scpi_status_line, "FFOM");
         if(s) {
            ffom = atoi(s+4);
            have_ffom = 3;
         }
      }
      else if(strstr(scpi_status_line, "NO REF")) {
         no_uccm_ref = 1;
         rcvr_mode = RCVR_MODE_ACQUIRE;  // !!!! RCVR_MODE_NO_SATS
      }
      else if(strstr(scpi_status_line, "WAIT FOR GPS")) {
         no_uccm_ref = 1;
         rcvr_mode = RCVR_MODE_ACQUIRE;
      }
      else if(strstr(scpi_status_line, "PRN") && strstr(scpi_status_line, "EL")) {  // tracking info follows
         if(strstr(scpi_status_line, "SS")) adjust_scpi_ss = 1;
         else                               adjust_scpi_ss = 0;
         scpi_status = 2;
         if(rcvr_type == UCCM_RCVR) {
            reset_sat_tracking();
         }
      }
      else if(strstr(scpi_status_line, "ELEV") && strstr(scpi_status_line, "MASK")) {  // end of tracking info
         scpi_status = 4; // skip lines until we see the COMMAND COMPLETE
         have_count = 44;
         sat_count = scpi_tracked + scpi_not_tracked;
         config_sat_count(sat_count);
         s = strstr(scpi_status_line, "V=");
         if(s) {
            ant_v1 = atof(s+2);
            have_ant_v1 = 1;
         }
         s = strstr(scpi_status_line, "I=");
         if(s) {
            ant_ma = atof(s+2);
            have_ant_ma = 1;
         }
      }
      else if((scpi_status == 4) && strstr(scpi_status_line, "------")) {
         scpi_status = 0;
      }
      if(scpi_status == 2) {  // we are in the az/el area, decode it
         parse_scpi_azel();
      }

      scpi_col = 0;
      scpi_status_line[0] = 0;
   }
   else {  // accumulate the status line
      if(scpi_col < ((int)sizeof(scpi_status_line)-2)) {
         scpi_status_line[scpi_col++] = c;
         scpi_status_line[scpi_col] = 0;
      }
// if(debug_file) fprintf(debug_file, "sline col:%d c:%d: stat:%d [%s]\n", scpi_col, c, scpi_status, scpi_status_line);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movb %dil, %al
movb %al, -0x1(%rbp)
movzbl -0x1(%rbp), %eax
cmpl $0xd, %eax
jne 0xda8ec
jmp 0xdada9
movzbl -0x1(%rbp), %eax
cmpl $0x0, %eax
jne 0xda8fa
jmp 0xdada9
movzbl -0x1(%rbp), %eax
cmpl $0xa, %eax
jne 0xdad6b
leaq 0x2f1402(%rip), %rdi    # 0x3cbd10
callq 0x9890
movl $0x1, %edi
callq 0xd9ec0
cmpl $0x0, %eax
je 0xda927
jmp 0xdada9
leaq 0x2f13e2(%rip), %rdi    # 0x3cbd10
leaq 0xae0de(%rip), %rsi     # 0x188a13
callq 0x9090
cmpq $0x0, %rax
je 0xda95c
leaq 0x291d30(%rip), %rax    # 0x36c677
movb $0xa, (%rax)
leaq 0x19f8a7(%rip), %rax    # 0x27a1f8
movl $0x1, (%rax)
jmp 0xdaa64
leaq 0x2f13ad(%rip), %rdi    # 0x3cbd10
leaq 0xae0b2(%rip), %rsi     # 0x188a1c
callq 0x9090
cmpq $0x0, %rax
je 0xda991
leaq 0x291cfb(%rip), %rax    # 0x36c677
movb $0xa, (%rax)
leaq 0x19f872(%rip), %rax    # 0x27a1f8
movl $0x2, (%rax)
jmp 0xdaa62
leaq 0x2f1378(%rip), %rdi    # 0x3cbd10
leaq 0xb181d(%rip), %rsi     # 0x18c1bc
callq 0x9090
cmpq $0x0, %rax
je 0xda9c6
leaq 0x291cc6(%rip), %rax    # 0x36c677
movb $0x1a, (%rax)
leaq 0x19f83d(%rip), %rax    # 0x27a1f8
movl $0x3, (%rax)
jmp 0xdaa60
leaq 0x2f1343(%rip), %rdi    # 0x3cbd10
leaq 0xb080a(%rip), %rsi     # 0x18b1de
callq 0x9090
cmpq $0x0, %rax
je 0xda9f8
leaq 0x291c91(%rip), %rax    # 0x36c677
movb $0x0, (%rax)
leaq 0x19f808(%rip), %rax    # 0x27a1f8
movl $0x3, (%rax)
jmp 0xdaa5e
leaq 0x2f1311(%rip), %rdi    # 0x3cbd10
leaq 0xae01d(%rip), %rsi     # 0x188a23
callq 0x9090
cmpq $0x0, %rax
je 0xdaa2a
leaq 0x291c5f(%rip), %rax    # 0x36c677
movb $0x0, (%rax)
leaq 0x19f7d6(%rip), %rax    # 0x27a1f8
movl $0x3, (%rax)
jmp 0xdaa5c
leaq 0x2f12df(%rip), %rdi    # 0x3cbd10
leaq 0xadde5(%rip), %rsi     # 0x18881d
callq 0x9090
cmpq $0x0, %rax
je 0xdaa5a
leaq 0x291c2d(%rip), %rax    # 0x36c677
movb $0x0, (%rax)
leaq 0x19f7a4(%rip), %rax    # 0x27a1f8
movl $0x3, (%rax)
jmp 0xdaa5c
jmp 0xdaa5e
jmp 0xdaa60
jmp 0xdaa62
jmp 0xdaa64
leaq 0x2f12a5(%rip), %rdi    # 0x3cbd10
leaq 0xadee8(%rip), %rsi     # 0x18895a
callq 0x9090
cmpq $0x0, %rax
je 0xdaa82
jmp 0xdad4a
leaq 0x2f1287(%rip), %rdi    # 0x3cbd10
leaq 0xa7e15(%rip), %rsi     # 0x1828a5
callq 0x9090
cmpq $0x0, %rax
je 0xdab2a
leaq 0x2f126a(%rip), %rdi    # 0x3cbd10
leaq 0xa7df8(%rip), %rsi     # 0x1828a5
callq 0x9090
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xdaae2
movq -0x10(%rbp), %rdi
addq $0x4, %rdi
callq 0x95c0
movl %eax, %ecx
leaq 0x29135d(%rip), %rax    # 0x36be30
movl %ecx, (%rax)
leaq 0x291358(%rip), %rax    # 0x36be34
movl $0x3, (%rax)
leaq 0x2f1227(%rip), %rdi    # 0x3cbd10
leaq 0xa7dba(%rip), %rsi     # 0x1828aa
callq 0x9090
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xdab25
movq -0x10(%rbp), %rdi
addq $0x4, %rdi
callq 0x95c0
movl %eax, %ecx
leaq 0x291322(%rip), %rax    # 0x36be38
movl %ecx, (%rax)
leaq 0x29131d(%rip), %rax    # 0x36be3c
movl $0x3, (%rax)
jmp 0xdad48
leaq 0x2f11df(%rip), %rdi    # 0x3cbd10
leaq 0xadef2(%rip), %rsi     # 0x188a2a
callq 0x9090
cmpq $0x0, %rax
je 0xdab5c
movl $0x1, 0x2f466b(%rip)    # 0x3cf1b8
leaq 0x29175c(%rip), %rax    # 0x36c2b0
movb $0x9, (%rax)
jmp 0xdad46
leaq 0x2f11ad(%rip), %rdi    # 0x3cbd10
leaq 0xadec7(%rip), %rsi     # 0x188a31
callq 0x9090
cmpq $0x0, %rax
je 0xdab8e
movl $0x1, 0x2f4639(%rip)    # 0x3cf1b8
leaq 0x29172a(%rip), %rax    # 0x36c2b0
movb $0x9, (%rax)
jmp 0xdad44
leaq 0x2f117b(%rip), %rdi    # 0x3cbd10
leaq 0xbb13b(%rip), %rsi     # 0x195cd7
callq 0x9090
cmpq $0x0, %rax
je 0xdac16
leaq 0x2f1162(%rip), %rdi    # 0x3cbd10
leaq 0x953a0(%rip), %rsi     # 0x16ff55
callq 0x9090
cmpq $0x0, %rax
je 0xdac16
leaq 0x2f1149(%rip), %rdi    # 0x3cbd10
leaq 0xbb3d4(%rip), %rsi     # 0x195fa2
callq 0x9090
cmpq $0x0, %rax
je 0xdabe8
leaq 0x19f61c(%rip), %rax    # 0x27a1fc
movl $0x1, (%rax)
jmp 0xdabf5
leaq 0x19f60d(%rip), %rax    # 0x27a1fc
movl $0x0, (%rax)
movl $0x2, 0x2f45b5(%rip)    # 0x3cf1b4
leaq 0x19ceaa(%rip), %rax    # 0x277ab0
cmpq $0x8, (%rax)
jne 0xdac11
callq 0x81c10
jmp 0xdad42
leaq 0x2f10f3(%rip), %rdi    # 0x3cbd10
leaq 0xadc8a(%rip), %rsi     # 0x1888ae
callq 0x9090
cmpq $0x0, %rax
je 0xdad12
leaq 0x2f10d6(%rip), %rdi    # 0x3cbd10
leaq 0xab555(%rip), %rsi     # 0x186196
callq 0x9090
cmpq $0x0, %rax
je 0xdad12
movl $0x4, 0x2f455a(%rip)    # 0x3cf1b4
leaq 0x291897(%rip), %rax    # 0x36c4f8
movl $0x2c, (%rax)
movl 0x2f6457(%rip), %ecx    # 0x3d10c4
addl 0x2f6455(%rip), %ecx    # 0x3d10c8
leaq 0x1c3472(%rip), %rax    # 0x29e0ec
movl %ecx, (%rax)
leaq 0x1c3469(%rip), %rax    # 0x29e0ec
movl (%rax), %edi
callq 0x82080
leaq 0x2f107f(%rip), %rdi    # 0x3cbd10
leaq 0xadda6(%rip), %rsi     # 0x188a3e
callq 0x9090
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xdaccd
movq -0x10(%rbp), %rdi
addq $0x2, %rdi
callq 0x9480
leaq 0x291f7c(%rip), %rax    # 0x36cc38
movsd %xmm0, (%rax)
leaq 0x291f89(%rip), %rax    # 0x36cc50
movl $0x1, (%rax)
leaq 0x2f103c(%rip), %rdi    # 0x3cbd10
leaq 0xadd66(%rip), %rsi     # 0x188a41
callq 0x9090
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xdad10
movq -0x10(%rbp), %rdi
addq $0x2, %rdi
callq 0x9480
leaq 0x291f49(%rip), %rax    # 0x36cc48
movsd %xmm0, (%rax)
leaq 0x291f4e(%rip), %rax    # 0x36cc58
movl $0x1, (%rax)
jmp 0xdad40
cmpl $0x4, 0x2f449b(%rip)    # 0x3cf1b4
jne 0xdad3e
leaq 0x2f0fee(%rip), %rdi    # 0x3cbd10
leaq 0x960ba(%rip), %rsi     # 0x170de3
callq 0x9090
cmpq $0x0, %rax
je 0xdad3e
movl $0x0, 0x2f4476(%rip)    # 0x3cf1b4
jmp 0xdad40
jmp 0xdad42
jmp 0xdad44
jmp 0xdad46
jmp 0xdad48
jmp 0xdad4a
cmpl $0x2, 0x2f4463(%rip)    # 0x3cf1b4
jne 0xdad58
callq 0xd9010
movl $0x0, 0x2f1032(%rip)    # 0x3cbd94
movb $0x0, 0x2f0fa7(%rip)    # 0x3cbd10
jmp 0xdada9
cmpl $0x7f, 0x2f1022(%rip)   # 0x3cbd94
jge 0xdada7
movb -0x1(%rbp), %dl
movl 0x2f1017(%rip), %eax    # 0x3cbd94
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x2f100c(%rip)    # 0x3cbd94
movslq %eax, %rcx
leaq 0x2f0f7e(%rip), %rax    # 0x3cbd10
movb %dl, (%rax,%rcx)
movslq 0x2f0ff8(%rip), %rcx    # 0x3cbd94
leaq 0x2f0f6d(%rip), %rax    # 0x3cbd10
movb $0x0, (%rax,%rcx)
jmp 0xdada9
addq $0x10, %rsp
popq %rbp
retq
nop