// File: /workspace/github_cpp_makefile_star2_O3/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 0x2d00a9(%rip), %rax    # 0x33701a
cmpb $0x0, (%rax)
jne 0x67419
leaq 0x1b194f(%rip), %rax    # 0x2188d0
movq (%rax), %rax
cmpq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
jg 0x66fd1
cmpq $0x7f, %rax
jg 0x6704e
cmpq $0x4, %rax
je 0x67119
cmpq $0x20, %rax
jne 0x67419
leaq 0x1b4073(%rip), %rax    # 0x21b024
movl (%rax), %eax
cmpl $0x8, %eax
je 0x672f7
cmpl $0x6, %eax
jne 0x6730e
leaq 0xb99fe(%rip), %rdi     # 0x1209ca
jmp 0x672fe
movabsq $0x1ffffffff, %rcx      # imm = 0x1FFFFFFFF
cmpq %rcx, %rax
jg 0x670b9
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
je 0x671c1
movabsq $0x100000000, %rcx      # imm = 0x100000000
cmpq %rcx, %rax
jne 0x67419
leaq 0x1b436c(%rip), %rax    # 0x21b378
movl (%rax), %eax
testl %eax, %eax
je 0x672b8
leaq 0x1b4363(%rip), %rcx    # 0x21b380
cmpl $0x0, (%rcx)
je 0x673fd
cvtsi2sd %eax, %xmm0
leaq 0x2d51ef(%rip), %r14    # 0x33c220
leaq 0xb999b(%rip), %rsi     # 0x1209d3
movq %r14, %rdi
movb $0x1, %al
callq 0x9060
leaq 0xb9999(%rip), %rbx     # 0x1209e2
jmp 0x672ea
cmpq $0x80, %rax
je 0x671f5
cmpq $0x800, %rax            # imm = 0x800
jne 0x67419
movl $0x24, %edi
callq 0x5e6be
leaq 0x1b4301(%rip), %rbx    # 0x21b378
movl (%rbx), %eax
testl %eax, %eax
movl $0x5, %edi
cmovnel %eax, %edi
movl $0xff, %r14d
andl %r14d, %edi
callq 0x590f7
callq 0x5e7c0
movl $0xf4, %edi
callq 0x5e6be
movl (%rbx), %eax
addl %eax, %eax
leal (%rax,%rax,4), %edi
andl %r14d, %edi
callq 0x590f7
callq 0x5e7c0
jmp 0x6740c
movabsq $0x200000000, %rcx      # imm = 0x200000000
cmpq %rcx, %rax
je 0x6740c
movabsq $0x800000000, %rcx      # imm = 0x800000000
cmpq %rcx, %rax
jne 0x67419
leaq 0x1b4292(%rip), %rbx    # 0x21b378
movl (%rbx), %eax
cmpl $0x5, %eax
je 0x67398
cmpl $0x2, %eax
je 0x67382
cmpl $0x1, %eax
jne 0x673b3
movl $0x97, %edi
movl $0x5, %esi
callq 0x65608
xorl %edi, %edi
jmp 0x673ac
leaq 0x1b4258(%rip), %rbx    # 0x21b378
movl (%rbx), %r14d
testl %r14d, %r14d
je 0x67253
movl $0x1, (%rbx)
movl $0x210, %edi            # imm = 0x210
movl $0x1, %esi
callq 0x6741e
movl (%rbx), %esi
movl $0x215, %edi            # imm = 0x215
callq 0x6741e
movl (%rbx), %esi
movl $0x106, %edi            # imm = 0x106
callq 0x6741e
movl $0x134, %edi            # imm = 0x134
xorl %esi, %esi
callq 0x6741e
movl $0x132, %edi            # imm = 0x132
xorl %esi, %esi
callq 0x6741e
movl (%rbx), %esi
movl $0x211, %edi            # imm = 0x211
callq 0x6741e
movl (%rbx), %esi
movl $0x213, %edi            # imm = 0x213
callq 0x6741e
leaq 0x1b41ec(%rip), %rax    # 0x21b37c
cmpl $0x0, (%rax)
je 0x671ad
movl (%rbx), %esi
movl $0x310, %edi            # imm = 0x310
callq 0x6741e
movl (%rbx), %esi
movl $0x30f, %edi            # imm = 0x30F
callq 0x6741e
movl (%rbx), %esi
movl $0x130, %edi            # imm = 0x130
callq 0x6741e
movl %r14d, (%rbx)
jmp 0x6740c
leaq 0x1b41b0(%rip), %rax    # 0x21b378
xorl %edx, %edx
cmpl $0x0, (%rax)
setne %dl
leaq 0x2d5049(%rip), %rbx    # 0x33c220
leaq 0xb97d8(%rip), %rsi     # 0x1209b6
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
callq 0x5ee9b
jmp 0x6740c
leaq 0x1b417c(%rip), %rax    # 0x21b378
xorl %ebx, %ebx
cmpl $0x0, (%rax)
setne %bl
movl $0x1e, %edi
movl $0x9, %esi
callq 0x5fb3c
xorl %edi, %edi
callq 0x590f7
movl %ebx, %edi
callq 0x590f7
movl %ebx, %edi
callq 0x590f7
movl %ebx, %edi
callq 0x590f7
xorl %edi, %edi
callq 0x590f7
xorl %edi, %edi
callq 0x590f7
movl %ebx, %edi
callq 0x590f7
movl $0x1, %edi
callq 0x5fc00
jmp 0x6740c
movl $0x210, %edi            # imm = 0x210
xorl %esi, %esi
callq 0x6741e
movl $0x215, %edi            # imm = 0x215
xorl %esi, %esi
callq 0x6741e
movl $0x106, %edi            # imm = 0x106
xorl %esi, %esi
callq 0x6741e
movl $0x211, %edi            # imm = 0x211
xorl %esi, %esi
callq 0x6741e
movl $0x213, %edi            # imm = 0x213
xorl %esi, %esi
callq 0x6741e
movl $0x310, %edi            # imm = 0x310
xorl %esi, %esi
callq 0x6741e
movl $0x30f, %edi            # imm = 0x30F
xorl %esi, %esi
callq 0x6741e
movl $0x130, %edi            # imm = 0x130
xorl %esi, %esi
callq 0x6741e
jmp 0x6740c
leaq 0xb9743(%rip), %rdi     # 0x120a02
callq 0x5f2c8
leaq 0xb9743(%rip), %rdi     # 0x120a0e
callq 0x5f2c8
leaq 0xb9748(%rip), %rdi     # 0x120a1f
callq 0x5f2c8
leaq 0xb9761(%rip), %rbx     # 0x120a44
leaq 0xb9747(%rip), %r14     # 0x120a31
movq %r14, %rdi
callq 0x5f2c8
jmp 0x67404
leaq 0xb96cf(%rip), %rdi     # 0x1209cd
callq 0x6160d
leaq 0x1b406e(%rip), %rax    # 0x21b378
movb (%rax), %al
jmp 0x67370
leaq 0xb96bb(%rip), %rdi     # 0x1209d0
callq 0x6160d
leaq 0x1b405f(%rip), %rax    # 0x21b380
cmpl $0x0, (%rax)
movl $0xa, %eax
je 0x67334
leaq 0x1b4046(%rip), %rax    # 0x21b378
movl (%rax), %eax
movzbl %al, %edi
callq 0x590f7
movl $0x2b, %edi
callq 0x590f7
movl $0x2b, %edi
callq 0x590f7
movl $0x2b, %edi
callq 0x590f7
movl $0x2b, %edi
callq 0x590f7
movl $0x2b, %edi
callq 0x590f7
movb $0x2b, %al
movzbl %al, %edi
callq 0x590f7
callq 0x61688
jmp 0x6740c
movl $0x97, %edi
movl $0x5, %esi
callq 0x65608
movl $0x1, %edi
jmp 0x673ac
movl $0x97, %edi
movl $0x5, %esi
callq 0x65608
movl $0x2, %edi
callq 0x590f7
jmp 0x673cf
movl $0x17, %edi
movl $0x5, %esi
callq 0x65608
xorl %edi, %edi
callq 0x590f7
movl $0x0, (%rbx)
movzwl 0x3056e5(%rip), %r14d   # 0x36cabc
movl $0xff, %ebx
movl %r14d, %edi
andl %ebx, %edi
callq 0x590f7
addl %r14d, %ebx
testw %r14w, %r14w
cmovnsl %r14d, %ebx
movzbl %bh, %edi
popq %rbx
popq %r14
popq %rbp
jmp 0x590f7
leaq 0xb95de(%rip), %rbx     # 0x1209e2
movq %rbx, %rdi
callq 0x5f2c8
leaq 0x1b3f71(%rip), %rax    # 0x21b384
movl $0x1, (%rax)
popq %rbx
popq %r14
popq %rbp
retq