// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heathgps.cpp
// Function: set_pps_mode(int)
void set_pps_mode(int mode)
{
int old_rate;

   // mode 0x02 - 1PPS
   // mode 0x82 - PP2S / 100 pps mode (Motorola)
   // mode 0x83 - 10000 PPS mode / 100 pps mode (Brandywine)

   if(read_only) return;    // !!! Resolution-T only
   if(luxor) return;

   if(rcvr_type == BRANDY_RCVR) {
      if(brandy_pps_width < 0) {  // negative polarity
         if     (mode == 0x82) sprintf(out, "$PRCCG,C,P2000,%d", brandy_pps_width);  // PP2S
         else if(mode == 0x83) sprintf(out, "$PRCCG,C,P10,%d",   brandy_pps_width);  // 100 PPS
         else                  sprintf(out, "$PRCCG,C,P1000,%d", brandy_pps_width);
      }
      else {  // positive polarity
         if     (mode == 0x82) sprintf(out, "$PRCCG,C,P2000,+%d", brandy_pps_width);  // PP2S
         else if(mode == 0x83) sprintf(out, "$PRCCG,C,P10,+%d",   brandy_pps_width);  // 100 PPS
         else                  sprintf(out, "$PRCCG,C,P1000,+%d", brandy_pps_width);
      }
      queue_brandy_cmd(out, BRANDY_PULSE_MSG);
   }
   else if(rcvr_type == ESIP_RCVR) {
       old_rate = pps_rate;
       pps_rate = mode;
       set_pps(user_pps_enable, pps_polarity,  cable_delay, pps1_delay,  pps_threshold, 10);
       pps_rate = old_rate;
       have_pps_rate = 1;
   }
   else if(rcvr_type == MOTO_RCVR) {
//sprintf(debug_text, "set pps mode:%d  oldr:%d  oldm:%d", mode, pps_rate,pps_mode);
      send_moto_start("AP");
      if(mode == RATE_100PPS) send_byte(1);  // 100 pps
      else                    send_byte(0);  // 1 PPS
      send_moto_end();
   }
   else if(rcvr_type == STAR_RCVR) {  // !!!!! we use this to toggle the TOD output
      if(star_type == OSA_TYPE) {
         if(mode == RATE_NO_TOD) {  // disable TOD message
            queue_star_cmd("TOD_STATE=D", STAR_TOD_MSG);
         }
         else {
            queue_star_cmd("TOD_STATE=E", STAR_TOD_MSG);
         }
         queue_star_cmd("TOD_STATE", STAR_TOD_MSG);
      }
      else {
         if(mode == RATE_NO_TOD) {  // disable TOD message
            queue_star_cmd("TOD_STATE=0;", STAR_TOD_MSG);
         }
         else {
            queue_star_cmd("TOD_STATE=1;", STAR_TOD_MSG);
         }
         queue_star_cmd("TOD_STATE;", STAR_TOD_MSG);
      }
   }
   else if(rcvr_type == TSIP_RCVR) {
      if(ACU_GG) ;
      else if(ACU_360) ;
      else if(ACUTIME) ;
      else if(PALISADE) return;
      else if(SV6_FAMILY) return;
      send_tsip_start(0x8E);
      send_byte(0x4E);
      mode &= 0xFE;
      send_byte(mode);
      send_tsip_end();
   }
   else if(rcvr_type == UBX_RCVR) {
       old_rate = pps_rate;
       pps_rate = mode;
       set_pps(user_pps_enable, pps_polarity,  delay_value, pps1_delay,  pps_threshold, 10);
       pps_rate = old_rate;
       have_pps_rate = 1;
   }
   else if(rcvr_type == UCCM_RCVR) {
      if(mode == RATE_PP2S) queue_uccm_cmd("OUTP:TP:SEL PP2S", UCCM_RATE_MSG);
      else                  queue_uccm_cmd("OUTP:TP:SEL PP1S", UCCM_RATE_MSG);
      queue_uccm_cmd("OUTP:TP:SEL?", UCCM_RATE_MSG);
   }
   else if(rcvr_type == ZYFER_RCVR) {
      if(mode == RATE_PP2S) send_zyfer_cmd("$PULR,2");      // PP2S
      else if(mode == RATE_1PPS) send_zyfer_cmd("$PULR,1"); // PPS
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
leaq 0x2caced(%rip), %rax    # 0x33701a
leaq 0x1d2c0a(%rip), %rcx    # 0x23ef3e
movb (%rcx), %cl
orb (%rax), %cl
jne 0x6c4e6
movl %edi, %ebx
leaq 0x1ac589(%rip), %rax    # 0x2188d0
movq (%rax), %rax
cmpq $0xfff, %rax            # imm = 0xFFF
jg 0x6c39d
cmpq $0x7, %rax
jg 0x6c434
cmpq $0x1, %rax
je 0x6c4f1
cmpq $0x4, %rax
jne 0x6c4e6
leaq 0x2a19ac(%rip), %r14    # 0x30dd23
movb (%r14), %r15b
movb %bl, (%r14)
leaq 0x2a199d(%rip), %rax    # 0x30dd21
movzbl (%rax), %edi
leaq 0x2a198a(%rip), %rax    # 0x30dd18
movzbl (%rax), %esi
leaq 0x2a1a28(%rip), %rax    # 0x30ddc0
jmp 0x6c4b2
cmpq $0xfffff, %rax          # imm = 0xFFFFF
jg 0x6c474
cmpq $0x1000, %rax           # imm = 0x1000
je 0x6c567
cmpq $0x40000, %rax          # imm = 0x40000
jne 0x6c4e6
cmpl $0x83, %ebx
leaq 0xb4d4c(%rip), %rax     # 0x12111a
leaq 0xb4d55(%rip), %rcx     # 0x12112a
cmoveq %rax, %rcx
leaq 0xb4d6f(%rip), %rax     # 0x12114f
leaq 0xb4d79(%rip), %rdx     # 0x121160
cmoveq %rax, %rdx
cmpl $0x82, %ebx
leaq 0xb4d10(%rip), %rax     # 0x121108
cmovneq %rcx, %rax
leaq 0x2cfa55(%rip), %rcx    # 0x33be58
leaq 0xb4d32(%rip), %rsi     # 0x12113c
cmovneq %rdx, %rsi
movl (%rcx), %edx
testl %edx, %edx
cmovsq %rax, %rsi
leaq 0x2cfe03(%rip), %rbx    # 0x33c220
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
movl $0x191, %esi            # imm = 0x191
jmp 0x6c616
cmpq $0x8, %rax
je 0x6c59e
cmpq $0x20, %rax
jne 0x6c4e6
leaq 0x9e773(%rip), %rdi     # 0x10abc2
callq 0x61694
xorl %edi, %edi
cmpl $0x82, %ebx
sete %dil
callq 0x591af
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6170f
cmpq $0x100000, %rax         # imm = 0x100000
je 0x6c5ce
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
jne 0x6c4e6
leaq 0x2a1892(%rip), %r14    # 0x30dd23
movb (%r14), %r15b
movb %bl, (%r14)
leaq 0x2a1883(%rip), %rax    # 0x30dd21
movzbl (%rax), %edi
leaq 0x2a1870(%rip), %rax    # 0x30dd18
movzbl (%rax), %esi
leaq 0x2a1916(%rip), %rax    # 0x30ddc8
movsd (%rax), %xmm0
leaq 0x2a191b(%rip), %rax    # 0x30ddd8
movsd (%rax), %xmm1
leaq 0x2a1854(%rip), %rax    # 0x30dd1c
movss (%rax), %xmm2
movl $0xa, %edx
callq 0x6ad1d
movb %r15b, (%r14)
leaq 0x2a0df0(%rip), %rax    # 0x30d2d0
movl $0x1, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1aeadc(%rip), %rcx    # 0x21afd4
movl (%rcx), %ecx
movl %ecx, %esi
xorl $0x41, %esi
leaq 0x1ac3f2(%rip), %rdx    # 0x2188f8
movl (%rdx), %edx
movl %edx, %edi
xorl $0x47, %edi
orl %esi, %edi
je 0x6c537
cmpl $0x41, %ecx
jne 0x6c520
cmpl $0x33, %edx
je 0x6c537
cmpl $0x47, %edx
je 0x6c537
cmpl $0x41, %ecx
sete %dl
cmpq $0x1, %rax
sete %sil
testb %dl, %sil
je 0x6c63b
movl $0x8e, %edi
callq 0x5e740
movl $0x4e, %edi
callq 0x591af
andl $0xfe, %ebx
movl %ebx, %edi
callq 0x591af
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x5e7c0
leaq 0x1aea7a(%rip), %rax    # 0x21afe8
cmpl $0x4f, (%rax)
jne 0x6c5e8
cmpl $0x82, %ebx
leaq 0xb4bf3(%rip), %rax     # 0x121173
leaq 0xb4bf8(%rip), %rdi     # 0x12117f
cmoveq %rax, %rdi
movl $0xd5, %esi
callq 0x5ee52
leaq 0xb4bef(%rip), %rdi     # 0x12118b
jmp 0x6c611
cmpl $0x82, %ebx
leaq 0xb4c0f(%rip), %rax     # 0x1211ba
leaq 0xb4c19(%rip), %rdi     # 0x1211cb
cmoveq %rax, %rdi
movl $0x64, %esi
callq 0x5ee52
leaq 0xb4c15(%rip), %rdi     # 0x1211dc
movl $0x64, %esi
jmp 0x6c616
cmpl $0x2, %ebx
je 0x6c625
cmpl $0x82, %ebx
jne 0x6c4e6
leaq 0xb4c04(%rip), %rdi     # 0x1211ea
jmp 0x6c62c
cmpl $0x82, %ebx
leaq 0xb4ba0(%rip), %rax     # 0x121195
leaq 0xb4ba6(%rip), %rdi     # 0x1211a2
cmoveq %rax, %rdi
movl $0xd5, %esi
callq 0x5ee52
leaq 0xb4b9e(%rip), %rdi     # 0x1211af
movl $0xd5, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x5ee52
leaq 0xb4bc6(%rip), %rdi     # 0x1211f2
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x5f15d
cmpq $0x1, %rax
sete %dl
cmpl $0x50, %ecx
sete %sil
testb %sil, %dl
jne 0x6c4e6
cmpq $0x1, %rax
jne 0x6c537
addl $-0x33, %ecx
cmpl $0x1d, %ecx
ja 0x6c537
movl $0x20004009, %eax       # imm = 0x20004009
btl %ecx, %eax
jb 0x6c4e6
jmp 0x6c537