// File: 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
subq $0x10, %rsp
leaq 0x30970b(%rip), %rax    # 0x3961fa
cmpb $0x0, (%rax)
je 0x8caf9
jmp 0x8d09a
movl $0x80000000, %ecx       # imm = 0x80000000
leaq 0x1eafab(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0x8cb67
leaq 0x1eda47(%rip), %rax    # 0x27a558
cmpl $0x0, (%rax)
je 0x8cb32
leaq 0x30e8e3(%rip), %rdi    # 0x39b400
leaq 0xf7112(%rip), %rsi     # 0x183c36
movl $0x1, %edx
movb $0x0, %al
callq 0x9060
jmp 0x8cb49
leaq 0x30e8c7(%rip), %rdi    # 0x39b400
leaq 0xf70f6(%rip), %rsi     # 0x183c36
xorl %edx, %edx
movb $0x0, %al
callq 0x9060
leaq 0x30e8b0(%rip), %rdi    # 0x39b400
callq 0x830d0
leaq 0x1eda08(%rip), %rax    # 0x27a564
movl $0x1, (%rax)
jmp 0x8d09a
leaq 0x1eaf42(%rip), %rax    # 0x277ab0
cmpq $0x20, (%rax)
jne 0x8cc65
leaq 0x1ed685(%rip), %rax    # 0x27a204
cmpl $0x6, (%rax)
jne 0x8cbab
leaq 0xf70bf(%rip), %rdi     # 0x183c4a
callq 0x86190
leaq 0x1ed9c1(%rip), %rax    # 0x27a558
movl (%rax), %eax
movzbl %al, %edi
callq 0x7b210
callq 0x86230
jmp 0x8cc53
leaq 0x1ed652(%rip), %rax    # 0x27a204
cmpl $0x8, (%rax)
jne 0x8cbdb
leaq 0xf708f(%rip), %rdi     # 0x183c4d
callq 0x86190
leaq 0x1ed98e(%rip), %rax    # 0x27a558
movl (%rax), %eax
movzbl %al, %edi
callq 0x7b210
callq 0x86230
jmp 0x8cc51
leaq 0xf706e(%rip), %rdi     # 0x183c50
callq 0x86190
leaq 0x1ed972(%rip), %rax    # 0x27a560
cmpl $0x0, (%rax)
je 0x8cc06
leaq 0x1ed95e(%rip), %rax    # 0x27a558
movl (%rax), %eax
movzbl %al, %edi
callq 0x7b210
jmp 0x8cc10
movl $0xa, %edi
callq 0x7b210
movl $0x2b, %edi
callq 0x7b210
movl $0x2b, %edi
callq 0x7b210
movl $0x2b, %edi
callq 0x7b210
movl $0x2b, %edi
callq 0x7b210
movl $0x2b, %edi
callq 0x7b210
movl $0x2b, %edi
callq 0x7b210
callq 0x86230
jmp 0x8cc53
leaq 0x1ed90a(%rip), %rax    # 0x27a564
movl $0x1, (%rax)
jmp 0x8d098
leaq 0x1eae44(%rip), %rax    # 0x277ab0
cmpq $0x800, (%rax)          # imm = 0x800
jne 0x8cce0
movl $0x24, %edi
callq 0x824f0
leaq 0x1ed8d2(%rip), %rax    # 0x27a558
cmpl $0x0, (%rax)
je 0x8cc9e
leaq 0x1ed8c6(%rip), %rax    # 0x27a558
movl (%rax), %eax
movzbl %al, %edi
callq 0x7b210
jmp 0x8cca8
movl $0x5, %edi
callq 0x7b210
callq 0x82630
movl $0xf4, %edi
callq 0x824f0
leaq 0x1ed89a(%rip), %rax    # 0x27a558
imull $0xa, (%rax), %eax
movzbl %al, %edi
callq 0x7b210
callq 0x82630
leaq 0x1ed88f(%rip), %rax    # 0x27a564
movl $0x1, (%rax)
jmp 0x8d096
movabsq $0x200000000, %rcx      # imm = 0x200000000
leaq 0x1eadbf(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0x8cd08
leaq 0x1ed867(%rip), %rax    # 0x27a564
movl $0x1, (%rax)
jmp 0x8d094
movabsq $0x800000000, %rcx      # imm = 0x800000000
leaq 0x1ead97(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0x8cdc5
leaq 0x1ed82f(%rip), %rax    # 0x27a558
cmpl $0x1, (%rax)
jne 0x8cd46
movl $0x97, %edi
movl $0x5, %esi
callq 0x8ab80
xorl %edi, %edi
callq 0x7b210
jmp 0x8cdbb
leaq 0x1ed80b(%rip), %rax    # 0x27a558
cmpl $0x2, (%rax)
jne 0x8cd6d
movl $0x97, %edi
movl $0x5, %esi
callq 0x8ab80
movl $0x1, %edi
callq 0x7b210
jmp 0x8cdb9
leaq 0x1ed7e4(%rip), %rax    # 0x27a558
cmpl $0x5, (%rax)
jne 0x8cd94
movl $0x97, %edi
movl $0x5, %esi
callq 0x8ab80
movl $0x2, %edi
callq 0x7b210
jmp 0x8cdb7
movl $0x17, %edi
movl $0x5, %esi
callq 0x8ab80
xorl %edi, %edi
callq 0x7b210
leaq 0x1ed7a7(%rip), %rax    # 0x27a558
movl $0x0, (%rax)
jmp 0x8cdb9
jmp 0x8cdbb
callq 0x8ac40
jmp 0x8d092
leaq 0x1eace4(%rip), %rax    # 0x277ab0
cmpq $0x4, (%rax)
jne 0x8cf3b
leaq 0x1ed77b(%rip), %rax    # 0x27a558
cmpl $0x0, (%rax)
je 0x8cec9
leaq 0x1ed76b(%rip), %rax    # 0x27a558
movl (%rax), %eax
movl %eax, -0x8(%rbp)
leaq 0x1ed75f(%rip), %rax    # 0x27a558
movl $0x1, (%rax)
leaq 0x1ed752(%rip), %rax    # 0x27a558
movl (%rax), %esi
movl $0x210, %edi            # imm = 0x210
callq 0x8d0a0
leaq 0x1ed73f(%rip), %rax    # 0x27a558
movl (%rax), %esi
movl $0x215, %edi            # imm = 0x215
callq 0x8d0a0
leaq 0x1ed72c(%rip), %rax    # 0x27a558
movl (%rax), %esi
movl $0x106, %edi            # imm = 0x106
callq 0x8d0a0
movl $0x134, %edi            # imm = 0x134
xorl %esi, %esi
callq 0x8d0a0
movl $0x132, %edi            # imm = 0x132
xorl %esi, %esi
callq 0x8d0a0
leaq 0x1ed701(%rip), %rax    # 0x27a558
movl (%rax), %esi
movl $0x211, %edi            # imm = 0x211
callq 0x8d0a0
leaq 0x1ed6ee(%rip), %rax    # 0x27a558
movl (%rax), %esi
movl $0x213, %edi            # imm = 0x213
callq 0x8d0a0
leaq 0x1ed6df(%rip), %rax    # 0x27a55c
cmpl $0x0, (%rax)
je 0x8cea8
leaq 0x1ed6cf(%rip), %rax    # 0x27a558
movl (%rax), %esi
movl $0x310, %edi            # imm = 0x310
callq 0x8d0a0
leaq 0x1ed6bc(%rip), %rax    # 0x27a558
movl (%rax), %esi
movl $0x30f, %edi            # imm = 0x30F
callq 0x8d0a0
leaq 0x1ed6a9(%rip), %rax    # 0x27a558
movl (%rax), %esi
movl $0x130, %edi            # imm = 0x130
callq 0x8d0a0
movl -0x8(%rbp), %ecx
leaq 0x1ed693(%rip), %rax    # 0x27a558
movl %ecx, (%rax)
jmp 0x8cf29
movl $0x210, %edi            # imm = 0x210
xorl %esi, %esi
callq 0x8d0a0
movl $0x215, %edi            # imm = 0x215
xorl %esi, %esi
callq 0x8d0a0
movl $0x106, %edi            # imm = 0x106
xorl %esi, %esi
callq 0x8d0a0
movl $0x211, %edi            # imm = 0x211
xorl %esi, %esi
callq 0x8d0a0
movl $0x213, %edi            # imm = 0x213
xorl %esi, %esi
callq 0x8d0a0
movl $0x310, %edi            # imm = 0x310
xorl %esi, %esi
callq 0x8d0a0
movl $0x30f, %edi            # imm = 0x30F
xorl %esi, %esi
callq 0x8d0a0
movl $0x130, %edi            # imm = 0x130
xorl %esi, %esi
callq 0x8d0a0
leaq 0x1ed634(%rip), %rax    # 0x27a564
movl $0x1, (%rax)
jmp 0x8d090
leaq 0x1eab6e(%rip), %rax    # 0x277ab0
cmpq $0x80, (%rax)
jne 0x8cfd7
leaq 0x1ed602(%rip), %rax    # 0x27a558
cmpl $0x0, (%rax)
je 0x8cf64
movl $0x1, -0x4(%rbp)
jmp 0x8cf6b
movl $0x0, -0x4(%rbp)
movl $0x1e, %edi
movl $0x9, %esi
callq 0x84080
xorl %edi, %edi
callq 0x7b210
movl -0x4(%rbp), %eax
movzbl %al, %edi
callq 0x7b210
movl -0x4(%rbp), %eax
movzbl %al, %edi
callq 0x7b210
movl -0x4(%rbp), %eax
movzbl %al, %edi
callq 0x7b210
xorl %edi, %edi
callq 0x7b210
xorl %edi, %edi
callq 0x7b210
movl -0x4(%rbp), %eax
movzbl %al, %edi
callq 0x7b210
movl $0x1, %edi
callq 0x84130
leaq 0x1ed598(%rip), %rax    # 0x27a564
movl $0x1, (%rax)
jmp 0x8d08e
movabsq $0x100000000, %rcx      # imm = 0x100000000
leaq 0x1eaac8(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0x8d08c
leaq 0x1ed560(%rip), %rax    # 0x27a558
cmpl $0x0, (%rax)
je 0x8d043
leaq 0x1ed55c(%rip), %rax    # 0x27a560
cmpl $0x0, (%rax)
je 0x8d035
leaq 0x1ed548(%rip), %rax    # 0x27a558
cvtsi2sdl (%rax), %xmm0
leaq 0x30e3e5(%rip), %rdi    # 0x39b400
leaq 0xf6c31(%rip), %rsi     # 0x183c53
movb $0x1, %al
callq 0x9060
leaq 0x30e3d0(%rip), %rdi    # 0x39b400
callq 0x83630
leaq 0xf6c26(%rip), %rdi     # 0x183c62
callq 0x83630
jmp 0x8d07f
leaq 0xf6c38(%rip), %rdi     # 0x183c82
callq 0x83630
leaq 0xf6c38(%rip), %rdi     # 0x183c8e
callq 0x83630
leaq 0xf6c3d(%rip), %rdi     # 0x183c9f
callq 0x83630
leaq 0xf6c43(%rip), %rdi     # 0x183cb1
callq 0x83630
leaq 0xf6c4a(%rip), %rdi     # 0x183cc4
callq 0x83630
leaq 0x1ed4de(%rip), %rax    # 0x27a564
movl $0x1, (%rax)
jmp 0x8d08e
jmp 0x8d090
jmp 0x8d092
jmp 0x8d094
jmp 0x8d096
jmp 0x8d098
jmp 0x8d09a
addq $0x10, %rsp
popq %rbp
retq