// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathgps.cpp
// Function: request_factory_reset()
void request_factory_reset()
{
   if(read_only) return;
   if(no_poll) return;

   reset_leap_flags();
   extend_com_timeout(0.0);

   if(luxor) {
      send_tsip_start(LUXOR_ID);   // erase EEPROM config
      send_byte(0x08);
      send_tsip_end();
      Sleep(100);

      request_cold_reset();
   }
   else if(rcvr_type == ACRON_RCVR) {
      need_acron_sync = 'h';
   }
   else if(rcvr_type == BRANDY_RCVR) {
      queue_brandy_cmd("$PRCCG,Z,0", BRANDY_RESET_MSG);
   }
   else if(rcvr_type == CS_RCVR) {
//    set_cs_remote(1);
      queue_cs_cmd("*RST", SCPI_NULL_MSG);
//    restore_cs_remote();

      queue_cs_cmd("DIAG:CONT:STAT?", CS_LAMP_MSG);
      queue_cs_cmd("DISP:ENAB?", CS_DISP_MSG);
      queue_cs_cmd("SYST:REM?", CS_REM_MSG);

      user_set_remote = 1;   // *RST forces remote mode
      cs_remote = 1;
   }
   else if(rcvr_type == ESIP_RCVR) {
      send_esip_cmd("PERDAPI,FLASHBACKUP,0x00");  // erase flash settings
      Sleep(2000);
      send_esip_cmd("PERDAPI,RESTART,FACTORY");
   }
   else if(rcvr_type == FURUNO_RCVR) {
      send_furuno_cmd("GPclr,1");
   }
   else if(rcvr_type == MOTO_RCVR) {
      send_moto_start("Cf");
      send_moto_end();
      rcvr_reset = 3;
//    restart_gpsdo();
//    Sleep(2000);
   }
   else if(rcvr_type == NVS_RCVR) {
      request_cold_reset();
   }
   else if(rcvr_type == PRS_RCVR) {
      queue_prs_cmd("RC1", PRS_RC_MSG);
   }
   else if(rcvr_type == RFTG_RCVR) {
      request_rftg_reset('H');
   }
   else if(rcvr_type == SCPI_RCVR) {
      if(scpi_type == NORTEL_TYPE) queue_scpi_cmd("SYST:PRESET", SCPI_RESET_MSG);
      else                         queue_scpi_cmd(":SYST:PRES", SCPI_RESET_MSG);
   }
   else if(rcvr_type == SRO_RCVR) {
      queue_sro_cmd("RESET", SRO_RESET_MSG);
   }
   else if(rcvr_type == SS_RCVR) {
      send_ss_start(2, 12);
      send_ss_string("UGPS-000");
      send_ss_end();
   }
   else if(rcvr_type == STAR_RCVR) {
      if(star_type == OSA_TYPE) queue_star_cmd("SET_DEFAULT", STAR_RESTART_MSG);
      else                      queue_star_cmd("RESTART(C);", STAR_RESTART_MSG);
   }
   else if(rcvr_type == TAIP_RCVR) {
      send_taip_cmd("SRTFACTORY");
   }
   else if(rcvr_type == TICC_RCVR) {
      set_ticc_config(RCVR_PORT, " X");   // reset config to factory defaults
Sleep(4000);
      get_ticc_config(RCVR_PORT);
   }
   else if(rcvr_type == TM4_RCVR) {
      send_tm4_cmd("#08,1");
   }
   else if(rcvr_type == TRUE_RCVR) {
      send_true_cmd("$FACT");    // factory reset unit
   }
   else if(rcvr_type == TSIP_RCVR) {
      send_tsip_start(0x1E);
      if(ACU_GG) send_byte('F');
      else if(ACU_360) send_byte('F');
      else if(ACUTIME) send_byte('F');
      else if(PALISADE) send_byte('F');
      else if(SV6_FAMILY) send_byte('K');
      else send_byte('F');
      send_tsip_end();
   }
   else if(rcvr_type == UBX_RCVR) {
      update_ubx_config(UBX_EE_ALL, 0x0000, UBX_EE_ALL);  // reset eeprom then re-load config from eeprom
      rcvr_reset = 4;
      Sleep(1000);
      init_messages(22, 1);
   }
   else if(rcvr_type == UCCM_RCVR) {
      queue_uccm_cmd("SYST:PRES", SCPI_RESET_MSG);
      queue_uccm_cmd("SYST:STAT?", UCCM_STATUS_MSG);
   }
   else if(rcvr_type == VENUS_RCVR) {
      send_venus_start(VENUS_FACTORY_RESET);
      send_byte(1);
      send_venus_end();
      Sleep(5000);
      init_messages(22, 1);
   }
   else if(rcvr_type == Z12_RCVR) {
      send_z12_cmd("PASHS,RST");
   }
   else if(rcvr_type == ZODIAC_RCVR) {
      send_zod_start(ZOD_REQ_RESTART, 8, 0);
      send_zod_seq();
      send_word(0x8007);
      send_zod_end();

      Sleep(10000);
      restart_zodiac_rcvr();
   }
   else if(rcvr_type == ZYFER_RCVR) {
      send_zyfer_cmd("$FACTORYRESET");
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
leaq 0x2d1f83(%rip), %rax    # 0x33701a
leaq 0x2d1f82(%rip), %rcx    # 0x337020
movb (%rcx), %cl
orb (%rax), %cl
je 0x650ab
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x2a8137(%rip), %rax    # 0x30d1e9
movb $0x0, (%rax)
leaq 0x2a8124(%rip), %rax    # 0x30d1e0
movl $0x0, (%rax)
leaq 0x2a810f(%rip), %rax    # 0x30d1d8
andb $0x7f, (%rax)
xorps %xmm0, %xmm0
callq 0x63ce2
leaq 0x1d9e63(%rip), %rax    # 0x23ef3e
cmpb $0x0, (%rax)
je 0x6510e
movl $0xdc, %edi
callq 0x5e6be
movl $0x8, %edi
callq 0x590f7
callq 0x5e73c
movl $0x64, %edi
callq 0xafe8
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x63fa7
leaq 0x1b37bb(%rip), %rbx    # 0x2188d0
movq (%rbx), %rax
cmpq $0x1ffff, %rax          # imm = 0x1FFFF
jg 0x65176
cmpq $0xff, %rax
jg 0x651c4
cmpq $0xf, %rax
jg 0x6526c
cmpq $0x1, %rax
je 0x65455
cmpq $0x4, %rax
je 0x65399
cmpq $0x8, %rax
jne 0x650a4
leaq 0xbb6e5(%rip), %rdi     # 0x120840
movl $0x14, %esi
callq 0x5edda
leaq 0xbf022(%rip), %rdi     # 0x12418e
movl $0x65, %esi
jmp 0x655fd
cmpq $0x7ffffff, %rax        # imm = 0x7FFFFFF
jg 0x65210
cmpq $0x1fffff, %rax         # imm = 0x1FFFFF
jg 0x652b4
cmpq $0x20000, %rax          # imm = 0x20000
je 0x654cc
cmpq $0x40000, %rax          # imm = 0x40000
je 0x653d6
cmpq $0x100000, %rax         # imm = 0x100000
jne 0x650a4
leaq 0xbb6c8(%rip), %rdi     # 0x120881
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5f0e5
cmpq $0x3fff, %rax           # imm = 0x3FFF
jg 0x652e9
cmpq $0x100, %rax            # imm = 0x100
je 0x6552c
cmpq $0x800, %rax            # imm = 0x800
je 0x65103
cmpq $0x1000, %rax           # imm = 0x1000
jne 0x650a4
leaq 0x1b5ded(%rip), %rax    # 0x21afe8
cmpl $0x4f, (%rax)
jne 0x655f1
leaq 0xbb648(%rip), %rdi     # 0x120853
jmp 0x655f8
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
jg 0x6533a
cmpq $0x8000000, %rax        # imm = 0x8000000
je 0x6558d
cmpq $0x20000000, %rax       # imm = 0x20000000
je 0x653e7
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
jne 0x650a4
leaq 0xbb5a8(%rip), %rdi     # 0x1207f3
callq 0x5ee9b
movl $0x7d0, %edi            # imm = 0x7D0
callq 0xafe8
leaq 0xbb5ab(%rip), %rdi     # 0x12080c
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5ee9b
cmpq $0x10, %rax
je 0x6559b
cmpq $0x20, %rax
je 0x653f9
cmpq $0x80, %rax
jne 0x650a4
movl $0x4, %edi
movl $0x2, %esi
callq 0x5fb3c
movl $0x1, %edi
callq 0x590f7
callq 0x61bc1
movl $0x1388, %edi           # imm = 0x1388
jmp 0x653bc
cmpq $0x200000, %rax         # imm = 0x200000
je 0x655b0
cmpq $0x400000, %rax         # imm = 0x400000
je 0x6541c
cmpq $0x1000000, %rax        # imm = 0x1000000
jne 0x650a4
leaq 0xbb550(%rip), %rdi     # 0x12082f
movl $0x1f4, %esi            # imm = 0x1F4
jmp 0x655fd
cmpq $0x4000, %rax           # imm = 0x4000
je 0x655c2
cmpq $0x8000, %rax           # imm = 0x8000
je 0x65427
cmpq $0x10000, %rax          # imm = 0x10000
jne 0x650a4
leaq 0xa846c(%rip), %rsi     # 0x10d780
movl $0xa, %edi
callq 0x64550
movl $0xfa0, %edi            # imm = 0xFA0
callq 0xafe8
movl $0xa, %edi
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x64550
movabsq $0x100000000, %rcx      # imm = 0x100000000
cmpq %rcx, %rax
je 0x655d1
movabsq $0x400000000, %rcx      # imm = 0x400000000
cmpq %rcx, %rax
je 0x65443
movabsq $0x800000000, %rcx      # imm = 0x800000000
cmpq %rcx, %rax
jne 0x650a4
movl $0x2, %edi
movl $0xc, %esi
callq 0x65608
leaq 0xbb4c1(%rip), %rdi     # 0x12084a
callq 0x6564e
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x65696
movl $0x41f, %edi            # imm = 0x41F
xorl %esi, %esi
movl $0x41f, %edx            # imm = 0x41F
callq 0x619b5
leaq 0x1b5c77(%rip), %rax    # 0x21b028
movl $0x4, (%rax)
movl $0x3e8, %edi            # imm = 0x3E8
callq 0xafe8
movl $0x16, %edi
movl $0x1, %esi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x616de
leaq 0xbb31f(%rip), %rdi     # 0x1206fc
movl $0x1a4, %esi            # imm = 0x1A4
jmp 0x655fd
leaq 0xbb436(%rip), %rdi     # 0x120824
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5eff8
leaq 0xbb42c(%rip), %rdi     # 0x12082c
callq 0x6160d
callq 0x61688
leaq 0x1b5c17(%rip), %rax    # 0x21b028
movl $0x3, (%rax)
jmp 0x650a4
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x644f4
leaq 0xbb431(%rip), %rdi     # 0x12085f
callq 0xa3914
movl $0x1, %edi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0xa39a0
leaq 0xbb420(%rip), %rdi     # 0x12086a
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5f170
movl $0x1e, %edi
callq 0x5e6be
movq (%rbx), %rdx
leaq 0x1b5b6b(%rip), %rax    # 0x21afd4
movl (%rax), %ecx
movb $0x46, %al
cmpq $0x1, %rdx
jne 0x65484
cmpl $0x41, %ecx
jne 0x65484
leaq 0x1b3479(%rip), %rsi    # 0x2188f8
cmpl $0x47, (%rsi)
je 0x654b9
cmpl $0x41, %ecx
sete %sil
cmpl $0x50, %ecx
sete %dil
cmpq $0x1, %rdx
jne 0x6549d
orb %dil, %sil
jne 0x654b9
cmpq $0x1, %rdx
jne 0x654b7
addl $-0x33, %ecx
cmpl $0x1d, %ecx
ja 0x654b7
movb $0x4b, %al
movl $0x20004009, %edx       # imm = 0x20004009
btl %ecx, %edx
jb 0x654b9
movb $0x46, %al
movzbl %al, %edi
callq 0x590f7
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5e73c
leaq 0xbb311(%rip), %rdi     # 0x1207e4
movl $0x1, %ebx
movl $0x1, %esi
callq 0x5edda
leaq 0xbb22e(%rip), %rdi     # 0x120717
movl $0x14d, %esi            # imm = 0x14D
callq 0x5edda
leaq 0xc02fd(%rip), %rdi     # 0x1257f7
movl $0x145, %esi            # imm = 0x145
callq 0x5edda
leaq 0xbb2de(%rip), %rdi     # 0x1207e9
movl $0x146, %esi            # imm = 0x146
callq 0x5edda
leaq 0x1b54d0(%rip), %rax    # 0x21a9ec
movl %ebx, (%rax)
leaq 0x1b54b7(%rip), %rax    # 0x21a9dc
movl %ebx, (%rax)
jmp 0x650a4
movl $0x517, %edi            # imm = 0x517
movl $0x8, %esi
xorl %edx, %edx
callq 0x646e6
callq 0x64869
movw $0x8007, -0xa(%rbp)     # imm = 0x8007
leaq 0x1b3285(%rip), %rbx    # 0x2187d4
xorl %eax, %eax
cmpb $0x0, (%rbx)
sete %al
movzbl -0xa(%rbp,%rax), %edi
callq 0x590f7
xorl %eax, %eax
cmpb $0x0, (%rbx)
setne %al
movzbl -0xa(%rbp,%rax), %edi
callq 0x590f7
callq 0x648ab
movl $0x2710, %edi           # imm = 0x2710
callq 0xafe8
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x6156d
leaq 0xbb1d8(%rip), %rdi     # 0x12076c
movl $0x323, %esi            # imm = 0x323
jmp 0x655fd
leaq 0x1b5a3e(%rip), %rax    # 0x21afe0
cmpl $0x4e, (%rax)
jne 0x655e3
leaq 0xbb285(%rip), %rdi     # 0x120833
jmp 0x655ea
leaq 0xbb2b9(%rip), %rdi     # 0x120870
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5f228
movl $0x68, 0x307664(%rip)   # 0x36cc30
jmp 0x650a4
leaq 0xbb29e(%rip), %rdi     # 0x120876
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5f2c8
leaq 0xbb255(%rip), %rdi     # 0x12083f
movl $0x14, %esi
jmp 0x655fd
leaq 0xbb15f(%rip), %rdi     # 0x120757
movl $0xfb, %esi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5edda