// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: decode_uccm_msg(int)
void decode_uccm_msg(int why)
{
char c;
int i, j;

   start_msg_decode(0);

   nmea_msg[0] = 0;
   j = 0;
   for(i=0; i<tsip_wptr; i++) {  // copy message from tsip buffer to nmea buffer
      c = tsip_byte();
      nmea_msg[j++] = c;
      nmea_msg[j] = 0;
      if(i >= ((int)sizeof(nmea_msg)-12)) break;
   }

   tsip_wptr = tsip_rptr = 0;
   tsip_sync = 0;

   // get the response from the receiver and pass it to (HOPEFULLY) the routine
   // that expects it...

   strupr(nmea_msg);

if(debug_file) fprintf(debug_file, "Decode uccm msg %d:%s\n", uccm_msg_id, nmea_msg);

   if(strstr(nmea_msg, "UCCM-L")) {  // samsung ID message (-LPK, -L8)
   }
   else if(strstr(nmea_msg, "UCCM-P")) {  // UCCM error response?
      if(user_set_scpi_type == 0) scpi_type = UCCMP_TYPE; // samsung
      uccm_msg_id = 0;
      return;
   }
   else if(strstr(nmea_msg, "UCCM")) {  // UCCM error response?
      uccm_msg_id = 0;
      return;
   }
   else if(strstr(nmea_msg, "COMMAND COMPLETE")) {
      if(uccm_msg_id == SCPI_IGNORE_MSG) {  // null response to ignore message - no sats exclued
         sats_enabled = 0xFFFFFFFF;
         update_disable_list(sats_enabled);
      }
      uccm_msg_id = 0;
      return;
   }
   else if(strstr(nmea_msg, "COMMAND ERROR")) {
      uccm_msg_id = 0;
      return;
   }
   else if(strstr(nmea_msg, "UNDEFINED HEADER")) {
      uccm_msg_id = 0;
      return;
   }
   else if(strstr(nmea_msg, "INVALID PARAMETER")) {
      uccm_msg_id = 0;
      return;
   }
   else if(strstr(nmea_msg, "DATA OUT OF RANGE")) {  // samsung
      uccm_msg_id = 0;
      return;
   }
   else if(strstr(nmea_msg, "CORRUPT")) {  // "Data corrupt or stale" uccmp
      uccm_msg_id = 0;
      return;
   }
   else if((nmea_msg[0] == 'C') && (nmea_msg[1] == '5')) {  // time string 132 bytes (44 values) long
      parse_uccm_time(123);

      uccm_time:
if(1 || have_uccm_loop) {
   send_polled_cmd("SYNC:TINT?", SCPI_TINT_MSG);
   poll_next_uccm();
}

if(1 || (scpi_type != UCCMP_TYPE)) {  //kkkkkkkkkkkkk
   poll_next_uccm();
   poll_next_uccm();
   poll_next_uccm();
//poll_next_uccm();
//poll_next_uccm();
//poll_next_uccm();
}
      return;
   }
   else if(uccm_msg_id == 0) {
if(debug_file) fprintf(debug_file, "response to:%s (status msg:%d) is next\n", nmea_msg, scpi_status);
      if     (strstr(nmea_msg, "GPS:POS?"))                uccm_msg_id = SCPI_POSN_MSG;
      else if(strstr(nmea_msg, "SYNC:TINT?"))              uccm_msg_id = SCPI_TINT_MSG;
      else if(strstr(nmea_msg, "ALARM:HARD?"))             uccm_msg_id = UCCM_GET_HW_ALARM;
      else if(strstr(nmea_msg, "ALARM:OPER?"))             uccm_msg_id = UCCM_GET_OPER_ALARM;
      else if(strstr(nmea_msg, "DIAG:ROSC:EFC:REL?"))      uccm_msg_id = SCPI_EFC_MSG;
      else if(strstr(nmea_msg, "LED:GPSL?"))               uccm_msg_id = UCCM_LED_MSG;
      else if(strstr(nmea_msg, ":GPS:POS:SURV:STAT?"))     uccm_msg_id = SCPI_SURVEY_MSG;
      else if(strstr(nmea_msg, ":GPS:POS:SURV:PROG?"))     uccm_msg_id = SCPI_PROGRESS_MSG;
      else if(strstr(nmea_msg, ":GPS:POS:SURV:STAT ONCE")) uccm_msg_id = SCPI_SURVEY_MSG;
      else if(strstr(nmea_msg, "ROSC:HOLD:DUR?"))          uccm_msg_id = SCPI_HOLDOVER_MSG;
      else if(strstr(nmea_msg, "SYNC:IMM"))                uccm_msg_id = SCPI_JAMSYNC_MSG;
      else if(strstr(nmea_msg, "DIAG:ROSC:EFC:DATA?"))     uccm_msg_id = UCCM_EFC_MSG;
      else if(strstr(nmea_msg, "GPS:SAT:TRAC:EMAN?"))      uccm_msg_id = SCPI_ELEV_MSG;
      else if(strstr(nmea_msg, "GPS:SAT:TRAC:IGN?"))       uccm_msg_id = SCPI_IGNORE_MSG;
      else if(strstr(nmea_msg, "GPS:REF:ADEL?"))           uccm_msg_id = SCPI_GET_CABLE_MSG;
      else if(strstr(nmea_msg, "GPS:REF:ADEL "))           uccm_msg_id = SCPI_SET_CABLE_MSG;
      else if(strstr(nmea_msg, "PULLINRANGE?"))            uccm_msg_id = UCCM_GET_PULLIN_MSG;
      else if(strstr(nmea_msg, "PULLINRANGE"))             uccm_msg_id = UCCM_SET_PULLIN_MSG;
      else if(strstr(nmea_msg, "OUTP:TP:SEL?"))            uccm_msg_id = UCCM_RATE_MSG;
      else if(strstr(nmea_msg, "OUTP:STAT?"))              uccm_msg_id = UCCM_STATE_MSG;
      else if(strstr(nmea_msg, "*IDN?"))                   uccm_msg_id = SCPI_ID_MSG;
      else if(strstr(nmea_msg, "*TST?"))                   uccm_msg_id = SCPI_TEST_MSG;
      else if(strstr(nmea_msg, "SYST:STAT?")) {
         uccm_msg_id = UCCM_STATUS_MSG;
         parse_scpi_status();
      }
      else if(strstr(nmea_msg, "DIAG:LOOP?")) {
         uccm_msg_id = SCPI_EFC_MSG;
         parse_uccm_loop();
      }
      else if(strstr(nmea_msg, "C5")) {  //kkkkkkkkk
         uccm_msg_id = 0;
         parse_uccm_time(144);
         goto uccm_time;
      }
      return;
   }

if(debug_file) fprintf(debug_file, "uccm %d response:%s\n", uccm_msg_id, nmea_msg);
   if     (uccm_msg_id == SCPI_POSN_MSG)       parse_scpi_posn();
   else if(uccm_msg_id == SCPI_TINT_MSG)       parse_scpi_tint();
   else if(uccm_msg_id == SCPI_EFC_MSG)        parse_scpi_efc();
   else if(uccm_msg_id == UCCM_LED_MSG)        parse_uccm_led();
   else if(uccm_msg_id == UCCM_EFC_MSG)        parse_uccm_efc();
   else if(uccm_msg_id == SCPI_TEST_MSG)       parse_scpi_test();
   else if(uccm_msg_id == SCPI_ELEV_MSG)       parse_scpi_elev();
   else if(uccm_msg_id == SCPI_IGNORE_MSG)     parse_scpi_ignore();
   else if(uccm_msg_id == SCPI_GET_CABLE_MSG)  parse_scpi_cable();
   else if(uccm_msg_id == SCPI_SET_CABLE_MSG)  parse_scpi_cable();
   else if(uccm_msg_id == SCPI_ID_MSG)         parse_scpi_id();
   else if(uccm_msg_id == SCPI_SURVEY_MSG)     parse_scpi_survey();
   else if(uccm_msg_id == SCPI_PROGRESS_MSG)   parse_scpi_progress();
   else if(uccm_msg_id == SCPI_JAMSYNC_MSG)    parse_scpi_jamsync();
   else if(uccm_msg_id == SCPI_HOLDOVER_MSG)   parse_scpi_holdover();
   else if(uccm_msg_id == UCCM_RATE_MSG)       parse_uccm_rate();
   else if(uccm_msg_id == UCCM_STATE_MSG)      parse_uccm_state();
   else if(uccm_msg_id == UCCM_GET_PULLIN_MSG) parse_uccm_pullin();
   else if(uccm_msg_id == UCCM_GET_HW_ALARM)   parse_uccm_hw_alarm();
   else if(uccm_msg_id == UCCM_GET_OPER_ALARM) parse_uccm_oper_alarm();
   else if(uccm_msg_id == UCCM_STATUS_MSG) {
      if(strstr(nmea_msg, "TEMP = ")) {  // samsung temperature value
         parse_uccm_temp();
      }
   }
   uccm_msg_id = 0;

   if(sim_file && sim_delay) {  // throttle sim file messages
      Sleep(sim_delay);
   }
   saw_rcvr_msg = 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x73dcb
leaq 0x2940e3(%rip), %r15    # 0x325830
movb $0x0, (%r15)
leaq 0x290afa(%rip), %r14    # 0x322252
movzwl (%r14), %eax
cmpl %eax, %ebx
jae 0x9177e
callq 0x51c47
movb %al, (%rbx,%r15)
movb $0x0, 0x1(%rbx,%r15)
leaq 0x1(%rbx), %rax
movq %rax, %rbx
cmpq $0x1f6, %rax            # imm = 0x1F6
jne 0x91758
leaq 0x290acf(%rip), %rax    # 0x322254
andw $0x0, (%rax)
andw $0x0, (%r14)
leaq 0x290ac1(%rip), %rax    # 0x322256
andw $0x0, (%rax)
leaq 0x294090(%rip), %rdi    # 0x325830
callq 0x988f
leaq 0x196be4(%rip), %r14    # 0x228390
movq (%r14), %rdi
testq %rdi, %rdi
je 0x917cf
movl 0x2ca722(%rip), %edx    # 0x35bedc
leaq 0x7ddca(%rip), %rsi     # 0x10f58b
leaq 0x294068(%rip), %rcx    # 0x325830
xorl %eax, %eax
callq 0x9560
leaq 0x29405a(%rip), %rdi    # 0x325830
leaq 0x7d7ad(%rip), %rsi     # 0x10ef8a
callq 0x9090
testq %rax, %rax
je 0x91832
movq (%r14), %rdi
movl 0x2ca6ec(%rip), %edx    # 0x35bedc
testq %rdi, %rdi
je 0x91810
leaq 0x7de56(%rip), %rsi     # 0x10f652
leaq 0x29402d(%rip), %rcx    # 0x325830
xorl %eax, %eax
callq 0x9560
movl 0x2ca6cc(%rip), %edx    # 0x35bedc
leal -0xa(%rdx), %eax
cmpl $0x1c, %eax
ja 0x91865
leaq 0x7810d(%rip), %rcx     # 0x10992c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
callq 0x8f1b6
jmp 0x91982
leaq 0x293ff7(%rip), %rdi    # 0x325830
leaq 0x7dd62(%rip), %rsi     # 0x10f5a2
callq 0x9090
testq %rax, %rax
je 0x9188b
leaq 0x17109b(%rip), %rax    # 0x2028ec
cmpl $0x0, (%rax)
jne 0x918a3
leaq 0x173783(%rip), %rax    # 0x204fe0
movl $0x50, (%rax)
jmp 0x918a3
addl $-0x64, %edx
cmpl $0xb, %edx
ja 0x91982
leaq 0x78128(%rip), %rax     # 0x1099a0
movslq (%rax,%rdx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
callq 0x90617
jmp 0x91982
leaq 0x293f9e(%rip), %rdi    # 0x325830
leaq 0x7dd10(%rip), %rsi     # 0x10f5a9
callq 0x9090
testq %rax, %rax
je 0x918af
andl $0x0, 0x2ca632(%rip)    # 0x35bedc
jmp 0x919c0
leaq 0x293f7a(%rip), %rdi    # 0x325830
leaq 0x7dcf1(%rip), %rsi     # 0x10f5ae
callq 0x9090
testq %rax, %rax
je 0x919cb
cmpl $0x1e, 0x2ca60a(%rip)   # 0x35bedc
jne 0x918a3
leaq 0x265809(%rip), %rax    # 0x2f70e4
orl $-0x1, (%rax)
pushq $-0x1
popq %rdi
callq 0x56b6d
jmp 0x918a3
callq 0x9014d
jmp 0x91982
callq 0x8fbd5
jmp 0x91982
callq 0x8f71f
jmp 0x91982
callq 0x8fadb
jmp 0x91982
callq 0x8f227
jmp 0x91982
callq 0x8fa65
jmp 0x91982
callq 0x8fce5
jmp 0x91982
callq 0x8fb4d
jmp 0x91982
callq 0x8fe90
jmp 0x91982
callq 0x8f006
jmp 0x91982
callq 0x90319
jmp 0x91982
callq 0x90686
jmp 0x91982
callq 0x906d8
jmp 0x91982
callq 0x8f073
jmp 0x91982
callq 0x8f10a
jmp 0x91982
leaq 0x293ed2(%rip), %rdi    # 0x325830
leaq 0x7dc1e(%rip), %rsi     # 0x10f583
callq 0x9090
testq %rax, %rax
je 0x91982
callq 0x91675
jmp 0x91982
callq 0x90751
jmp 0x91982
callq 0x907ba
andl $0x0, 0x2ca553(%rip)    # 0x35bedc
leaq 0x196a30(%rip), %rax    # 0x2283c0
cmpq $0x0, (%rax)
setne %al
leaq 0x17bc62(%rip), %rcx    # 0x20d600
movq (%rcx), %rdi
testq %rdi, %rdi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x919b3
callq 0xae83
leaq 0x1975e6(%rip), %rax    # 0x228fa0
movl $0x1, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x293e5e(%rip), %rdi    # 0x325830
leaq 0x7dbe6(%rip), %rsi     # 0x10f5bf
callq 0x9090
testq %rax, %rax
jne 0x918a3
leaq 0x293e42(%rip), %rdi    # 0x325830
leaq 0x7dbd8(%rip), %rsi     # 0x10f5cd
callq 0x9090
testq %rax, %rax
jne 0x918a3
leaq 0x293e26(%rip), %rdi    # 0x325830
leaq 0x7dbcd(%rip), %rsi     # 0x10f5de
callq 0x9090
testq %rax, %rax
jne 0x918a3
leaq 0x293e0a(%rip), %rdi    # 0x325830
leaq 0x7dbc3(%rip), %rsi     # 0x10f5f0
callq 0x9090
testq %rax, %rax
jne 0x918a3
leaq 0x293dee(%rip), %rbx    # 0x325830
leaq 0x80eec(%rip), %rsi     # 0x112935
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
jne 0x918a3
cmpb $0x43, (%rbx)
jne 0x91a9a
cmpb $0x35, 0x1(%rbx)
jne 0x91a9a
pushq $0x7b
popq %rdi
callq 0x913e7
leaq 0x7db8e(%rip), %rdi     # 0x10f602
pushq $0x10
popq %rsi
callq 0x64f01
callq 0x6680e
callq 0x6680e
callq 0x6680e
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6680e
movl 0x2ca43c(%rip), %edx    # 0x35bedc
movq (%r14), %rdi
testl %edx, %edx
jne 0x917f0
testq %rdi, %rdi
je 0x91acb
movl 0x2c852e(%rip), %ecx    # 0x359fe4
leaq 0x7db50(%rip), %rsi     # 0x10f60d
leaq 0x293d6c(%rip), %rdx    # 0x325830
xorl %eax, %eax
callq 0x9560
leaq 0x293d5e(%rip), %rdi    # 0x325830
leaq 0x7d858(%rip), %rsi     # 0x10f331
callq 0x9090
testq %rax, %rax
je 0x91af2
movl $0x15, 0x2ca3ef(%rip)   # 0x35bedc
jmp 0x919c0
leaq 0x293d37(%rip), %rdi    # 0x325830
leaq 0x7db02(%rip), %rsi     # 0x10f602
callq 0x9090
testq %rax, %rax
je 0x91b19
movl $0x10, 0x2ca3c8(%rip)   # 0x35bedc
jmp 0x919c0
leaq 0x293d10(%rip), %rdi    # 0x325830
leaq 0x7da08(%rip), %rsi     # 0x10f52f
callq 0x9090
testq %rax, %rax
je 0x91b40
movl $0x6e, 0x2ca3a1(%rip)   # 0x35bedc
jmp 0x919c0
leaq 0x293ce9(%rip), %rdi    # 0x325830
leaq 0x7d9ed(%rip), %rsi     # 0x10f53b
callq 0x9090
testq %rax, %rax
je 0x91b67
movl $0x6f, 0x2ca37a(%rip)   # 0x35bedc
jmp 0x919c0
leaq 0x293cc2(%rip), %rdi    # 0x325830
leaq 0x7d9a7(%rip), %rsi     # 0x10f51c
callq 0x9090
testq %rax, %rax
je 0x91b8e
movl $0xb, 0x2ca353(%rip)    # 0x35bedc
jmp 0x919c0
leaq 0x293c9b(%rip), %rdi    # 0x325830
leaq 0x79bd7(%rip), %rsi     # 0x10b773
callq 0x9090
testq %rax, %rax
je 0x91bb5
movl $0x69, 0x2ca32c(%rip)   # 0x35bedc
jmp 0x919c0
leaq 0x293c74(%rip), %rdi    # 0x325830
leaq 0x79aaa(%rip), %rsi     # 0x10b66d
callq 0x9090
testq %rax, %rax
je 0x91bdc
movl $0x13, 0x2ca305(%rip)   # 0x35bedc
jmp 0x919c0
leaq 0x293c4d(%rip), %rdi    # 0x325830
leaq 0x7d7c6(%rip), %rsi     # 0x10f3b0
callq 0x9090
testq %rax, %rax
je 0x91c03
movl $0x12, 0x2ca2de(%rip)   # 0x35bedc
jmp 0x919c0
leaq 0x293c26(%rip), %rdi    # 0x325830
leaq 0x79cf6(%rip), %rsi     # 0x10b907
callq 0x9090
testq %rax, %rax
jne 0x91bcd
leaq 0x293c0e(%rip), %rdi    # 0x325830
leaq 0x7980d(%rip), %rsi     # 0x10b436
callq 0x9090
testq %rax, %rax
je 0x91c42
movl $0x16, 0x2ca29f(%rip)   # 0x35bedc
jmp 0x919c0
leaq 0x293be7(%rip), %rdi    # 0x325830
leaq 0x797dc(%rip), %rsi     # 0x10b42c
callq 0x9090
testq %rax, %rax
je 0x91c69
movl $0x21, 0x2ca278(%rip)   # 0x35bedc
jmp 0x919c0
leaq 0x293bc0(%rip), %rdi    # 0x325830
leaq 0x7964d(%rip), %rsi     # 0x10b2c4
callq 0x9090
testq %rax, %rax
je 0x91c90
movl $0x67, 0x2ca251(%rip)   # 0x35bedc
jmp 0x919c0
leaq 0x293b99(%rip), %rdi    # 0x325830
leaq 0x79220(%rip), %rsi     # 0x10aebe
callq 0x9090
testq %rax, %rax
je 0x91cb7
movl $0xa, 0x2ca22a(%rip)    # 0x35bedc
jmp 0x919c0
leaq 0x293b72(%rip), %rdi    # 0x325830
leaq 0x78f05(%rip), %rsi     # 0x10abca
callq 0x9090
testq %rax, %rax
je 0x91cde
movl $0x1e, 0x2ca203(%rip)   # 0x35bedc
jmp 0x919c0
leaq 0x293b4b(%rip), %rdi    # 0x325830
leaq 0x793b6(%rip), %rsi     # 0x10b0a2
callq 0x9090
testq %rax, %rax
je 0x91d05
movl $0xe, 0x2ca1dc(%rip)    # 0x35bedc
jmp 0x919c0
leaq 0x293b24(%rip), %rdi    # 0x325830
leaq 0x7d922(%rip), %rsi     # 0x10f635
callq 0x9090
testq %rax, %rax
je 0x91d2c
movl $0x26, 0x2ca1b5(%rip)   # 0x35bedc
jmp 0x919c0
leaq 0x293afd(%rip), %rdi    # 0x325830
leaq 0x7902d(%rip), %rsi     # 0x10ad67
callq 0x9090
testq %rax, %rax
je 0x91d53
movl $0x6d, 0x2ca18e(%rip)   # 0x35bedc
jmp 0x919c0
leaq 0x293ad6(%rip), %rdi    # 0x325830
leaq 0x7d8e2(%rip), %rsi     # 0x10f643
callq 0x9090
testq %rax, %rax
je 0x91d7a
movl $0x6c, 0x2ca167(%rip)   # 0x35bedc
jmp 0x919c0
leaq 0x293aaf(%rip), %rdi    # 0x325830
leaq 0x7947c(%rip), %rsi     # 0x10b204
callq 0x9090
testq %rax, %rax
je 0x91da1
movl $0x64, 0x2ca140(%rip)   # 0x35bedc
jmp 0x919c0
leaq 0x293a88(%rip), %rdi    # 0x325830
leaq 0x78fad(%rip), %rsi     # 0x10ad5c
callq 0x9090
testq %rax, %rax
je 0x91dc8
movl $0x6b, 0x2ca119(%rip)   # 0x35bedc
jmp 0x919c0
leaq 0x293a61(%rip), %rdi    # 0x325830
leaq 0x79839(%rip), %rsi     # 0x10b60f
callq 0x9090
testq %rax, %rax
je 0x91def
movl $0x1c, 0x2ca0f2(%rip)   # 0x35bedc
jmp 0x919c0
leaq 0x293a3a(%rip), %rdi    # 0x325830
leaq 0x78893(%rip), %rsi     # 0x10a690
callq 0x9090
testq %rax, %rax
je 0x91e16
movl $0x19, 0x2ca0cb(%rip)   # 0x35bedc
jmp 0x919c0
leaq 0x293a13(%rip), %rdi    # 0x325830
leaq 0x7c2b2(%rip), %rsi     # 0x10e0d6
callq 0x9090
testq %rax, %rax
je 0x91e47
movl $0x65, 0x2ca0a4(%rip)   # 0x35bedc
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x907da
leaq 0x2939e2(%rip), %rdi    # 0x325830
leaq 0x7d6bc(%rip), %rsi     # 0x10f511
callq 0x9090
testq %rax, %rax
je 0x91e78
movl $0xb, 0x2ca073(%rip)    # 0x35bedc
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x913b6
leaq 0x2939b1(%rip), %rdi    # 0x325830
leaq 0x7d7c9(%rip), %rsi     # 0x10f64f
callq 0x9090
testq %rax, %rax
je 0x919c0
andl $0x0, 0x2ca041(%rip)    # 0x35bedc
movl $0x90, %edi
jmp 0x91a68