// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
cmpl $0x6, %edi
je 0x8cf22
cmpl $0x8, %ebx
jne 0x8cf45
leaq 0x81e16(%rip), %rdi     # 0x10ed36
jmp 0x8cf4c
leaq 0x81dfb(%rip), %rdi     # 0x10ed24
callq 0x520bf
leaq 0x26a2df(%rip), %rax    # 0x2f7214
cmpl $0x0, (%rax)
je 0x8cf51
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x81dfc(%rip), %rdi     # 0x10ed48
callq 0x520bf
leaq 0x1780cc(%rip), %rax    # 0x205024
cmpl %ebx, (%rax)
je 0x8cf63
movl %ebx, (%rax)
callq 0x43898
callq 0x51c47
callq 0x51c47
movzbl %al, %eax
leaq 0x178149(%rip), %rcx    # 0x2050c0
movl %eax, (%rcx)
leaq 0x26a448(%rip), %rax    # 0x2f73c8
pushq $0x1
popq %r15
movl %r15d, (%rax)
callq 0x51c63
movzwl %ax, %eax
leaq 0x17812e(%rip), %rcx    # 0x2050c4
movl %eax, (%rcx)
callq 0x51c47
leaq 0x26ad7e(%rip), %rcx    # 0x2f7d22
movb %al, (%rcx)
leaq 0x26ad73(%rip), %rcx    # 0x2f7d20
movb %al, (%rcx)
leaq 0x26a326(%rip), %rax    # 0x2f72dc
pushq $0x6
popq %rcx
movl %ecx, (%rax)
leaq 0x26a32a(%rip), %rax    # 0x2f72ec
movl %ecx, (%rax)
callq 0x51c47
callq 0x51c47
callq 0x51c47
callq 0x51c47
callq 0x51c47
callq 0x51c63
callq 0x51c47
callq 0x51c47
callq 0x51c47
callq 0x51c47
callq 0x51c47
callq 0x51c47
movzbl %al, %eax
leaq 0x1780be(%rip), %rcx    # 0x2050c8
movl %eax, (%rcx)
callq 0x51c47
callq 0x51c63
movl %eax, %r14d
callq 0x51c47
movzbl %al, %eax
leal -0x100(%rax), %ecx
testb %al, %al
cmovnsl %eax, %ecx
cvtsi2ss %ecx, %xmm0
leaq 0x26a38d(%rip), %rax    # 0x2f73c4
cvtss2sd %xmm0, %xmm0
leaq 0x2699be(%rip), %rcx    # 0x2f6a00
movsd %xmm0, (%rcx)
movswl %r14w, %ecx
cvtsi2sd %ecx, %xmm0
movl %r15d, (%rax)
leaq 0x269760(%rip), %rax    # 0x2f67b8
movsd %xmm0, (%rax)
leaq 0x26a1d5(%rip), %rax    # 0x2f7238
pushq $0x5
popq %rcx
movl %ecx, (%rax)
leaq 0x26a1d5(%rip), %rax    # 0x2f7244
movl %ecx, (%rax)
xorl %r14d, %r14d
testl %ebx, %ebx
cmovgl %ebx, %r14d
subl $0x1, %r14d
jb 0x8cf3a
callq 0x51c47
callq 0x51cf3
jmp 0x8d07a