// File: jkingan[P]ladyheather/heathgps.cpp
// Function: parse_moto_En(int)
void parse_moto_En(int num_chans)
{
int i;
S32 sawtooth;
s16 accu;

   if(num_chans == 6)      log_packet_id("6-chan traim info");
   else if(num_chans == 8) log_packet_id("8-chan traim info");
   else                    log_packet_id("unkn-chans traim info");

   if((num_chans == 6) && have_moto_En) return;

   if(num_chans != moto_chans) {
      moto_chans = num_chans;
      config_msg_ofs();
   }

   tsip_byte();  // output rate
   traim_mode = tsip_byte();
   have_traim = 1;
   traim_threshold = tsip_word();
   pps_enabled = pps_mode = tsip_byte();  // 0=off, 1=always on,  2=on when tracking, 3=on when traim met
   have_pps_enable = 6;
   have_pps_mode = 6;

   tsip_byte();  // pps rate   // !!!!! have_pps_rate
   tsip_byte();
   tsip_byte();

   tsip_byte();  // next pps time
   tsip_byte();
   tsip_word();
   tsip_byte();
   tsip_byte();
   tsip_byte();

   tsip_byte();  // pps status (=0off, 1=enabled)
   tsip_byte();  // 0=sync to UTC  1=sync to GPS
   traim_status = tsip_byte();
   tsip_byte();

   accu = tsip_word();     // time accuracy
   sawtooth = tsip_byte(); // sawtooth
   if(sawtooth & 0x80) sawtooth |= (~(S32)0xFF);
   have_sawtooth = 1;

   dac_voltage = (float) sawtooth;
   pps_offset = (double) accu;
   have_pps_offset = 5;
   have_rcvr_pps = 5;
//adadad   if(jitter_adev == 0) do_pps_adev(pps_offset);

   for(i=0; i<num_chans; i++) {
      tsip_byte();  // prn
      tsip_dword(); // time fraction
   }
//sprintf(debug_text2, "En: thresh:%d tmode:%d tstat:%d  pps:%d  saw:%d  rate:%d   ", 
//traim_threshold,traim_mode,traim_status,pps_mode,sawtooth,pps_rate);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %edi, -0x4(%rbp)
cmpl $0x6, -0x4(%rbp)
jne 0xd35ff
leaq 0xb4ad0(%rip), %rdi     # 0x1880c8
callq 0x7add0
jmp 0xd3621
cmpl $0x8, -0x4(%rbp)
jne 0xd3613
leaq 0xb4ace(%rip), %rdi     # 0x1880da
callq 0x7add0
jmp 0xd361f
leaq 0xb4ad2(%rip), %rdi     # 0x1880ec
callq 0x7add0
jmp 0xd3621
cmpl $0x6, -0x4(%rbp)
jne 0xd3638
leaq 0x298dc6(%rip), %rax    # 0x36c3f4
cmpl $0x0, (%rax)
je 0xd3638
jmp 0xd37a9
movl -0x4(%rbp), %eax
leaq 0x1a6bc2(%rip), %rcx    # 0x27a204
cmpl (%rcx), %eax
je 0xd3657
movl -0x4(%rbp), %ecx
leaq 0x1a6bb4(%rip), %rax    # 0x27a204
movl %ecx, (%rax)
callq 0x63c20
callq 0x7a510
callq 0x7a510
movzbl %al, %ecx
leaq 0x1a6c35(%rip), %rax    # 0x27a2a0
movl %ecx, (%rax)
leaq 0x298f34(%rip), %rax    # 0x36c5a8
movl $0x1, (%rax)
callq 0x7a560
movzwl %ax, %ecx
leaq 0x1a6c1b(%rip), %rax    # 0x27a2a4
movl %ecx, (%rax)
callq 0x7a510
movb %al, %cl
leaq 0x299869(%rip), %rax    # 0x36cf02
movb %cl, (%rax)
leaq 0x29985e(%rip), %rax    # 0x36cf00
movb %cl, (%rax)
leaq 0x298e11(%rip), %rax    # 0x36c4bc
movl $0x6, (%rax)
leaq 0x298e14(%rip), %rax    # 0x36c4cc
movl $0x6, (%rax)
callq 0x7a510
callq 0x7a510
callq 0x7a510
callq 0x7a510
callq 0x7a510
callq 0x7a560
callq 0x7a510
callq 0x7a510
callq 0x7a510
callq 0x7a510
callq 0x7a510
callq 0x7a510
movzbl %al, %ecx
leaq 0x1a6ba4(%rip), %rax    # 0x27a2a8
movl %ecx, (%rax)
callq 0x7a510
callq 0x7a560
movw %ax, -0xe(%rbp)
callq 0x7a510
movzbl %al, %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0xd3737
movl -0xc(%rbp), %eax
orl $0xffffff00, %eax       # imm = 0xFFFFFF00
movl %eax, -0xc(%rbp)
leaq 0x298e66(%rip), %rax    # 0x36c5a4
movl $0x1, (%rax)
cvtsi2ssl -0xc(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x29848c(%rip), %rax    # 0x36bbe0
movsd %xmm0, (%rax)
movswl -0xe(%rbp), %eax
cvtsi2sd %eax, %xmm0
leaq 0x298231(%rip), %rax    # 0x36b998
movsd %xmm0, (%rax)
leaq 0x298ca6(%rip), %rax    # 0x36c418
movl $0x5, (%rax)
leaq 0x298ca5(%rip), %rax    # 0x36c424
movl $0x5, (%rax)
movl $0x0, -0x8(%rbp)
movl -0x8(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0xd37a9
callq 0x7a510
callq 0x7a680
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0xd378c
addq $0x10, %rsp
popq %rbp
retq
nop