// File: /workspace/github_cpp_makefile_star2_O1/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
movl $0xa, %edi
callq 0xb9c3
movl $0xa, %edi
testl %eax, %eax
je 0x88555
callq 0x1ea2c
callq 0x584d5
leaq 0x285e08(%rip), %rcx    # 0x30e2e0
cmpb $0x0, 0x17a12(%rcx)
je 0x884e8
movb $0x0, 0x17a12(%rcx)
leaq 0x2afd67(%rip), %rbx    # 0x338256
movzwl (%rbx), %ecx
cmpq $0x6, %rcx
ja 0x8866e
leaq 0x96c85(%rip), %rdx     # 0x11f188
movslq (%rdx,%rcx,4), %rsi
addq %rdx, %rsi
jmpq *%rsi
cmpl $0x1, %eax
jne 0x8851b
movw $0x1, (%rbx)
callq 0x58682
leaq 0x2afd30(%rip), %rax    # 0x338252
xorl %ecx, %ecx
movw %cx, (%rax)
leaq 0x2afd26(%rip), %rax    # 0x338254
movw %cx, (%rax)
movw %cx, 0x2e4580(%rip)     # 0x36cab8
movw %cx, 0x2e457b(%rip)     # 0x36caba
movb $0x0, 0x2e993a(%rip)    # 0x371e80
movl $0x0, 0x2e9934(%rip)    # 0x371e84
jmp 0x886dc
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1e6a0
leaq 0x2afceb(%rip), %rsi    # 0x338252
movzwl (%rsi), %edx
cmpq $0xfff, %rdx            # imm = 0xFFF
ja 0x8858a
addw %ax, 0x2e453e(%rip)     # 0x36cab8
leal 0x1(%rdx), %edi
movw %di, (%rsi)
leaq 0x2aecc9(%rip), %rsi    # 0x337250
movb %al, (%rsi,%rdx)
movl 0x2e98f4(%rip), %eax    # 0x371e84
leal -0x1(%rax), %edx
movl %edx, 0x2e98eb(%rip)    # 0x371e84
cmpl $0x1, %eax
jle 0x8869c
jmp 0x886dc
leaq 0x2afca4(%rip), %rsi    # 0x338252
movzwl (%rsi), %edx
cmpq $0xfff, %rdx            # imm = 0xFFF
ja 0x88663
addw %ax, 0x2e44f3(%rip)     # 0x36cab8
leal 0x1(%rdx), %edi
movw %di, (%rsi)
leaq 0x2aec7e(%rip), %rsi    # 0x337250
movb %al, (%rsi,%rdx)
movzbl 0x2e98a4(%rip), %edx    # 0x371e80
xorl %edx, %eax
cmpl $0xff, %eax
jne 0x8866e
jmp 0x8869c
leaq 0x2afc5d(%rip), %rsi    # 0x338252
movzwl (%rsi), %edx
cmpq $0xfff, %rdx            # imm = 0xFFF
ja 0x88663
addw %ax, 0x2e44b0(%rip)     # 0x36cab8
leal 0x1(%rdx), %edi
movw %di, (%rsi)
leaq 0x2aec3b(%rip), %rsi    # 0x337250
movb %al, (%rsi,%rdx)
movl %eax, 0x2e9866(%rip)    # 0x371e84
leal 0x1(%rcx), %edx
movw %dx, (%rbx)
testl %eax, %eax
jne 0x886dc
leal 0x2(%rcx), %eax
jmp 0x8869f
leaq 0x2afc1a(%rip), %rsi    # 0x338252
movzwl (%rsi), %edx
cmpq $0xfff, %rdx            # imm = 0xFFF
ja 0x88663
addw %ax, 0x2e446d(%rip)     # 0x36cab8
leal 0x1(%rdx), %edi
movw %di, (%rsi)
leaq 0x2aebf8(%rip), %rsi    # 0x337250
movb %al, (%rsi,%rdx)
movb %al, 0x2e981f(%rip)     # 0x371e80
jmp 0x8869c
leaq 0x1b6906(%rip), %rax    # 0x23ef70
orb $-0x80, 0x1(%rax)
leaq 0x2afbdd(%rip), %rax    # 0x338252
xorl %ecx, %ecx
movw %cx, (%rax)
movw %cx, (%rbx)
movb %cl, 0x2e4432(%rip)     # 0x36cab5
movb %cl, 0x2e442b(%rip)     # 0x36cab4
movl $0x0, 0x2e4451(%rip)    # 0x36cae4
jmp 0x886dc
movw %ax, 0x2e441e(%rip)     # 0x36caba
leal 0x1(%rcx), %eax
movw %ax, (%rbx)
jmp 0x886dc
shll $0x8, %eax
addw 0x2e440c(%rip), %ax     # 0x36caba
movw %ax, 0x2e4405(%rip)     # 0x36caba
cmpw 0x2e43fc(%rip), %ax     # 0x36cab8
jne 0x886c3
callq 0x881a2
movl $0x1, 0x2e35c7(%rip)    # 0x36bc94
xorl %eax, %eax
movw %ax, (%rbx)
leaq 0x2afb79(%rip), %rcx    # 0x338252
movw %ax, (%rcx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq