// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathgps.cpp
// Function: get_rcvr_enviro_message(unsigned int)
void get_rcvr_enviro_message(unsigned port)
{
u08 c;
static u08 last_c = 0;
static double last_enviro_time = 0.0;

   // This routine is used when the environmental sensor the main "receiver" device.
   // This routine buffers up an incoming environmental message.  When the 
   // end of the message is seen, the message is parsed and decoded with 
   // decode_enviro_msg().  Messages can end with 0x0D, 0x0A, or both.

   if(enviro_type == HEATHER_ENVIRO) ;
   else if(GetMsecs() < last_enviro_time) return;  // rate limits requests to minimize useless traffic
   last_enviro_time = GetMsecs() + ENVIRO_RATE;    // 100 cps max input rate

   // This routine buffers up an incoming sensor message.  When the end of the
   // message is seen, the message is parsed and decoded with decode_enviro_msg()
   // Messages can end with 0x0D, 0x0A, or both.

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

   if(port == RCVR_PORT) {  // sensor is main input decice
      c = get_com_char();
      if(com[RCVR_PORT].rcv_error) {      // parity/framing/overrun errors
         com[RCVR_PORT].rcv_error = 0;
         //!!!!!qqqq    goto rst_msg;
      }
   }
   else {  // sensor is auxiliary input device (/et=)
      c = get_enviro_char();  // aaattt
      if(com[port].rcv_error) {      // parity/framing/overrun errors
         com[port].rcv_error = 0;
         //!!!!!qqqq    goto rst_msg;
      }
   }

   last_c = c;

   if(tsip_sync == 0) {    // syncing to start of message, search for a line feed
      if((c == 0x0D) || (c == 0x0A) || (c == 0x00)) {
         tsip_sync = 1;
         get_sync_time();
      }
      tsip_wptr = 0;
      tsip_rptr = 0;
      return;
   }
   else if(tsip_sync == 1) { // 0x0A has been seen, now build the message
      if((c == 0x0D) || (c == 0x0A) || (c == 0x00)) {
         if(tsip_wptr == 0) return; // end-of-line with no data in the message buffer
         goto tsip_end;  // end of message
      }

      if(tsip_wptr < MAX_TSIP) {   // add char to the message buffer
         tsip_buf[tsip_wptr++] = c;
      }
      else {  // buffer overflow, ignore the message
         tsip_error |= OVFL_ERROR;
         goto rst_msg;
      }
   }
   else {  // end of message
      tsip_end:
      if(tsip_wptr) {           // we have a message
         decode_enviro_msg(port); // process the message
         packet_end = 1;
      }

      rst_msg:
      tsip_wptr = 0;     // prepare for next message
      tsip_rptr = 0;
      if((c == 0x0D) || (c == 0x0A) || (c == 0x00)) tsip_sync = 1;
      else tsip_sync = 0;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
leaq 0x16c080(%rip), %rax    # 0x218914
cmpl $0x2, (%rax)
je 0xac8b0
callq 0xae92
movsd 0x2c59aa(%rip), %xmm1   # 0x372250
ucomisd %xmm0, %xmm1
ja 0xaca27
callq 0xae92
addsd 0x5c7eb(%rip), %xmm0    # 0x1090a8
movsd %xmm0, 0x2c598b(%rip)   # 0x372250
movl %ebx, %edi
callq 0xb9ad
testl %eax, %eax
je 0xac8fc
movl %ebx, %edi
callq 0x1ea0b
cmpl $0xa, %ebx
jne 0xac90d
callq 0x584bd
movl %eax, %r14d
leaq 0x2619f5(%rip), %rax    # 0x30e2e0
cmpb $0x0, 0x17a12(%rax)
je 0xac93b
addq $0x17a12, %rax          # imm = 0x17A12
jmp 0xac938
movl %ebx, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1e66a
callq 0x58584
movl %eax, %r14d
movl %ebx, %eax
imulq $0x2260, %rax, %rax     # imm = 0x2260
leaq 0x2619bb(%rip), %rcx    # 0x30e2e0
cmpb $0x0, 0x2252(%rcx,%rax)
je 0xac93b
addq %rcx, %rax
addq $0x2252, %rax           # imm = 0x2252
movb $0x0, (%rax)
leaq 0x28b914(%rip), %r15    # 0x338256
movzwl (%r15), %eax
cmpl $0x1, %eax
je 0xac989
testl %eax, %eax
jne 0xac9ac
cmpb $0xd, %r14b
ja 0xac96e
movzbl %r14b, %eax
movl $0x2401, %ecx           # imm = 0x2401
btl %eax, %ecx
jae 0xac96e
movw $0x1, (%r15)
callq 0x58672
leaq 0x28b8dd(%rip), %rax    # 0x338252
xorl %ecx, %ecx
movw %cx, (%rax)
leaq 0x28b8d3(%rip), %rax    # 0x338254
movw %cx, (%rax)
jmp 0xaca27
cmpb $0xd, %r14b
ja 0xaca04
movzbl %r14b, %eax
movl $0x2401, %ecx           # imm = 0x2401
btl %eax, %ecx
jae 0xaca04
leaq 0x28b8ae(%rip), %rax    # 0x338252
cmpw $0x0, (%rax)
jne 0xac9b9
jmp 0xaca27
leaq 0x28b89f(%rip), %rax    # 0x338252
cmpw $0x0, (%rax)
je 0xac9ca
movl %ebx, %edi
callq 0xac349
movl $0x1, 0x2bf2ca(%rip)    # 0x36bc94
leaq 0x28b881(%rip), %rax    # 0x338252
xorl %ecx, %ecx
movw %cx, (%rax)
leaq 0x28b877(%rip), %rax    # 0x338254
movw %cx, (%rax)
cmpb $0xd, %r14b
ja 0xac9fc
movzbl %r14b, %eax
movl $0x2401, %ecx           # imm = 0x2401
btl %eax, %ecx
jae 0xac9fc
movw $0x1, (%r15)
jmp 0xaca27
movw $0x0, (%r15)
jmp 0xaca27
leaq 0x28b847(%rip), %rcx    # 0x338252
movzwl (%rcx), %eax
cmpq $0xfff, %rax            # imm = 0xFFF
ja 0xaca32
leal 0x1(%rax), %edx
movw %dx, (%rcx)
leaq 0x28a82d(%rip), %rcx    # 0x337250
movb %r14b, (%rcx,%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x192537(%rip), %rax    # 0x23ef70
orb $-0x80, 0x1(%rax)
jmp 0xac9ca