// File: /workspace/github_cpp_makefile_star2_O2/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 0x2c4272(%rip), %rax    # 0x32101a
leaq 0x2c4271(%rip), %rcx    # 0x321020
movb (%rcx), %cl
orb (%rax), %cl
je 0x5cdbc
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x29a426(%rip), %rax    # 0x2f71e9
movb $0x0, (%rax)
leaq 0x29a413(%rip), %rax    # 0x2f71e0
andl $0x0, (%rax)
leaq 0x29a401(%rip), %rax    # 0x2f71d8
andb $0x7f, (%rax)
xorps %xmm0, %xmm0
callq 0x5bd83
leaq 0x1cc155(%rip), %rax    # 0x228f3e
cmpb $0x0, (%rax)
je 0x5ce18
movl $0xdc, %edi
callq 0x5707f
pushq $0x8
popq %rdi
callq 0x523f2
callq 0x570f8
pushq $0x64
popq %rdi
callq 0xae83
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5bfcf
leaq 0x1a5ab1(%rip), %rbx    # 0x2028d0
movq (%rbx), %rax
cmpq $0x1, %rax
je 0x5d053
cmpq $0x4, %rax
je 0x5d221
cmpq $0x8, %rax
je 0x5d207
cmpq $0x10, %rax
je 0x5d18b
cmpq $0x20, %rax
je 0x5d168
cmpq $0x80, %rax
je 0x5cf5a
cmpq $0x100, %rax            # imm = 0x100
je 0x5d1cf
cmpq $0x800, %rax            # imm = 0x800
je 0x5ce0d
cmpq $0x1000, %rax           # imm = 0x1000
je 0x5cf88
movabsq $0x800000000, %rcx      # imm = 0x800000000
cmpq %rcx, %rax
je 0x5d146
cmpq $0x8000, %rax           # imm = 0x8000
je 0x5cfb6
cmpq $0x10000, %rax          # imm = 0x10000
je 0x5d1a7
cmpq $0x20000, %rax          # imm = 0x20000
je 0x5d0c8
cmpq $0x40000, %rax          # imm = 0x40000
je 0x5d01e
cmpq $0x100000, %rax         # imm = 0x100000
je 0x5cfa4
cmpq $0x200000, %rax         # imm = 0x200000
je 0x5d134
cmpq $0x400000, %rax         # imm = 0x400000
je 0x5d013
cmpq $0x1000000, %rax        # imm = 0x1000000
je 0x5d002
cmpq $0x8000000, %rax        # imm = 0x8000000
je 0x5d123
cmpq $0x20000000, %rax       # imm = 0x20000000
je 0x5cfc8
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
je 0x5cfda
movabsq $0x100000000, %rcx      # imm = 0x100000000
cmpq %rcx, %rax
je 0x5d02f
movabsq $0x400000000, %rcx      # imm = 0x400000000
cmpq %rcx, %rax
je 0x5d041
cmpq $0x4000, %rax           # imm = 0x4000
jne 0x5cdb5
movl $0x68, 0x2f9cdb(%rip)   # 0x356c30
jmp 0x5cdb5
pushq $0x4
popq %rdi
pushq $0x2
popq %rsi
callq 0x582b6
pushq $0x1
popq %rbx
movl %ebx, %edi
callq 0x523f2
callq 0x59f48
movl $0x1388, %edi           # imm = 0x1388
callq 0xae83
pushq $0x16
popq %rdi
movl %ebx, %esi
jmp 0x5d24f
leaq 0x1a8059(%rip), %rax    # 0x204fe8
cmpl $0x4f, (%rax)
jne 0x5d25a
leaq 0xad7fc(%rip), %rdi     # 0x10a79b
jmp 0x5d261
leaq 0xad81e(%rip), %rdi     # 0x10a7c9
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x579af
leaq 0xad7ea(%rip), %rdi     # 0x10a7a7
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5c473
leaq 0xad79d(%rip), %rdi     # 0x10a76c
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x578d5
leaq 0xad75a(%rip), %rdi     # 0x10a73b
callq 0x57791
movl $0x7d0, %edi            # imm = 0x7D0
callq 0xae83
leaq 0xad75d(%rip), %rdi     # 0x10a754
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x57791
leaq 0xad76e(%rip), %rdi     # 0x10a777
movl $0x1f4, %esi            # imm = 0x1F4
jmp 0x5d272
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5c446
leaq 0xad61f(%rip), %rdi     # 0x10a644
movl $0x1a4, %esi            # imm = 0x1A4
jmp 0x5d272
leaq 0xad788(%rip), %rdi     # 0x10a7be
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x57b55
leaq 0xad76a(%rip), %rdi     # 0x10a7b2
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x57a21
pushq $0x1e
popq %rdi
callq 0x5707f
movq (%rbx), %rdx
leaq 0x1a7f6f(%rip), %rax    # 0x204fd4
movl (%rax), %ecx
movb $0x46, %al
cmpq $0x1, %rdx
jne 0x5d080
cmpl $0x41, %ecx
jne 0x5d080
leaq 0x1a587d(%rip), %rsi    # 0x2028f8
cmpl $0x47, (%rsi)
je 0x5d0b5
cmpl $0x41, %ecx
sete %sil
cmpl $0x50, %ecx
sete %dil
cmpq $0x1, %rdx
jne 0x5d099
orb %dil, %sil
jne 0x5d0b5
cmpq $0x1, %rdx
jne 0x5d0b3
addl $-0x33, %ecx
cmpl $0x1d, %ecx
ja 0x5d0b3
movb $0x4b, %al
movl $0x20004009, %edx       # imm = 0x20004009
btl %ecx, %edx
jb 0x5d0b5
movb $0x46, %al
movzbl %al, %edi
callq 0x523f2
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x570f8
leaq 0xad65d(%rip), %rdi     # 0x10a72c
pushq $0x1
popq %rbx
movl %ebx, %esi
callq 0x576d4
leaq 0xad57f(%rip), %rdi     # 0x10a65f
movl $0x14d, %esi            # imm = 0x14D
callq 0x576d4
leaq 0xb264e(%rip), %rdi     # 0x10f73f
movl $0x145, %esi            # imm = 0x145
callq 0x576d4
leaq 0xad62f(%rip), %rdi     # 0x10a731
movl $0x146, %esi            # imm = 0x146
callq 0x576d4
leaq 0x1a78d9(%rip), %rax    # 0x2049ec
movl %ebx, (%rax)
leaq 0x1a78c0(%rip), %rax    # 0x2049dc
movl %ebx, (%rax)
jmp 0x5cdb5
leaq 0xad58a(%rip), %rdi     # 0x10a6b4
movl $0x323, %esi            # imm = 0x323
jmp 0x5d272
leaq 0xad67d(%rip), %rdi     # 0x10a7b8
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x57acc
pushq $0x2
popq %rdi
pushq $0xc
popq %rsi
callq 0x5d27d
leaq 0xad63a(%rip), %rdi     # 0x10a792
callq 0x5d2c0
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5d2f6
leaq 0xad605(%rip), %rdi     # 0x10a774
callq 0x59a28
callq 0x59aab
leaq 0x1a7ea8(%rip), %rax    # 0x205028
movl $0x3, (%rax)
jmp 0x5cdb5
leaq 0x1a7e4e(%rip), %rax    # 0x204fe0
cmpl $0x4e, (%rax)
jne 0x5d268
leaq 0xad5d9(%rip), %rdi     # 0x10a77b
jmp 0x5d26f
leaq 0x9a652(%rip), %rsi     # 0xf7800
pushq $0xa
popq %rbx
movl %ebx, %edi
callq 0x5c48b
movl $0xfa0, %edi            # imm = 0xFA0
callq 0xae83
movl %ebx, %edi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5c606
pushq $0x8
popq %rsi
movl $0x517, %edi            # imm = 0x517
xorl %edx, %edx
callq 0x5c619
callq 0x5c6ed
movl $0x8007, %edi           # imm = 0x8007
callq 0x52599
callq 0x5c6fe
movl $0x2710, %edi           # imm = 0x2710
callq 0xae83
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5998f
leaq 0xad57a(%rip), %rdi     # 0x10a788
pushq $0x14
popq %rsi
callq 0x576d4
leaq 0xb0eb9(%rip), %rdi     # 0x10e0d6
pushq $0x65
jmp 0x5d271
movl $0x41f, %edi            # imm = 0x41F
xorl %esi, %esi
movl $0x41f, %edx            # imm = 0x41F
callq 0x59dc8
leaq 0x1a7def(%rip), %rax    # 0x205028
movl $0x4, (%rax)
movl $0x3e8, %edi            # imm = 0x3E8
callq 0xae83
pushq $0x16
popq %rdi
pushq $0x1
popq %rsi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x59afe
leaq 0xad43e(%rip), %rdi     # 0x10a69f
movl $0xfb, %esi
jmp 0x5d272
leaq 0xad518(%rip), %rdi     # 0x10a787
pushq $0x14
popq %rsi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x576d4