// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: get_ae_packet()
void get_ae_packet()
{
u08 subcode;      // packet subcode
u16 zero;         // ???
u08 leds;         // led status
u08 hold;         // holdover state
u08 pll;          // pll state
u08 dis;          // disciplining mode
u08 flash;        // firmware code
u08 b1,b2;        // ???
u08 log_count;    // number of events in the log
u16 op_status;    // operation status
u16 hw_status;    // hardware status
float pps_val;    // related to pps error (in ns)
float osc_val;    // related to osc error (in ppb)
int i;
unsigned char buf[32];


   log_packet_id("Packet 0x8F.AE (Nortel packet)");

   // Unknown packet sent by Nortel receiver.  Also mentioned as being
   // sent by the Palisade,  but in a different format.

// for(i=0; i<9+8; i++) tsip_byte();
   subcode = tsip_byte();
   if(subcode == 0x01) {
      zero  = tsip_word();
      leds  = tsip_byte();
      ffom  = tsip_byte();
      have_ffom = 1;
      tfom  = tsip_byte();
      have_tfom = 1;
      hold  = tsip_byte();

      if(try_ntpx == 0) {
         pll   = tsip_byte();
         dis   = tsip_byte();
         flash = tsip_byte();

         b1 = tsip_byte();    // 0
         b2 = tsip_byte();    // 1
         log_count = tsip_byte();  // error count
         op_status = tsip_word(); 
         hw_status = tsip_word(); 

         pps_val = tsip_single();  // PPS val (ns)
         osc_val = tsip_single();  // OSC val (ppb)
      }
//    sprintf(plot_title, "led:%02X  ffom:%02X tfom:%02X  ho:%02X  pll:%02X  dis:%02X  flash:%02X  b:%02X,%02X  log:%02X  op:%04X hw:%04X  %12g %12g", 
//      leds, ffom,tfom,  hold,pll,dis,flash, b1,b2, log_count, op_status,hw_status, pps_val,osc_val);
   }
   else if(1) {
//    plot_title[0] = 0;
      for(i=0; i<9+8+8; i++) {
         buf[i] = tsip_byte();
//       sprintf(out, "%02X ", (unsigned) buf[i]);
//       strcat(plot_title, out);
      }
   }

   check_tsip_end(1);
   if(STARLOC) ;
   else if(try_ntpx && (tsip_error == 0) && (zero == 0x0001)) {
      saw_ntpx = 1;
      strcpy(unit_name, "Nortel NTPX"); 
      saw_gpsdo = 3;
      if(user_set_temp_filter == 0) undo_fw_temp_filter = 0;
   }

   if(STARLOC) ;
   else if(tsip_error && (zero == 0x0001)) { // error seen, maybe it's an NTPX gpsdo?
      try_ntpx ^= 1;
      if(try_ntpx == 0) {
         saw_ntpx = 0;
         saw_gpsdo = 0;
      }
   }
//sprintf(plot_title, "ntpx: %d  zero:%04X  saw_ntpx=%d  notel=%d  oscp=%04X", 
//try_ntpx, zero, saw_ntpx, saw_nortel, have_osc_params);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
leaq 0x9cd28(%rip), %rdi     # 0x10c237
callq 0x520bf
callq 0x51c47
cmpb $0x1, %al
jne 0x6f638
callq 0x51c63
movl %eax, %ebx
callq 0x51c47
callq 0x51c47
movzbl %al, %eax
leaq 0x28771c(%rip), %rcx    # 0x2f6c58
movl %eax, (%rcx)
leaq 0x287717(%rip), %rax    # 0x2f6c5c
pushq $0x1
popq %r14
movl %r14d, (%rax)
callq 0x51c47
movzbl %al, %eax
leaq 0x2876f5(%rip), %rcx    # 0x2f6c50
movl %eax, (%rcx)
leaq 0x2876f0(%rip), %rax    # 0x2f6c54
movl %r14d, (%rax)
callq 0x51c47
leaq 0x1b99c8(%rip), %rax    # 0x228f3b
cmpb $0x0, (%rax)
jne 0x6f5aa
callq 0x51c47
callq 0x51c47
callq 0x51c47
callq 0x51c47
callq 0x51c47
callq 0x51c47
callq 0x51c63
callq 0x51c63
callq 0x51dc3
callq 0x51dc3
xorl %edi, %edi
callq 0x52194
leaq 0x193318(%rip), %rax    # 0x2028d0
cmpq $0x1, (%rax)
jne 0x6f5ce
leaq 0x195a0f(%rip), %rax    # 0x204fd4
cmpl $0x53, (%rax)
je 0x6f67e
leaq 0x1b9966(%rip), %rcx    # 0x228f3b
movb (%rcx), %al
leaq 0x1b9992(%rip), %rdx    # 0x228f70
movl (%rdx), %edx
cmpw $0x1, %bx
jne 0x6f64d
testb %al, %al
je 0x6f64d
testl %edx, %edx
jne 0x6f64d
leaq 0x1b9947(%rip), %rax    # 0x228f3c
movb $0x1, (%rax)
leaq 0x2b7041(%rip), %rax    # 0x326640
movabsq $0x4e206c6574726f4e, %rcx # imm = 0x4E206C6574726F4E
movq %rcx, (%rax)
movl $0x585054, 0x8(%rax)    # imm = 0x585054
leaq 0x195a1e(%rip), %rax    # 0x205038
movl $0x3, (%rax)
leaq 0x195ce6(%rip), %rax    # 0x20530d
cmpb $0x0, (%rax)
jne 0x6f67e
leaq 0x195cd9(%rip), %rax    # 0x20530c
movb $0x0, (%rax)
jmp 0x6f67e
pushq $0x19
popq %r14
subl $0x1, %r14d
jb 0x6f5aa
callq 0x51c47
jmp 0x6f63c
cmpw $0x1, %bx
setne %sil
testl %edx, %edx
sete %dl
orb %sil, %dl
jne 0x6f67e
movl %eax, %edx
xorb $0x1, %dl
movb %dl, (%rcx)
cmpb $0x1, %al
jne 0x6f67e
leaq 0x1b98cb(%rip), %rax    # 0x228f3c
movb $0x0, (%rax)
leaq 0x1959bd(%rip), %rax    # 0x205038
andl $0x0, (%rax)
popq %rbx
popq %r14
popq %rbp
retq