// File: /workspace/github_cpp_makefile_star2_O1/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 0xa8483(%rip), %rdi     # 0x12220f
callq 0x58e77
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x79da7
leaq 0x1c51cc(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
cmpb $0x1, %al
jne 0x79eea
callq 0x588f0
movl %eax, %ebx
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x79dcc
leaq 0x1c51a7(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x79de2
leaq 0x1c5191(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movzbl %al, %eax
leaq 0x292e6c(%rip), %rcx    # 0x30cc58
movl %eax, (%rcx)
leaq 0x292e67(%rip), %rax    # 0x30cc5c
movl $0x1, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x79e11
leaq 0x1c5162(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movzbl %al, %eax
leaq 0x292e35(%rip), %rcx    # 0x30cc50
movl %eax, (%rcx)
leaq 0x292e30(%rip), %rax    # 0x30cc54
movl $0x1, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x79e40
leaq 0x1c5133(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
leaq 0x1c50f4(%rip), %rax    # 0x23ef3b
cmpb $0x0, (%rax)
jne 0x79f0c
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x79e66
leaq 0x1c510d(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x79e7c
leaq 0x1c50f7(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x79e92
leaq 0x1c50e1(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x79ea8
leaq 0x1c50cb(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x79ebe
leaq 0x1c50b5(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x79ed4
leaq 0x1c509f(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x588f0
callq 0x588f0
callq 0x58aae
callq 0x58aae
jmp 0x79f0c
movl $0x19, %r14d
leaq 0x1c5079(%rip), %r15    # 0x23ef70
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x79f07
orb $0x8, (%r15)
decl %r14d
jne 0x79ef7
xorl %edi, %edi
callq 0x58f50
leaq 0x19e9b6(%rip), %rax    # 0x2188d0
cmpq $0x1, (%rax)
sete %al
leaq 0x1a10ac(%rip), %rcx    # 0x21afd4
cmpl $0x53, (%rcx)
sete %dl
andb %al, %dl
jne 0x79f9c
leaq 0x1c5002(%rip), %rax    # 0x23ef3b
leaq 0x1c5030(%rip), %rcx    # 0x23ef70
cmpw $0x1, %bx
jne 0x79f98
cmpb $0x0, (%rax)
je 0x79f98
cmpl $0x0, (%rcx)
jne 0x79f98
leaq 0x1c4fe5(%rip), %rsi    # 0x23ef3c
movb $0x1, (%rsi)
leaq 0x2c26df(%rip), %rsi    # 0x33c640
movabsq $0x4e206c6574726f4e, %rdi # imm = 0x4E206C6574726F4E
movq %rdi, (%rsi)
movl $0x585054, 0x8(%rsi)    # imm = 0x585054
leaq 0x1a10bc(%rip), %rsi    # 0x21b038
movl $0x3, (%rsi)
leaq 0x1a1384(%rip), %rsi    # 0x21b30d
cmpb $0x0, (%rsi)
jne 0x79f98
leaq 0x1a1377(%rip), %rsi    # 0x21b30c
movb $0x0, (%rsi)
testb %dl, %dl
je 0x79fa7
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpw $0x1, %bx
jne 0x79f9c
cmpl $0x0, (%rcx)
je 0x79f9c
movb (%rax), %cl
movl %ecx, %edx
xorb $0x1, %dl
movb %dl, (%rax)
cmpb $0x1, %cl
jne 0x79f9c
leaq 0x1c4f75(%rip), %rax    # 0x23ef3c
movb $0x0, (%rax)
leaq 0x1a1067(%rip), %rax    # 0x21b038
movl $0x0, (%rax)
jmp 0x79f9c