// File: /workspace/github_cpp_makefile_star2_O2/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 0x2c2897(%rip), %rax    # 0x32101a
cmpb $0x0, (%rax)
jne 0x5ebaf
leaq 0x1a413d(%rip), %rax    # 0x2028d0
movq (%rax), %rax
cmpq $0x4, %rax
je 0x5e984
cmpq $0x20, %rax
je 0x5e8ba
cmpq $0x80, %rax
je 0x5e92c
cmpq $0x800, %rax            # imm = 0x800
je 0x5e8e1
movabsq $0x800000000, %rcx      # imm = 0x800000000
cmpq %rcx, %rax
je 0x5e839
movabsq $0x100000000, %rcx      # imm = 0x100000000
cmpq %rcx, %rax
je 0x5e871
movabsq $0x200000000, %rcx      # imm = 0x200000000
cmpq %rcx, %rax
je 0x5eba2
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
jne 0x5ebaf
leaq 0x1a6b6c(%rip), %rax    # 0x205378
xorl %edx, %edx
cmpl $0x0, (%rax)
setne %dl
leaq 0x2c7a05(%rip), %rbx    # 0x326220
leaq 0xac0dc(%rip), %rsi     # 0x10a8fe
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
callq 0x57791
jmp 0x5eba2
leaq 0x1a6b38(%rip), %rbx    # 0x205378
movl (%rbx), %eax
cmpl $0x5, %eax
je 0x5eb1c
cmpl $0x2, %eax
je 0x5eb0b
cmpl $0x1, %eax
jne 0x5eb33
pushq $0x5
popq %rsi
movl $0x97, %edi
callq 0x5d27d
xorl %edi, %edi
jmp 0x5eb2c
leaq 0x1a6b00(%rip), %rax    # 0x205378
movl (%rax), %eax
testl %eax, %eax
je 0x5ea2a
leaq 0x1a6af7(%rip), %rcx    # 0x205380
cmpl $0x0, (%rcx)
je 0x5eb51
cvtsi2sd %eax, %xmm0
leaq 0x2c7983(%rip), %r14    # 0x326220
leaq 0xac077(%rip), %rsi     # 0x10a91b
movq %r14, %rdi
movb $0x1, %al
callq 0x9060
leaq 0xac075(%rip), %rbx     # 0x10a92a
jmp 0x5ea5c
leaq 0x1a6763(%rip), %rax    # 0x205024
movl (%rax), %eax
cmpl $0x8, %eax
je 0x5eace
cmpl $0x6, %eax
jne 0x5eae8
leaq 0xac036(%rip), %rdi     # 0x10a912
jmp 0x5ead5
pushq $0x24
popq %rdi
callq 0x5707f
leaq 0x1a6a88(%rip), %rbx    # 0x205378
movl (%rbx), %eax
testl %eax, %eax
pushq $0x5
popq %rdi
cmovnel %eax, %edi
movl $0xff, %r14d
andl %r14d, %edi
callq 0x523f2
callq 0x57171
movl $0xf4, %edi
callq 0x5707f
imull $0xa, (%rbx), %edi
andl %r14d, %edi
callq 0x523f2
callq 0x57171
jmp 0x5eba2
leaq 0x1a6a45(%rip), %rax    # 0x205378
xorl %ebx, %ebx
cmpl $0x0, (%rax)
setne %bl
pushq $0x1e
popq %rdi
pushq $0x9
popq %rsi
callq 0x582b6
xorl %edi, %edi
callq 0x523f2
movl %ebx, %edi
callq 0x523f2
movl %ebx, %edi
callq 0x523f2
movl %ebx, %edi
callq 0x523f2
xorl %edi, %edi
callq 0x523f2
xorl %edi, %edi
callq 0x523f2
movl %ebx, %edi
callq 0x523f2
pushq $0x1
popq %rdi
callq 0x58354
jmp 0x5eba2
leaq 0x1a69ed(%rip), %rbx    # 0x205378
movl (%rbx), %r14d
testl %r14d, %r14d
je 0x5ea69
movl $0x1, (%rbx)
pushq $0x1
popq %rsi
movl $0x210, %edi            # imm = 0x210
callq 0x5ebb4
movl (%rbx), %esi
movl $0x215, %edi            # imm = 0x215
callq 0x5ebb4
movl (%rbx), %esi
movl $0x106, %edi            # imm = 0x106
callq 0x5ebb4
movl $0x134, %edi            # imm = 0x134
xorl %esi, %esi
callq 0x5ebb4
movl $0x132, %edi            # imm = 0x132
xorl %esi, %esi
callq 0x5ebb4
movl (%rbx), %esi
movl $0x211, %edi            # imm = 0x211
callq 0x5ebb4
movl (%rbx), %esi
movl $0x213, %edi            # imm = 0x213
callq 0x5ebb4
leaq 0x1a6983(%rip), %rax    # 0x20537c
cmpl $0x0, (%rax)
je 0x5ea16
movl (%rbx), %esi
movl $0x310, %edi            # imm = 0x310
callq 0x5ebb4
movl (%rbx), %esi
movl $0x30f, %edi            # imm = 0x30F
callq 0x5ebb4
movl (%rbx), %esi
movl $0x130, %edi            # imm = 0x130
callq 0x5ebb4
movl %r14d, (%rbx)
jmp 0x5eba2
leaq 0xabf19(%rip), %rdi     # 0x10a94a
callq 0x57b55
leaq 0xabf19(%rip), %rdi     # 0x10a956
callq 0x57b55
leaq 0xabf1e(%rip), %rdi     # 0x10a967
callq 0x57b55
leaq 0xabf37(%rip), %rbx     # 0x10a98c
leaq 0xabf1d(%rip), %r14     # 0x10a979
movq %r14, %rdi
callq 0x57b55
jmp 0x5eb58
movl $0x210, %edi            # imm = 0x210
xorl %esi, %esi
callq 0x5ebb4
movl $0x215, %edi            # imm = 0x215
xorl %esi, %esi
callq 0x5ebb4
movl $0x106, %edi            # imm = 0x106
xorl %esi, %esi
callq 0x5ebb4
movl $0x211, %edi            # imm = 0x211
xorl %esi, %esi
callq 0x5ebb4
movl $0x213, %edi            # imm = 0x213
xorl %esi, %esi
callq 0x5ebb4
movl $0x310, %edi            # imm = 0x310
xorl %esi, %esi
callq 0x5ebb4
movl $0x30f, %edi            # imm = 0x30F
xorl %esi, %esi
callq 0x5ebb4
movl $0x130, %edi            # imm = 0x130
xorl %esi, %esi
callq 0x5ebb4
jmp 0x5eba2
leaq 0xabe40(%rip), %rdi     # 0x10a915
callq 0x59a28
leaq 0x1a6897(%rip), %rax    # 0x205378
movb (%rax), %al
jmp 0x5eb95
leaq 0xabe29(%rip), %rdi     # 0x10a918
callq 0x59a28
leaq 0x1a6885(%rip), %rax    # 0x205380
cmpl $0x0, (%rax)
je 0x5eb62
leaq 0x1a6871(%rip), %rax    # 0x205378
movl (%rax), %eax
jmp 0x5eb65
pushq $0x5
popq %rsi
movl $0x97, %edi
callq 0x5d27d
pushq $0x1
jmp 0x5eb2b
pushq $0x5
popq %rsi
movl $0x97, %edi
callq 0x5d27d
pushq $0x2
popq %rdi
callq 0x523f2
jmp 0x5eb48
pushq $0x17
popq %rdi
pushq $0x5
popq %rsi
callq 0x5d27d
xorl %edi, %edi
callq 0x523f2
andl $0x0, (%rbx)
popq %rbx
popq %r14
popq %rbp
jmp 0x5d2f6
leaq 0xabdd2(%rip), %rbx     # 0x10a92a
movq %rbx, %rdi
callq 0x57b55
jmp 0x5eba2
pushq $0xa
popq %rax
movzbl %al, %edi
callq 0x523f2
pushq $0x2b
popq %rbx
movl %ebx, %edi
callq 0x523f2
movl %ebx, %edi
callq 0x523f2
movl %ebx, %edi
callq 0x523f2
movl %ebx, %edi
callq 0x523f2
movl %ebx, %edi
callq 0x523f2
movb $0x2b, %al
movzbl %al, %edi
callq 0x523f2
callq 0x59aab
leaq 0x1a67db(%rip), %rax    # 0x205384
movl $0x1, (%rax)
popq %rbx
popq %r14
popq %rbp
retq