// File: jkingan[P]ladyheather/heathgps.cpp
// Function: get_discipline_params()
void get_discipline_params()
{
u08 type;
float v1,v2,v3;
float v4,v5,v6,v7;
int osc_ok;

   log_packet_id("Packet 0x8F.A8 (Discipline params)");

   type = tsip_byte();

   if(type == 0) {
      v1 = tsip_single();
      v2 = tsip_single();
      if(STARLOC) ;
      else if(saw_ntpx) {
         v3 = tsip_single();
         v4 = tsip_single();
         v5 = tsip_single();
//sprintf(plot_title, "v: %f %f %f %f %f      ", v1,v2,v3,v4,v5);
      } 
      else if(try_nortel & 0x01) {
         v3 = tsip_single();
         v4 = tsip_single();
         v5 = tsip_single();
         v6 = tsip_single();
         v7 = tsip_single();
      }
      check_tsip_end(1);

      if(tsip_error) {
         try_nortel ^= 0x01;
         request_discipline_params(0x00);
         return;
      }

      time_constant = v1;
      have_tc = 0x01;

      damping_factor = v2;
      have_damp = 1;
      have_osc_params |= (PARAM_TC | PARAM_DAMP);

      if(STARLOC) ;
      else if(saw_ntpx) {
         osc_gain = v3;
         min_volts = v4;
         max_volts = v5;
         have_minv = have_maxv = 1;
         have_osc_params |= (PARAM_GAIN | PARAM_MINV | PARAM_MAXV);
      }
      else if(try_nortel & 0x01) {
         osc_gain = v3;
         min_volts = v4;
         max_volts = v5;
         have_minv = have_maxv = 1;
         have_osc_params |= (PARAM_GAIN | PARAM_MINV | PARAM_MAXV);

         jam_sync = v6;
         have_jam_sync = 1;
         max_freq_offset = v7;
         have_freq_ofs = 1;
         have_osc_params |= (PARAM_JAMSYNC | PARAM_MAXFREQ);

         saw_nortel |= 0x01;
         strcpy(unit_name, "Nortel NTGS/NTBW"); 
         saw_gpsdo = 4;
         if(user_set_temp_filter == 0) undo_fw_temp_filter = 0;
      }
   }
   else if(type == 1) {
      v1 = tsip_single();
      v2 = tsip_single();
      v3 = tsip_single();
      if(STARLOC) ;
      else if(try_nortel & 0x02) {
         v4 = tsip_single();
         v5 = tsip_single();
      }
      check_tsip_end(1);
      if(tsip_error) {
         try_nortel ^= 0x02;
         request_discipline_params(0x01);
         return;
      }
      if(pause_data) return;   // in case reading log file,  we don't want to change the OSC_GAIN
                               // since the user may be calculating osc parameters
      gain_color = WHITE;
      osc_gain = v1;
      have_gain = 1;
      min_volts = v2;
      max_volts = v3;
      have_minv = have_maxv = 1;
      have_osc_params |= (PARAM_GAIN | PARAM_MINV | PARAM_MAXV);

      if(STARLOC);
      else if(try_nortel & 0x02) {
         jam_sync = v4;
         have_jam_sync = 1;
         max_freq_offset = v5;
         have_freq_ofs = 1;
         saw_nortel |= 0x02;
         strcpy(unit_name, "Nortel NTGS/NTBW"); 
         saw_gpsdo = 5;
         have_osc_params |= (PARAM_JAMSYNC | PARAM_MAXFREQ);
         if(user_set_temp_filter == 0) undo_fw_temp_filter = 0;
      }
   }
   else if(saw_ntpx) {  // packets 2,3,4 have no data
      check_tsip_end(1);
      if(tsip_error) return;
   }
   else if(type == 2) {
      v1 = tsip_single();
      v2 = tsip_single();
      check_tsip_end(1);
      if(tsip_error) return;

      jam_sync = v1;
      have_jam_sync = 1;
      max_freq_offset = v2;
      have_freq_ofs = 1;
      have_osc_params |= (PARAM_JAMSYNC | PARAM_MAXFREQ);
   }
   else if(type == 3) {
      v1 = tsip_single();
      check_tsip_end(1);
      if(tsip_error) return;

      initial_voltage = v1;
      have_initv = 1;
      have_osc_params |= (PARAM_INITV);
   }
   else if(type == 4) {     // undocumented - allowable dac range?
      v1 = tsip_single();
      v2 = tsip_single();
      check_tsip_end(1);
      if(tsip_error) return;

      min_dac_v = v1;
      max_dac_v = v2;
      have_dac_range = 1;
      have_osc_params |= (PARAM_MINRANGE | PARAM_MAXRANGE);
   }
   else {
      check_tsip_end(1);
      if(tsip_error) return;
   }

   if((have_osc_params & PARAM_TBOLT) == PARAM_TBOLT) {  // !!!!! 0x0F: we have all osc params available
      osc_ok = 1;
   }
   else if(saw_ntpx && ((have_osc_params & PARAM_NTPX) == PARAM_NTPX)) {
      osc_ok = 1;
   }
   else osc_ok = 0;


   if(1 && user_set_osc_param && osc_ok) {  // set osc params from command line values
      update_osc_params();
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
leaq 0xe3dd7(%rip), %rdi     # 0x185356
callq 0x7add0
callq 0x7a510
movb %al, -0x1(%rbp)
movzbl -0x1(%rbp), %eax
cmpl $0x0, %eax
jne 0xa1890
callq 0x7a860
movss %xmm0, -0x8(%rbp)
callq 0x7a860
movss %xmm0, -0xc(%rbp)
leaq 0x1d64fc(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0xa15c8
leaq 0x1d8bf3(%rip), %rax    # 0x27a1b4
cmpl $0x53, (%rax)
jne 0xa15c8
jmp 0xa1639
leaq 0x1fcb4d(%rip), %rax    # 0x29e11c
cmpb $0x0, (%rax)
je 0xa15f4
callq 0x7a860
movss %xmm0, -0x10(%rbp)
callq 0x7a860
movss %xmm0, -0x14(%rbp)
callq 0x7a860
movss %xmm0, -0x18(%rbp)
jmp 0xa1637
movzbl 0x329a01(%rip), %eax    # 0x3caffc
andl $0x1, %eax
cmpl $0x0, %eax
je 0xa1635
callq 0x7a860
movss %xmm0, -0x10(%rbp)
callq 0x7a860
movss %xmm0, -0x14(%rbp)
callq 0x7a860
movss %xmm0, -0x18(%rbp)
callq 0x7a860
movss %xmm0, -0x1c(%rbp)
callq 0x7a860
movss %xmm0, -0x20(%rbp)
jmp 0xa1637
jmp 0xa1639
movl $0x1, %edi
callq 0x7aee0
leaq 0x1fcb06(%rip), %rax    # 0x29e150
cmpl $0x0, (%rax)
je 0xa166b
movzbl 0x3299a6(%rip), %eax    # 0x3caffc
xorl $0x1, %eax
movb %al, 0x32999d(%rip)     # 0x3caffc
xorl %edi, %edi
callq 0x99aa0
jmp 0xa1ce6
movss -0x8(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2cac55(%rip), %rax    # 0x36c2d0
movsd %xmm0, (%rax)
leaq 0x2cae4a(%rip), %rax    # 0x36c4d0
movl $0x1, (%rax)
movss -0xc(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2cac44(%rip), %rax    # 0x36c2e0
movsd %xmm0, (%rax)
leaq 0x2cae2d(%rip), %rax    # 0x36c4d4
movl $0x1, (%rax)
leaq 0x2cb928(%rip), %rax    # 0x36cfdc
movl (%rax), %ecx
orl $0x3, %ecx
leaq 0x2cb91c(%rip), %rax    # 0x36cfdc
movl %ecx, (%rax)
leaq 0x1d63e7(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0xa16e0
leaq 0x1d8ade(%rip), %rax    # 0x27a1b4
cmpl $0x53, (%rax)
jne 0xa16e0
jmp 0xa188b
leaq 0x1fca35(%rip), %rax    # 0x29e11c
cmpb $0x0, (%rax)
je 0xa175c
movss -0x10(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2cabec(%rip), %rax    # 0x36c2e8
movsd %xmm0, (%rax)
movss -0x14(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2cabf0(%rip), %rax    # 0x36c300
movsd %xmm0, (%rax)
movss -0x18(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2cabe4(%rip), %rax    # 0x36c308
movsd %xmm0, (%rax)
leaq 0x2cadb9(%rip), %rax    # 0x36c4e8
movl $0x1, (%rax)
leaq 0x2cada8(%rip), %rax    # 0x36c4e4
movl $0x1, (%rax)
leaq 0x2cb893(%rip), %rax    # 0x36cfdc
movl (%rax), %ecx
orl $0x34, %ecx
leaq 0x2cb887(%rip), %rax    # 0x36cfdc
movl %ecx, (%rax)
jmp 0xa1889
movzbl 0x329899(%rip), %eax    # 0x3caffc
andl $0x1, %eax
cmpl $0x0, %eax
je 0xa1887
movss -0x10(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2cab69(%rip), %rax    # 0x36c2e8
movsd %xmm0, (%rax)
movss -0x14(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2cab6d(%rip), %rax    # 0x36c300
movsd %xmm0, (%rax)
movss -0x18(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2cab61(%rip), %rax    # 0x36c308
movsd %xmm0, (%rax)
leaq 0x2cad36(%rip), %rax    # 0x36c4e8
movl $0x1, (%rax)
leaq 0x2cad25(%rip), %rax    # 0x36c4e4
movl $0x1, (%rax)
leaq 0x2cb810(%rip), %rax    # 0x36cfdc
movl (%rax), %ecx
orl $0x34, %ecx
leaq 0x2cb804(%rip), %rax    # 0x36cfdc
movl %ecx, (%rax)
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2cab36(%rip), %rax    # 0x36c320
movsd %xmm0, (%rax)
leaq 0x2cacfb(%rip), %rax    # 0x36c4f0
movl $0x1, (%rax)
movss -0x20(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2cab1d(%rip), %rax    # 0x36c328
movsd %xmm0, (%rax)
leaq 0x2cacde(%rip), %rax    # 0x36c4f4
movl $0x1, (%rax)
leaq 0x2cb7b9(%rip), %rax    # 0x36cfdc
movl (%rax), %ecx
orl $0x600, %ecx            # imm = 0x600
leaq 0x2cb7aa(%rip), %rax    # 0x36cfdc
movl %ecx, (%rax)
leaq 0x1fc8df(%rip), %rax    # 0x29e11a
movzbl (%rax), %eax
orl $0x1, %eax
movb %al, %cl
leaq 0x1fc8d0(%rip), %rax    # 0x29e11a
movb %cl, (%rax)
leaq 0x2f9fcd(%rip), %rdi    # 0x39b820
leaq 0xeff45(%rip), %rsi     # 0x19179f
callq 0x9350
leaq 0x1d89b2(%rip), %rax    # 0x27a218
movl $0x4, (%rax)
leaq 0x1d8c7a(%rip), %rax    # 0x27a4ed
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0xa1885
leaq 0x1d8c6a(%rip), %rax    # 0x27a4ec
movb $0x0, (%rax)
jmp 0xa1887
jmp 0xa1889
jmp 0xa188b
jmp 0xa1c86
movzbl -0x1(%rbp), %eax
cmpl $0x1, %eax
jne 0xa1aab
callq 0x7a860
movss %xmm0, -0x8(%rbp)
callq 0x7a860
movss %xmm0, -0xc(%rbp)
callq 0x7a860
movss %xmm0, -0x10(%rbp)
leaq 0x1d61ee(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0xa18d6
leaq 0x1d88e5(%rip), %rax    # 0x27a1b4
cmpl $0x53, (%rax)
jne 0xa18d6
jmp 0xa18fb
movzbl 0x32971f(%rip), %eax    # 0x3caffc
andl $0x2, %eax
cmpl $0x0, %eax
je 0xa18f9
callq 0x7a860
movss %xmm0, -0x14(%rbp)
callq 0x7a860
movss %xmm0, -0x18(%rbp)
jmp 0xa18fb
movl $0x1, %edi
callq 0x7aee0
leaq 0x1fc844(%rip), %rax    # 0x29e150
cmpl $0x0, (%rax)
je 0xa1930
movzbl 0x3296e4(%rip), %eax    # 0x3caffc
xorl $0x2, %eax
movb %al, 0x3296db(%rip)     # 0x3caffc
movl $0x1, %edi
callq 0x99aa0
jmp 0xa1ce6
leaq 0x1d8add(%rip), %rax    # 0x27a414
cmpb $0x0, (%rax)
je 0xa1941
jmp 0xa1ce6
leaq 0x2caa00(%rip), %rax    # 0x36c348
movl $0xf, (%rax)
movss -0x8(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2ca98a(%rip), %rax    # 0x36c2e8
movsd %xmm0, (%rax)
leaq 0x2cab6f(%rip), %rax    # 0x36c4d8
movl $0x1, (%rax)
movss -0xc(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2ca981(%rip), %rax    # 0x36c300
movsd %xmm0, (%rax)
movss -0x10(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2ca975(%rip), %rax    # 0x36c308
movsd %xmm0, (%rax)
leaq 0x2cab4a(%rip), %rax    # 0x36c4e8
movl $0x1, (%rax)
leaq 0x2cab39(%rip), %rax    # 0x36c4e4
movl $0x1, (%rax)
leaq 0x2cb624(%rip), %rax    # 0x36cfdc
movl (%rax), %ecx
orl $0x34, %ecx
leaq 0x2cb618(%rip), %rax    # 0x36cfdc
movl %ecx, (%rax)
leaq 0x1d60e3(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0xa19e4
leaq 0x1d87da(%rip), %rax    # 0x27a1b4
cmpl $0x53, (%rax)
jne 0xa19e4
jmp 0xa1aa6
movzbl 0x329611(%rip), %eax    # 0x3caffc
andl $0x2, %eax
cmpl $0x0, %eax
je 0xa1aa4
movss -0x14(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2ca919(%rip), %rax    # 0x36c320
movsd %xmm0, (%rax)
leaq 0x2caade(%rip), %rax    # 0x36c4f0
movl $0x1, (%rax)
movss -0x18(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2ca900(%rip), %rax    # 0x36c328
movsd %xmm0, (%rax)
leaq 0x2caac1(%rip), %rax    # 0x36c4f4
movl $0x1, (%rax)
leaq 0x1fc6da(%rip), %rax    # 0x29e11a
movzbl (%rax), %eax
orl $0x2, %eax
movb %al, %cl
leaq 0x1fc6cb(%rip), %rax    # 0x29e11a
movb %cl, (%rax)
leaq 0x2f9dc8(%rip), %rdi    # 0x39b820
leaq 0xefd40(%rip), %rsi     # 0x19179f
callq 0x9350
leaq 0x1d87ad(%rip), %rax    # 0x27a218
movl $0x5, (%rax)
leaq 0x2cb564(%rip), %rax    # 0x36cfdc
movl (%rax), %ecx
orl $0x600, %ecx            # imm = 0x600
leaq 0x2cb555(%rip), %rax    # 0x36cfdc
movl %ecx, (%rax)
leaq 0x1d8a5d(%rip), %rax    # 0x27a4ed
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0xa1aa2
leaq 0x1d8a4d(%rip), %rax    # 0x27a4ec
movb $0x0, (%rax)
jmp 0xa1aa4
jmp 0xa1aa6
jmp 0xa1c84
leaq 0x1fc66a(%rip), %rax    # 0x29e11c
cmpb $0x0, (%rax)
je 0xa1ad7
movl $0x1, %edi
callq 0x7aee0
leaq 0x1fc688(%rip), %rax    # 0x29e150
cmpl $0x0, (%rax)
je 0xa1ad2
jmp 0xa1ce6
jmp 0xa1c82
movzbl -0x1(%rbp), %eax
cmpl $0x2, %eax
jne 0xa1b72
callq 0x7a860
movss %xmm0, -0x8(%rbp)
callq 0x7a860
movss %xmm0, -0xc(%rbp)
movl $0x1, %edi
callq 0x7aee0
leaq 0x1fc647(%rip), %rax    # 0x29e150
cmpl $0x0, (%rax)
je 0xa1b13
jmp 0xa1ce6
movss -0x8(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2ca7fd(%rip), %rax    # 0x36c320
movsd %xmm0, (%rax)
leaq 0x2ca9c2(%rip), %rax    # 0x36c4f0
movl $0x1, (%rax)
movss -0xc(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2ca7e4(%rip), %rax    # 0x36c328
movsd %xmm0, (%rax)
leaq 0x2ca9a5(%rip), %rax    # 0x36c4f4
movl $0x1, (%rax)
leaq 0x2cb480(%rip), %rax    # 0x36cfdc
movl (%rax), %ecx
orl $0x600, %ecx            # imm = 0x600
leaq 0x2cb471(%rip), %rax    # 0x36cfdc
movl %ecx, (%rax)
jmp 0xa1c80
movzbl -0x1(%rbp), %eax
cmpl $0x3, %eax
jne 0xa1bdb
callq 0x7a860
movss %xmm0, -0x8(%rbp)
movl $0x1, %edi
callq 0x7aee0
leaq 0x1fc5ba(%rip), %rax    # 0x29e150
cmpl $0x0, (%rax)
je 0xa1ba0
jmp 0xa1ce6
movss -0x8(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2ca780(%rip), %rax    # 0x36c330
movsd %xmm0, (%rax)
leaq 0x2ca925(%rip), %rax    # 0x36c4e0
movl $0x1, (%rax)
leaq 0x2cb414(%rip), %rax    # 0x36cfdc
movl (%rax), %ecx
orl $0x8, %ecx
leaq 0x2cb408(%rip), %rax    # 0x36cfdc
movl %ecx, (%rax)
jmp 0xa1c7e
movzbl -0x1(%rbp), %eax
cmpl $0x4, %eax
jne 0xa1c62
callq 0x7a860
movss %xmm0, -0x8(%rbp)
callq 0x7a860
movss %xmm0, -0xc(%rbp)
movl $0x1, %edi
callq 0x7aee0
leaq 0x1fc547(%rip), %rax    # 0x29e150
cmpl $0x0, (%rax)
je 0xa1c13
jmp 0xa1ce6
movss -0x8(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2ca6ed(%rip), %rax    # 0x36c310
movsd %xmm0, (%rax)
movss -0xc(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2ca6e1(%rip), %rax    # 0x36c318
movsd %xmm0, (%rax)
leaq 0x2ca8aa(%rip), %rax    # 0x36c4ec
movl $0x1, (%rax)
leaq 0x2cb38d(%rip), %rax    # 0x36cfdc
movl (%rax), %ecx
orl $0x1800, %ecx           # imm = 0x1800
leaq 0x2cb37e(%rip), %rax    # 0x36cfdc
movl %ecx, (%rax)
jmp 0xa1c7c
movl $0x1, %edi
callq 0x7aee0
leaq 0x1fc4dd(%rip), %rax    # 0x29e150
cmpl $0x0, (%rax)
je 0xa1c7a
jmp 0xa1ce6
jmp 0xa1c7c
jmp 0xa1c7e
jmp 0xa1c80
jmp 0xa1c82
jmp 0xa1c84
jmp 0xa1c86
leaq 0x2cb34f(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x3f, %eax
cmpl $0x3f, %eax
jne 0xa1ca0
movl $0x1, -0x24(%rbp)
jmp 0xa1ccf
leaq 0x1fc475(%rip), %rax    # 0x29e11c
cmpb $0x0, (%rax)
je 0xa1cc6
leaq 0x2cb329(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x37, %eax
cmpl $0x37, %eax
jne 0xa1cc6
movl $0x1, -0x24(%rbp)
jmp 0xa1ccd
movl $0x0, -0x24(%rbp)
jmp 0xa1ccf
leaq 0x2cb302(%rip), %rax    # 0x36cfd8
cmpl $0x0, (%rax)
je 0xa1ce6
cmpl $0x0, -0x24(%rbp)
je 0xa1ce6
callq 0x971f0
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)