// File: 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
leaq 0x30bccf(%rip), %rax    # 0x3961fa
cmpb $0x0, (%rax)
je 0x8a535
jmp 0x8ab71
leaq 0x30bcc4(%rip), %rax    # 0x396200
cmpb $0x0, (%rax)
je 0x8a546
jmp 0x8ab71
callq 0x80300
xorps %xmm0, %xmm0
callq 0x88f10
leaq 0x213bc4(%rip), %rax    # 0x29e11e
cmpb $0x0, (%rax)
je 0x8a58c
movl $0xdc, %edi
callq 0x824f0
movl $0x8, %edi
callq 0x7b210
callq 0x82590
movl $0x64, %edi
callq 0xb8b0
callq 0x89450
jmp 0x8ab71
leaq 0x1ed51d(%rip), %rax    # 0x277ab0
cmpq $0x4000, (%rax)         # imm = 0x4000
jne 0x8a5ab
movl $0x68, 0x34185a(%rip)   # 0x3cbe00
jmp 0x8ab6f
leaq 0x1ed4fe(%rip), %rax    # 0x277ab0
cmpq $0x40000, (%rax)        # imm = 0x40000
jne 0x8a5d1
leaq 0xf93ba(%rip), %rdi     # 0x18397c
movl $0x1a4, %esi            # imm = 0x1A4
callq 0x82fd0
jmp 0x8ab6d
leaq 0x1ed4d8(%rip), %rax    # 0x277ab0
cmpq $0x20000, (%rax)        # imm = 0x20000
jne 0x8a644
leaq 0xf947c(%rip), %rdi     # 0x183a64
movl $0x1, %esi
callq 0x82fd0
leaq 0xf939e(%rip), %rdi     # 0x183997
movl $0x14d, %esi            # imm = 0x14D
callq 0x82fd0
leaq 0xfe4e1(%rip), %rdi     # 0x188aeb
movl $0x145, %esi            # imm = 0x145
callq 0x82fd0
leaq 0xf944e(%rip), %rdi     # 0x183a69
movl $0x146, %esi            # imm = 0x146
callq 0x82fd0
leaq 0x1ef5a0(%rip), %rax    # 0x279bcc
movl $0x1, (%rax)
leaq 0x1ef583(%rip), %rax    # 0x279bbc
movl $0x1, (%rax)
jmp 0x8ab6b
movl $0x80000000, %ecx       # imm = 0x80000000
leaq 0x1ed460(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0x8a67c
leaq 0xf9417(%rip), %rdi     # 0x183a73
callq 0x830d0
movl $0x7d0, %edi            # imm = 0x7D0
callq 0xb8b0
leaq 0xf941a(%rip), %rdi     # 0x183a8c
callq 0x830d0
jmp 0x8ab69
leaq 0x1ed42d(%rip), %rax    # 0x277ab0
cmpq $0x20000000, (%rax)     # imm = 0x20000000
jne 0x8a69d
leaq 0xf9411(%rip), %rdi     # 0x183aa4
callq 0x83270
jmp 0x8ab67
leaq 0x1ed40c(%rip), %rax    # 0x277ab0
cmpq $0x20, (%rax)
jne 0x8a6cd
leaq 0xf93fb(%rip), %rdi     # 0x183aac
callq 0x86190
callq 0x86230
leaq 0x1efb46(%rip), %rax    # 0x27a208
movl $0x3, (%rax)
jmp 0x8ab65
leaq 0x1ed3dc(%rip), %rax    # 0x277ab0
cmpq $0x800, (%rax)          # imm = 0x800
jne 0x8a6e7
callq 0x89450
jmp 0x8ab63
leaq 0x1ed3c2(%rip), %rax    # 0x277ab0
cmpq $0x1000000, (%rax)      # imm = 0x1000000
jne 0x8a70d
leaq 0xf93b1(%rip), %rdi     # 0x183aaf
movl $0x1f4, %esi            # imm = 0x1F4
callq 0x82fd0
jmp 0x8ab61
leaq 0x1ed39c(%rip), %rax    # 0x277ab0
cmpq $0x400000, (%rax)       # imm = 0x400000
jne 0x8a72c
movl $0x48, %edi
callq 0x89980
jmp 0x8ab5f
leaq 0x1ed37d(%rip), %rax    # 0x277ab0
cmpq $0x10, (%rax)
jne 0x8a76e
leaq 0x1efa80(%rip), %rax    # 0x27a1c0
cmpl $0x4e, (%rax)
jne 0x8a758
leaq 0xf9367(%rip), %rdi     # 0x183ab3
movl $0x14, %esi
callq 0x82fd0
jmp 0x8a769
leaq 0xf9360(%rip), %rdi     # 0x183abf
movl $0x14, %esi
callq 0x82fd0
jmp 0x8ab5d
leaq 0x1ed33b(%rip), %rax    # 0x277ab0
cmpq $0x8000000, (%rax)      # imm = 0x8000000
jne 0x8a794
leaq 0xf9267(%rip), %rdi     # 0x1839ec
movl $0x323, %esi            # imm = 0x323
callq 0x82fd0
jmp 0x8ab5b
movabsq $0x800000000, %rcx      # imm = 0x800000000
leaq 0x1ed30b(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0x8a7cf
movl $0x2, %edi
movl $0xc, %esi
callq 0x8ab80
leaq 0xf930a(%rip), %rdi     # 0x183aca
callq 0x8abe0
callq 0x8ac40
jmp 0x8ab59
leaq 0x1ed2da(%rip), %rax    # 0x277ab0
cmpq $0x1000, (%rax)         # imm = 0x1000
jne 0x8a814
leaq 0x1ef9e2(%rip), %rax    # 0x27a1c8
cmpl $0x4f, (%rax)
jne 0x8a7fe
leaq 0xf92e1(%rip), %rdi     # 0x183ad3
movl $0xfb, %esi
callq 0x82fd0
jmp 0x8a80f
leaq 0xf91d2(%rip), %rdi     # 0x1839d7
movl $0xfb, %esi
callq 0x82fd0
jmp 0x8ab57
leaq 0x1ed295(%rip), %rax    # 0x277ab0
cmpq $0x8000, (%rax)         # imm = 0x8000
jne 0x8a835
leaq 0xf92b4(%rip), %rdi     # 0x183adf
callq 0x899c0
jmp 0x8ab55
leaq 0x1ed274(%rip), %rax    # 0x277ab0
cmpq $0x10000, (%rax)        # imm = 0x10000
jne 0x8a86f
movl $0xa, %edi
leaq 0xe77f3(%rip), %rsi     # 0x172044
callq 0x899f0
movl $0xfa0, %edi            # imm = 0xFA0
callq 0xb8b0
movl $0xa, %edi
callq 0x89bc0
jmp 0x8ab53
movabsq $0x400000000, %rcx      # imm = 0x400000000
leaq 0x1ed230(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0x8a896
leaq 0xf925e(%rip), %rdi     # 0x183aea
callq 0x83490
jmp 0x8ab51
leaq 0x1ed213(%rip), %rax    # 0x277ab0
cmpq $0x200000, (%rax)       # imm = 0x200000
jne 0x8a8b7
leaq 0xf9243(%rip), %rdi     # 0x183af0
callq 0x83580
jmp 0x8ab4f
leaq 0x1ed1f2(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x8a9f5
movl $0x1e, %edi
callq 0x824f0
leaq 0x1ed1d7(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x8a906
leaq 0x1ef8ce(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x8a906
leaq 0x1ed1e6(%rip), %rax    # 0x277ad8
cmpl $0x47, (%rax)
jne 0x8a906
movl $0x46, %edi
callq 0x7b210
jmp 0x8a9eb
leaq 0x1ed1a3(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x8a946
leaq 0x1ef89a(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x8a946
leaq 0x1ed1b2(%rip), %rax    # 0x277ad8
cmpl $0x33, (%rax)
je 0x8a937
leaq 0x1ed1a6(%rip), %rax    # 0x277ad8
cmpl $0x47, (%rax)
jne 0x8a946
movl $0x46, %edi
callq 0x7b210
jmp 0x8a9e9
leaq 0x1ed163(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x8a96b
leaq 0x1ef85a(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x8a96b
movl $0x46, %edi
callq 0x7b210
jmp 0x8a9e7
leaq 0x1ed13e(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x8a990
leaq 0x1ef835(%rip), %rax    # 0x27a1b4
cmpl $0x50, (%rax)
jne 0x8a990
movl $0x46, %edi
callq 0x7b210
jmp 0x8a9e5
leaq 0x1ed119(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x8a9d9
leaq 0x1ef810(%rip), %rax    # 0x27a1b4
cmpl $0x36, (%rax)
je 0x8a9cd
leaq 0x1ef804(%rip), %rax    # 0x27a1b4
cmpl $0x33, (%rax)
je 0x8a9cd
leaq 0x1ef7f8(%rip), %rax    # 0x27a1b4
cmpl $0x50, (%rax)
je 0x8a9cd
leaq 0x1ef7ec(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x8a9d9
movl $0x4b, %edi
callq 0x7b210
jmp 0x8a9e3
movl $0x46, %edi
callq 0x7b210
jmp 0x8a9e5
jmp 0x8a9e7
jmp 0x8a9e9
jmp 0x8a9eb
callq 0x82590
jmp 0x8ab4d
leaq 0x1ed0b4(%rip), %rax    # 0x277ab0
cmpq $0x4, (%rax)
jne 0x8aa3b
movl $0x41f, %edx            # imm = 0x41F
xorl %esi, %esi
movl %edx, %edi
callq 0x86600
leaq 0x1ef7f1(%rip), %rax    # 0x27a208
movl $0x4, (%rax)
movl $0x3e8, %edi            # imm = 0x3E8
callq 0xb8b0
movl $0x16, %edi
movl $0x1, %esi
callq 0x86290
jmp 0x8ab4b
leaq 0x1ed06e(%rip), %rax    # 0x277ab0
cmpq $0x8, (%rax)
jne 0x8aa6f
leaq 0xf9071(%rip), %rdi     # 0x183ac0
movl $0x14, %esi
callq 0x82fd0
leaq 0xfca1b(%rip), %rdi     # 0x18747b
movl $0x65, %esi
callq 0x82fd0
jmp 0x8ab49
leaq 0x1ed03a(%rip), %rax    # 0x277ab0
cmpq $0x80, (%rax)
jne 0x8aabb
movl $0x4, %edi
movl $0x2, %esi
callq 0x84080
movl $0x1, %edi
callq 0x7b210
callq 0x867d0
movl $0x1388, %edi           # imm = 0x1388
callq 0xb8b0
movl $0x16, %edi
movl $0x1, %esi
callq 0x86290
jmp 0x8ab47
movabsq $0x100000000, %rcx      # imm = 0x100000000
leaq 0x1ecfe4(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0x8aadf
leaq 0xf901e(%rip), %rdi     # 0x183af6
callq 0x83630
jmp 0x8ab45
leaq 0x1ecfca(%rip), %rax    # 0x277ab0
cmpq $0x100, (%rax)          # imm = 0x100
jne 0x8ab25
movl $0x517, %edi            # imm = 0x517
movl $0x8, %esi
xorl %edx, %edx
callq 0x89bf0
callq 0x89d10
movl $0x8007, %edi           # imm = 0x8007
callq 0x7b4b0
callq 0x89d30
movl $0x2710, %edi           # imm = 0x2710
callq 0xb8b0
callq 0x860e0
jmp 0x8ab43
leaq 0x1ecf84(%rip), %rax    # 0x277ab0
cmpq $0x100000, (%rax)       # imm = 0x100000
jne 0x8ab41
leaq 0xf8fc4(%rip), %rdi     # 0x183b00
callq 0x85d30
jmp 0x8ab43
jmp 0x8ab45
jmp 0x8ab47
jmp 0x8ab49
jmp 0x8ab4b
jmp 0x8ab4d
jmp 0x8ab4f
jmp 0x8ab51
jmp 0x8ab53
jmp 0x8ab55
jmp 0x8ab57
jmp 0x8ab59
jmp 0x8ab5b
jmp 0x8ab5d
jmp 0x8ab5f
jmp 0x8ab61
jmp 0x8ab63
jmp 0x8ab65
jmp 0x8ab67
jmp 0x8ab69
jmp 0x8ab6b
jmp 0x8ab6d
jmp 0x8ab6f
jmp 0x8ab71
popq %rbp
retq
nopw %cs:(%rax,%rax)