// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heathgps.cpp
// Function: set_raw_rate()
void set_raw_rate()
{
int i;
int raw_rate;

   if(read_only) return;

   if(rcvr_type == ESIP_RCVR) {  // only outputs raw_msg_rate data at 1 Hz and if baud >= 115200
      if(raw_msg_rate) sprintf(out, "PERDAPI,CROUT,MN,%d", 1); 
      else             sprintf(out, "PERDAPI,CROUT,MN,%d", 0);
      send_esip_cmd(out);    // enable sat measurement and navigation data
      have_raw_rate = 1;
   }
   else if(rcvr_type == MOTO_RCVR) {  // raw Hz !!!! untested - no rcvr available that does this message
      if(moto_chans == 6) {
         send_moto_start("Bg");
         send_byte(raw_msg_rate);
         send_moto_end();
      }
      else if(moto_chans == 8) {
         send_moto_start("Eg");
         send_byte(raw_msg_rate);
         send_moto_end();
      }
      else {
         send_moto_start("Hr");  // differential (pseudorange) data at raw message rate
         if(user_set_raw_rate) send_byte(raw_msg_rate);
         else                  send_byte(10);
         send_byte('+');
         send_byte('+');
         send_byte('+');
         send_byte('+');
         send_byte('+');
         send_byte('+');
         send_moto_end();
      }

      if(0 && user_set_raw_rate) {  // !!!! only updates when data changes
         send_moto_start("Bb"); 
         send_byte(user_set_raw_rate);
         send_moto_end();
      }
      have_raw_rate = 1;
   }
   else if(rcvr_type == NVS_RCVR) {  // raw Hz !!!!
      send_nvs_start(0x24); // 0x54 sky view message rate raw rate or every 5 seconds
      if(raw_msg_rate) send_byte(raw_msg_rate);
      else             send_byte(5);
      send_nvs_end();

      send_nvs_start(0xF4); // 0xF4 raw data every second  //rawz
      send_byte(raw_msg_rate*10);  // 100 msec granularity
      send_nvs_end();
      have_raw_rate = 1;
   }
   else if(rcvr_type == RT17_RCVR) {  // toots rt17 fix needed
      have_raw_rate = 1;
   }
   else if(rcvr_type == SS_RCVR) {
      if(raw_msg_rate == 1) {
         send_ss_start(23 | 0x80, 5);
         send_byte(0);
      }
      else if(raw_msg_rate == 2) {
         send_ss_start(23 | 0x80, 5);
         send_byte(1);
      }
      else if(raw_msg_rate == 5) {
         send_ss_start(23 | 0x80, 5);
         send_byte(2);
      }
      else {
         send_ss_start(23, 5);
         send_byte(0);
         raw_msg_rate = 0;
      }
      send_ss_end();
   }
   else if(rcvr_type == UBX_RCVR) {
      if(raw_msg_rate) {  // automatically send RAW and SFRB messages for RTKLIB use
         raw_rate = raw_msg_rate;
         raw_msg_rate = 1;  // raw Hz - we actually output raw data at the navigation rate
         set_ubx_rate(UBX_RAW,   raw_msg_rate);    // RAW info
         set_ubx_rate(UBX_RAWX,  raw_msg_rate);    // RAW info
         set_ubx_rate(UBX_SOL,   raw_msg_rate);    // SOL info
//       set_ubx_rate(UBX_ORB,   raw_msg_rate);    // ORB info
//       set_ubx_rate(UBX_SBAS,  raw_msg_rate);    // SBAS info
         set_ubx_rate(UBX_ORB,   0);               // ORB info
         set_ubx_rate(UBX_SBAS,  0);               // SBAS info
         set_ubx_rate(UBX_SFRB,  raw_msg_rate);    // SFRB info
         set_ubx_rate(UBX_SFRBX, raw_msg_rate);    // SFRBX info (ublox8)
         if(special_raw) {  // enable undocumented raw messages for early M8N's
            set_ubx_rate(TRK_SFRBX, raw_msg_rate);    // TRK_SFRBX info (ublox8 - undocumented, causes errors)
            set_ubx_rate(TRK_MEAS,  raw_msg_rate);    // TRK_MEAS info (ublox8 - undocumanted, causes errors)
         }
         set_ubx_rate(UBX_SVN, raw_msg_rate);     // sat info
         raw_msg_rate = raw_rate;
      }
      else {  // disable raw data messages to reduce serial port traffic
         set_ubx_rate(UBX_RAW,   0);    // RAW info
         set_ubx_rate(UBX_RAWX,  0);    // RAW info
         set_ubx_rate(UBX_SOL,   0);    // SOL info
//       set_ubx_rate(UBX_ORB,   0);    // ORB info
//       set_ubx_rate(UBX_SBAS,  0);    // SBAS info
         set_ubx_rate(UBX_SFRB,  0);    // SFRB info
         set_ubx_rate(UBX_SFRBX, 0);    // SFRBX info (ublox8)
         set_ubx_rate(TRK_SFRBX, 0);    // TRK_SFRBX info (ublox8 undocumented)
         set_ubx_rate(TRK_MEAS,  0);    // TRK_MEAS info (ublox8 undocumented)
         set_ubx_rate(UBX_SVN,   0);    // sat info - we now poll for this
      }
      have_raw_rate = 1;
   }
   else if(rcvr_type == VENUS_RCVR) {  // raw Hz !!!! 0..6 -> 1/2/4/5/10/20/8 Hz
      if(raw_msg_rate) i = 1;
      else             i = 0;
      send_venus_start(SET_VENUS_RAW);
      send_byte(0);  // always 1Hz rate, we drop unwanted messages if raw rate > 1 sec
      send_byte(i);  // enable meas time
      send_byte(i);  // enable raw data
      send_byte(i);  // SV/channel data   
      send_byte(0);  // RCV_State
      send_byte(0);  // subframe enable
      send_byte(i);  // extended raw data
      send_venus_save(1);
      have_raw_rate = 1;
   }
   else if(rcvr_type == Z12_RCVR) {  // raw Hz !!!!
      if(raw_msg_rate) {
         if(user_set_raw_rate) {
            sprintf(out, "PASHS,RCI,%.1f", (double) raw_msg_rate);
            send_z12_cmd(out);
         }
         // MBN -> MPC
         // PBN -> PBN
         // SAL -> ALM
         // SNV -> SNV 
         // DBN -> DBN (locks up);
         // EPB -> EPB (locks up);
//       send_z12_cmd("PASHS,OUT,A,PBN,MBN");  // enable RAW meessages -> MPC ascii
         send_z12_cmd("PASHS,OUT,A,PBN,MBN,SNV,SAL,BIN");  // enable RAW meessages -> MPC ascii
      }
      else {
send_z12_cmd("PASHS,REC,N");  // disable recording (raw messages)
//       send_z12_cmd("PASHS,OUT,A,NME");    // enable NMEA meessages //lfs
         send_z12_cmd("PASHS,OUT,A,NMEA");   // enable NMEA meessages
         send_z12_cmd("PASHS,NME,PER,1.0");  // 1Hz output rate
//       send_z12_cmd("PASHS,NME,GGA,A,ON"); // select NMEA command
//       send_z12_cmd("PASHS,NME,GLL,A,ON"); // select NMEA command
//       send_z12_cmd("PASHS,NME,GSA,A,ON"); // select NMEA command
//       send_z12_cmd("PASHS,NME,GSV,A,ON"); // select NMEA command
         send_z12_cmd("PASHS,NME,ZDA,A,ON"); // select NMEA command
//       send_z12_cmd("PASHS,NME,GGA,GLL,GSA,GSV,ZDA,ON"); // select NMEA command
//       send_z12_cmd("PASHS,NME,PER,1.0");  // 1Hz output rate
send_z12_cmd("PASHQ,ZDA"); //lfs
      }
      have_raw_rate = 1;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
leaq 0x2d023c(%rip), %rax    # 0x33701a
cmpb $0x0, (%rax)
jne 0x67286
leaq 0x1b1ae2(%rip), %rax    # 0x2188d0
movq (%rax), %rax
cmpq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
jg 0x66e3e
cmpq $0x7f, %rax
jg 0x66ebb
cmpq $0x4, %rax
je 0x66f86
cmpq $0x20, %rax
jne 0x67286
leaq 0x1b4206(%rip), %rax    # 0x21b024
movl (%rax), %eax
cmpl $0x8, %eax
je 0x67164
cmpl $0x6, %eax
jne 0x6717b
leaq 0xb9ab1(%rip), %rdi     # 0x1208ea
jmp 0x6716b
movabsq $0x1ffffffff, %rcx      # imm = 0x1FFFFFFFF
cmpq %rcx, %rax
jg 0x66f26
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
je 0x6702e
movabsq $0x100000000, %rcx      # imm = 0x100000000
cmpq %rcx, %rax
jne 0x67286
leaq 0x1b44ff(%rip), %rax    # 0x21b378
movl (%rax), %eax
testl %eax, %eax
je 0x67125
leaq 0x1b44f6(%rip), %rcx    # 0x21b380
cmpl $0x0, (%rcx)
je 0x6726a
cvtsi2sd %eax, %xmm0
leaq 0x2d5382(%rip), %r14    # 0x33c220
leaq 0xb9a4e(%rip), %rsi     # 0x1208f3
movq %r14, %rdi
movb $0x1, %al
callq 0x9060
leaq 0xb9a4c(%rip), %rbx     # 0x120902
jmp 0x67157
cmpq $0x80, %rax
je 0x67062
cmpq $0x800, %rax            # imm = 0x800
jne 0x67286
movl $0x24, %edi
callq 0x5e740
leaq 0x1b4494(%rip), %rbx    # 0x21b378
movl (%rbx), %eax
testl %eax, %eax
movl $0x5, %edi
cmovnel %eax, %edi
movl $0xff, %r14d
andl %r14d, %edi
callq 0x591af
callq 0x5e844
movl $0xf4, %edi
callq 0x5e740
movl (%rbx), %eax
addl %eax, %eax
leal (%rax,%rax,4), %edi
andl %r14d, %edi
callq 0x591af
callq 0x5e844
jmp 0x67279
movabsq $0x200000000, %rcx      # imm = 0x200000000
cmpq %rcx, %rax
je 0x67279
movabsq $0x800000000, %rcx      # imm = 0x800000000
cmpq %rcx, %rax
jne 0x67286
leaq 0x1b4425(%rip), %rbx    # 0x21b378
movl (%rbx), %eax
cmpl $0x5, %eax
je 0x67205
cmpl $0x2, %eax
je 0x671ef
cmpl $0x1, %eax
jne 0x67220
movl $0x97, %edi
movl $0x5, %esi
callq 0x653a5
xorl %edi, %edi
jmp 0x67219
leaq 0x1b43eb(%rip), %rbx    # 0x21b378
movl (%rbx), %r14d
testl %r14d, %r14d
je 0x670c0
movl $0x1, (%rbx)
movl $0x210, %edi            # imm = 0x210
movl $0x1, %esi
callq 0x6728b
movl (%rbx), %esi
movl $0x215, %edi            # imm = 0x215
callq 0x6728b
movl (%rbx), %esi
movl $0x106, %edi            # imm = 0x106
callq 0x6728b
movl $0x134, %edi            # imm = 0x134
xorl %esi, %esi
callq 0x6728b
movl $0x132, %edi            # imm = 0x132
xorl %esi, %esi
callq 0x6728b
movl (%rbx), %esi
movl $0x211, %edi            # imm = 0x211
callq 0x6728b
movl (%rbx), %esi
movl $0x213, %edi            # imm = 0x213
callq 0x6728b
leaq 0x1b437f(%rip), %rax    # 0x21b37c
cmpl $0x0, (%rax)
je 0x6701a
movl (%rbx), %esi
movl $0x310, %edi            # imm = 0x310
callq 0x6728b
movl (%rbx), %esi
movl $0x30f, %edi            # imm = 0x30F
callq 0x6728b
movl (%rbx), %esi
movl $0x130, %edi            # imm = 0x130
callq 0x6728b
movl %r14d, (%rbx)
jmp 0x67279
leaq 0x1b4343(%rip), %rax    # 0x21b378
xorl %edx, %edx
cmpl $0x0, (%rax)
setne %dl
leaq 0x2d51dc(%rip), %rbx    # 0x33c220
leaq 0xb988b(%rip), %rsi     # 0x1208d6
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
callq 0x5ef13
jmp 0x67279
leaq 0x1b430f(%rip), %rax    # 0x21b378
xorl %ebx, %ebx
cmpl $0x0, (%rax)
setne %bl
movl $0x1e, %edi
movl $0x9, %esi
callq 0x5fbb4
xorl %edi, %edi
callq 0x591af
movl %ebx, %edi
callq 0x591af
movl %ebx, %edi
callq 0x591af
movl %ebx, %edi
callq 0x591af
xorl %edi, %edi
callq 0x591af
xorl %edi, %edi
callq 0x591af
movl %ebx, %edi
callq 0x591af
movl $0x1, %edi
callq 0x5fc43
jmp 0x67279
movl $0x210, %edi            # imm = 0x210
xorl %esi, %esi
callq 0x6728b
movl $0x215, %edi            # imm = 0x215
xorl %esi, %esi
callq 0x6728b
movl $0x106, %edi            # imm = 0x106
xorl %esi, %esi
callq 0x6728b
movl $0x211, %edi            # imm = 0x211
xorl %esi, %esi
callq 0x6728b
movl $0x213, %edi            # imm = 0x213
xorl %esi, %esi
callq 0x6728b
movl $0x310, %edi            # imm = 0x310
xorl %esi, %esi
callq 0x6728b
movl $0x30f, %edi            # imm = 0x30F
xorl %esi, %esi
callq 0x6728b
movl $0x130, %edi            # imm = 0x130
xorl %esi, %esi
callq 0x6728b
jmp 0x67279
leaq 0xb97f6(%rip), %rdi     # 0x120922
callq 0x5f340
leaq 0xb97f6(%rip), %rdi     # 0x12092e
callq 0x5f340
leaq 0xb97fb(%rip), %rdi     # 0x12093f
callq 0x5f340
leaq 0xb9814(%rip), %rbx     # 0x120964
leaq 0xb97fa(%rip), %r14     # 0x120951
movq %r14, %rdi
callq 0x5f340
jmp 0x67271
leaq 0xb9782(%rip), %rdi     # 0x1208ed
callq 0x61694
leaq 0x1b4201(%rip), %rax    # 0x21b378
movb (%rax), %al
jmp 0x671dd
leaq 0xb976e(%rip), %rdi     # 0x1208f0
callq 0x61694
leaq 0x1b41f2(%rip), %rax    # 0x21b380
cmpl $0x0, (%rax)
movl $0xa, %eax
je 0x671a1
leaq 0x1b41d9(%rip), %rax    # 0x21b378
movl (%rax), %eax
movzbl %al, %edi
callq 0x591af
movl $0x2b, %edi
callq 0x591af
movl $0x2b, %edi
callq 0x591af
movl $0x2b, %edi
callq 0x591af
movl $0x2b, %edi
callq 0x591af
movl $0x2b, %edi
callq 0x591af
movb $0x2b, %al
movzbl %al, %edi
callq 0x591af
callq 0x6170f
jmp 0x67279
movl $0x97, %edi
movl $0x5, %esi
callq 0x653a5
movl $0x1, %edi
jmp 0x67219
movl $0x97, %edi
movl $0x5, %esi
callq 0x653a5
movl $0x2, %edi
callq 0x591af
jmp 0x6723c
movl $0x17, %edi
movl $0x5, %esi
callq 0x653a5
xorl %edi, %edi
callq 0x591af
movl $0x0, (%rbx)
movzwl 0x305878(%rip), %r14d   # 0x36cabc
movl $0xff, %ebx
movl %r14d, %edi
andl %ebx, %edi
callq 0x591af
addl %r14d, %ebx
testw %r14w, %r14w
cmovnsl %r14d, %ebx
movzbl %bh, %edi
popq %rbx
popq %r14
popq %rbp
jmp 0x591af
leaq 0xb9691(%rip), %rbx     # 0x120902
movq %rbx, %rdi
callq 0x5f340
leaq 0x1b4104(%rip), %rax    # 0x21b384
movl $0x1, (%rax)
popq %rbx
popq %r14
popq %rbp
retq