// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: get_ss_message()
void get_ss_message()
{
u08 c;
static u08 id;
static u08 cid;
static int msg_len;

   // This routine buffers up an incoming Novatel message.  When the end of the
   // message is seen, the message is parsed and decoded with decode_ss_msg()

   if(SERIAL_DATA_AVAILABLE(RCVR_PORT) == 0) {
      check_com_timer(RCVR_PORT);
      return;
   }
   else {
      reset_com_timer(RCVR_PORT);
   }

   c = get_com_char();
   if(com[RCVR_PORT].rcv_error) {      // parity/framing/overrun errors
      com[RCVR_PORT].rcv_error = 0;
//!!!!!qqqq    goto rst_msg;
   }

   if(tsip_sync == 0) {    // syncing to start of message, search for a SOH
      if(c == 0x01) {      // SOH seen
         tsip_sync = 1;
         get_sync_time();
      }
      tsip_wptr = 0;
      tsip_rptr = 0;
      ss_vfy_cksum = 0;  // the calculated message checksum
      ss_msg_cksum = 0;  // the checksum in the message
      id = 0;
      cid = 0;
      msg_len = 0;
      return;
   }
   else if(tsip_sync == 1) { // SOH has been seen, get message id
      if(tsip_wptr < MAX_TSIP) {   // add char to the message buffer
         ss_vfy_cksum += c;
         tsip_buf[tsip_wptr++] = c;
      }
      else {
         tsip_error |= OVFL_ERROR;
         goto rst_msg;
      }
      id = c;
      ++tsip_sync;
   }
   else if(tsip_sync == 2) { // message id inverted
      if(tsip_wptr < MAX_TSIP) {   // add char to the message buffer
         ss_vfy_cksum += c;
         tsip_buf[tsip_wptr++] = c;
      }
      else {
         tsip_error |= OVFL_ERROR;
         goto rst_msg;
      }
      cid = c ^ 0xFF;
//BEEP(5555);  // piss3
//sprintf(out, "id:%02X(%d)  c:%02X  cinv:%02x    ", id,id, c, cid);
//DEBUGSTR(out);
//refresh_page();
      if(id != cid) goto rst_msg;
      ++tsip_sync;
   }
   else if(tsip_sync == 3) { // message len
      if(tsip_wptr < MAX_TSIP) {   // add char to the message buffer
         ss_vfy_cksum += c;
         tsip_buf[tsip_wptr++] = c;
      }
      else {
         tsip_error |= OVFL_ERROR;
         goto rst_msg;
      }
      msg_len = c;
      ++tsip_sync;
      if(msg_len == 0) ++tsip_sync;
   }
   else if(tsip_sync == 4) { // message body
      if(tsip_wptr < MAX_TSIP) {   // add char to the message buffer
         ss_vfy_cksum += c;
         tsip_buf[tsip_wptr++] = c;
      }
      --msg_len;
      if(msg_len <= 0) ++tsip_sync;
   }
   else if(tsip_sync == 5) {  // low byte of checksum
      ss_msg_cksum = c;
      ++tsip_sync;
   }
   else if(tsip_sync == 6) {  // high byte of checksum
      ss_msg_cksum += ((int) c) * 256;
      if(ss_msg_cksum == ss_vfy_cksum) decode_ss_msg();
      packet_end = 1;
      tsip_sync = 0;
      tsip_wptr = 0;
      tsip_sync = 0;
   }
   else {     // should never happen, prepare for next message
      rst_msg:
      tsip_wptr = 0;
      tsip_sync = 0;
      nmea_vfy_cksum = nmea_msg_cksum = 0; // init received message checksum
      venus_nmea = 0;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
pushq $0xa
popq %rdi
callq 0xb771
pushq $0xa
popq %rdi
testl %eax, %eax
je 0x7bff4
callq 0x1d93f
callq 0x51891
leaq 0x27c368(%rip), %rcx    # 0x2f82e0
cmpb $0x0, 0x17a12(%rcx)
je 0x7bf88
movb $0x0, 0x17a12(%rcx)
leaq 0x2a62c7(%rip), %rbx    # 0x322256
movzwl (%rbx), %ecx
cmpq $0x6, %rcx
ja 0x7c11a
leaq 0x8d1e9(%rip), %rdx     # 0x10918c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpl $0x1, %eax
jne 0x7bfbb
movw $0x1, (%rbx)
callq 0x51a2f
leaq 0x2a6290(%rip), %rax    # 0x322252
andw $0x0, (%rax)
leaq 0x2a6287(%rip), %rax    # 0x322254
andw $0x0, (%rax)
andw $0x0, 0x2daadf(%rip)    # 0x356ab8
andw $0x0, 0x2daad9(%rip)    # 0x356aba
movb $0x0, 0x2dfe98(%rip)    # 0x35be80
andl $0x0, 0x2dfe95(%rip)    # 0x35be84
jmp 0x7c186
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1d61b
leaq 0x2a624c(%rip), %rdx    # 0x322252
movzwl (%rdx), %ecx
cmpq $0xfff, %rcx            # imm = 0xFFF
ja 0x7c029
addw %ax, 0x2daa9f(%rip)     # 0x356ab8
leal 0x1(%rcx), %esi
movw %si, (%rdx)
leaq 0x2a522a(%rip), %rdx    # 0x321250
movb %al, (%rdx,%rcx)
movl 0x2dfe55(%rip), %eax    # 0x35be84
leal -0x1(%rax), %ecx
movl %ecx, 0x2dfe4c(%rip)    # 0x35be84
cmpl $0x1, %eax
jg 0x7c186
movw $0x5, (%rbx)
jmp 0x7c186
leaq 0x2a6200(%rip), %rdx    # 0x322252
movzwl (%rdx), %ecx
cmpq $0xfff, %rcx            # imm = 0xFFF
ja 0x7c10f
addw %ax, 0x2daa4f(%rip)     # 0x356ab8
leal 0x1(%rcx), %esi
movw %si, (%rdx)
leaq 0x2a51da(%rip), %rdx    # 0x321250
movb %al, (%rdx,%rcx)
movzbl 0x2dfe00(%rip), %ecx    # 0x35be80
xorl %ecx, %eax
cmpl $0xff, %eax
jne 0x7c11a
movw $0x3, (%rbx)
jmp 0x7c186
leaq 0x2a61b4(%rip), %rdx    # 0x322252
movzwl (%rdx), %ecx
cmpq $0xfff, %rcx            # imm = 0xFFF
ja 0x7c10f
addw %ax, 0x2daa07(%rip)     # 0x356ab8
leal 0x1(%rcx), %esi
movw %si, (%rdx)
leaq 0x2a5192(%rip), %rdx    # 0x321250
movb %al, (%rdx,%rcx)
movl %eax, 0x2dfdbd(%rip)    # 0x35be84
xorl %ecx, %ecx
cmpl $0x1, %eax
adcw $0x4, %cx
movw %cx, (%rbx)
jmp 0x7c186
leaq 0x2a6173(%rip), %rdx    # 0x322252
movzwl (%rdx), %ecx
cmpq $0xfff, %rcx            # imm = 0xFFF
ja 0x7c10f
addw %ax, 0x2da9c6(%rip)     # 0x356ab8
leal 0x1(%rcx), %esi
movw %si, (%rdx)
leaq 0x2a5151(%rip), %rdx    # 0x321250
movb %al, (%rdx,%rcx)
movb %al, 0x2dfd78(%rip)     # 0x35be80
movw $0x2, (%rbx)
jmp 0x7c186
leaq 0x1ace5a(%rip), %rax    # 0x228f70
orb $-0x80, 0x1(%rax)
leaq 0x2a6131(%rip), %rax    # 0x322252
andw $0x0, (%rax)
andw $0x0, (%rbx)
xorl %eax, %eax
movb %al, 0x2da984(%rip)     # 0x356ab5
movb %al, 0x2da97d(%rip)     # 0x356ab4
andl $0x0, 0x2da9a6(%rip)    # 0x356ae4
jmp 0x7c186
movw %ax, 0x2da973(%rip)     # 0x356aba
movw $0x6, (%rbx)
jmp 0x7c186
shll $0x8, %eax
addw 0x2da962(%rip), %ax     # 0x356aba
movw %ax, 0x2da95b(%rip)     # 0x356aba
cmpw 0x2da952(%rip), %ax     # 0x356ab8
jne 0x7c16d
callq 0x7bd95
leaq 0x2a60de(%rip), %rax    # 0x322252
andw $0x0, (%rax)
movl $0x1, 0x2d9b12(%rip)    # 0x355c94
andw $0x0, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq