// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %rbx
pushq %rax
leaq 0xa87d6(%rip), %rdi     # 0x1222ef
callq 0x58dc2
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x79b34
leaq 0x1c543f(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
cmpb $0x1, %al
jne 0x79c77
callq 0x588d2
movl %eax, %ebx
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x79b59
leaq 0x1c541a(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x79b6f
leaq 0x1c5404(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movzbl %al, %eax
leaq 0x2930df(%rip), %rcx    # 0x30cc58
movl %eax, (%rcx)
leaq 0x2930da(%rip), %rax    # 0x30cc5c
movl $0x1, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x79b9e
leaq 0x1c53d5(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movzbl %al, %eax
leaq 0x2930a8(%rip), %rcx    # 0x30cc50
movl %eax, (%rcx)
leaq 0x2930a3(%rip), %rax    # 0x30cc54
movl $0x1, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x79bcd
leaq 0x1c53a6(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
leaq 0x1c5367(%rip), %rax    # 0x23ef3b
cmpb $0x0, (%rax)
jne 0x79c99
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x79bf3
leaq 0x1c5380(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x79c09
leaq 0x1c536a(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x79c1f
leaq 0x1c5354(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x79c35
leaq 0x1c533e(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x79c4b
leaq 0x1c5328(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x79c61
leaq 0x1c5312(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x588d2
callq 0x588d2
callq 0x58a30
callq 0x58a30
jmp 0x79c99
movl $0x19, %r14d
leaq 0x1c52ec(%rip), %r15    # 0x23ef70
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x79c94
orb $0x8, (%r15)
decl %r14d
jne 0x79c84
xorl %edi, %edi
callq 0x58e9b
leaq 0x19ec29(%rip), %rax    # 0x2188d0
cmpq $0x1, (%rax)
jne 0x79cbd
leaq 0x1a1320(%rip), %rax    # 0x21afd4
cmpl $0x53, (%rax)
je 0x79d5b
leaq 0x1c5277(%rip), %rcx    # 0x23ef3b
movb (%rcx), %al
leaq 0x1c52a3(%rip), %rdx    # 0x23ef70
movl (%rdx), %edx
cmpw $0x1, %bx
jne 0x79d27
testb %al, %al
je 0x79d27
testl %edx, %edx
jne 0x79d27
leaq 0x1c5258(%rip), %rax    # 0x23ef3c
movb $0x1, (%rax)
leaq 0x2c2952(%rip), %rax    # 0x33c640
movabsq $0x4e206c6574726f4e, %rcx # imm = 0x4E206C6574726F4E
movq %rcx, (%rax)
movl $0x585054, 0x8(%rax)    # imm = 0x585054
leaq 0x1a132f(%rip), %rax    # 0x21b038
movl $0x3, (%rax)
leaq 0x1a15f7(%rip), %rax    # 0x21b30d
cmpb $0x0, (%rax)
jne 0x79d5b
leaq 0x1a15ea(%rip), %rax    # 0x21b30c
movb $0x0, (%rax)
jmp 0x79d5b
cmpw $0x1, %bx
setne %sil
testl %edx, %edx
sete %dl
orb %sil, %dl
jne 0x79d5b
movl %eax, %edx
xorb $0x1, %dl
movb %dl, (%rcx)
cmpb $0x1, %al
jne 0x79d5b
leaq 0x1c51f1(%rip), %rax    # 0x23ef3c
movb $0x0, (%rax)
leaq 0x1a12e3(%rip), %rax    # 0x21b038
movl $0x0, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq