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

   // request an item from a PRS10 rubidium.  Requests are alternated between
   // a time message and some device parameter.  The parameter requests are 
   // alternated between one of three important parameters and then the lesser
   // important ones.

   test = 0;
   if(test && (polled_q_in != polled_q_out)) {  // we have a special message request queued
      send_queued_cmd(1);
   }
   else if(1) { // request next misc message every time
      if((test == 0) && (polled_q_in != polled_q_out)) {  // we have a special message request queued
         send_queued_cmd(2);
      }
      else {  // poll standard messages 
      if(polled_req < 0) polled_req = 0;

         if(0 && ((polled_seq % 8) == 0)) {       // get FC value every two seconds
            send_polled_cmd("FC?", PRS_FC_MSG);
         }
         else if(0 && ((polled_seq % 8) == 1)) {  // get TT value every two seconds
            send_polled_cmd("TT?", PRS_TT_MSG);
         }
         else if(0 && ((polled_seq % 8) == 2)) {  // get case temperature value every two seconds
            send_polled_cmd("AD10?", PRS_AD10_MSG);
         }
         else if(1 && prs_poll_tick) {
            if(prs_poll_tick == 1) {       // get FC value every two seconds
               send_polled_cmd("FC?", PRS_FC_MSG);
               ++prs_poll_tick;
            }
            else if(prs_poll_tick == 2) {  // get TT value every two seconds
               send_polled_cmd("TT?", PRS_TT_MSG);
               ++prs_poll_tick;
            }
            else {  // get case temperature value every two seconds
               send_polled_cmd("AD10?", PRS_AD10_MSG);
               prs_poll_tick = 0;
            }
         }
         else {
            // 52 message cycle repeats every 12 seconds -> 4.33 messages per second with PRS_SLEEP == 0
            // 52 message cycle repeats every 13 seconds -> 4.00 messages per second with PRS_SLEEP == 100

            if     (polled_req == 0)  send_polled_cmd("ID?",   PRS_ID_MSG);  // we get serial number from here, not from SN?
            else if(polled_req == 1)  send_polled_cmd("EP?",   PRS_EP_MSG);  // enable power
            else if(polled_req == 2)  send_polled_cmd("VB?",   PRS_VB_MSG);
            else if(polled_req == 3)  send_polled_cmd("ST?",   PRS_ST_MSG);
            else if(polled_req == 4)  send_polled_cmd("LM?",   PRS_LM_MSG);
            else if(polled_req == 5)  send_polled_cmd("LO?",   PRS_LO_MSG);
            else if(polled_req == 6)  send_polled_cmd("FC?",   PRS_FC_MSG);
            else if(polled_req == 7)  send_polled_cmd("DS?",   PRS_DS_MSG);
            else if(polled_req == 8)  send_polled_cmd("SF?",   PRS_SF_MSG);
            else if(polled_req == 9)  send_polled_cmd("SS?",   PRS_SS_MSG);
            else if(polled_req == 10) send_polled_cmd("GA?",   PRS_GA_MSG);
            else if(polled_req == 11) send_polled_cmd("PH?",   PRS_PH_MSG);
            else if(polled_req == 12) send_polled_cmd("SP?",   PRS_SP_MSG);
            else if(polled_req == 13) send_polled_cmd("MS?",   PRS_MS_MSG);
            else if(polled_req == 14) send_polled_cmd("MO?",   PRS_MO_MSG);
            else if(polled_req == 15) send_polled_cmd("MR?",   PRS_MR_MSG);
            else if(polled_req == 16) send_polled_cmd("FC!?",  PRS_FC2_MSG);  // was TT?
            else if(polled_req == 17) send_polled_cmd("TS?",   PRS_TS_MSG);
            else if(polled_req == 18) send_polled_cmd("TO?",   PRS_TO_MSG);
            else if(polled_req == 19) send_polled_cmd("PL?",   PRS_PL_MSG);
            else if(polled_req == 20) send_polled_cmd("PT?",   PRS_PT_MSG);
            else if(polled_req == 21) send_polled_cmd("PF?",   PRS_PF_MSG);
            else if(polled_req == 22) send_polled_cmd("PI?",   PRS_PI_MSG);

            else if(polled_req == 23) send_polled_cmd("SD0?",  PRS_SD0_MSG);
            else if(polled_req == 24) send_polled_cmd("SD1?",  PRS_SD1_MSG);
            else if(polled_req == 25) send_polled_cmd("SD2?",  PRS_SD2_MSG);
            else if(polled_req == 26) send_polled_cmd("SD3?",  PRS_SD3_MSG);
            else if(polled_req == 27) send_polled_cmd("SD4?",  PRS_SD4_MSG);
            else if(polled_req == 28) send_polled_cmd("SD5?",  PRS_SD5_MSG);
            else if(polled_req == 29) send_polled_cmd("SD6?",  PRS_SD6_MSG);
            else if(polled_req == 30) send_polled_cmd("SD7?",  PRS_SD7_MSG);

            else if(polled_req == 31) send_polled_cmd("AD0?",  PRS_AD0_MSG);
            else if(polled_req == 32) send_polled_cmd("AD1?",  PRS_AD1_MSG);
            else if(polled_req == 33) send_polled_cmd("AD2?",  PRS_AD2_MSG);
            else if(polled_req == 34) send_polled_cmd("AD3?",  PRS_AD3_MSG);
            else if(polled_req == 35) send_polled_cmd("AD4?",  PRS_AD4_MSG);
            else if(polled_req == 36) send_polled_cmd("AD5?",  PRS_AD5_MSG);
            else if(polled_req == 37) send_polled_cmd("AD6?",  PRS_AD6_MSG);
            else if(polled_req == 38) send_polled_cmd("AD7?",  PRS_AD7_MSG);
            else if(polled_req == 39) send_polled_cmd("AD8?",  PRS_AD8_MSG);
            else if(polled_req == 40) send_polled_cmd("AD9?",  PRS_AD9_MSG);
            else if(polled_req == 41) send_polled_cmd("AD10?", PRS_AD10_MSG);  // case temp
            else if(polled_req == 42) send_polled_cmd("AD11?", PRS_AD11_MSG);
            else if(polled_req == 43) send_polled_cmd("AD12?", PRS_AD12_MSG);
            else if(polled_req == 44) send_polled_cmd("AD13?", PRS_AD13_MSG);
            else if(polled_req == 45) send_polled_cmd("AD14?", PRS_AD14_MSG);
            else if(polled_req == 46) send_polled_cmd("AD15?", PRS_AD15_MSG);
            else if(polled_req == 47) send_polled_cmd("AD16?", PRS_AD16_MSG);
            else if(polled_req == 48) send_polled_cmd("AD17?", PRS_AD17_MSG);
            else if(polled_req == 49) send_polled_cmd("AD18?", PRS_AD18_MSG);
            else if(polled_req == 50) send_polled_cmd("AD19?", PRS_AD19_MSG);

            else if(polled_req == 51) send_polled_cmd("PS?",   PRS_PS_MSG);

            if(++polled_req > 51) {
               polled_req = 0;
               ++all_polled;
               if(all_polled == 1) {  // reset the queues the first time through
                  new_queue(RESET_ALL_QUEUES, 4598);
               }
            }
         }
         ++polled_seq;
      }
   }
}

// Assembly:
movl 0x300f31(%rip), %eax    # 0x36ffd0
cmpl 0x300f2f(%rip), %eax    # 0x36ffd4
jne 0x6f0e0
cmpl $0x0, 0x300f2e(%rip)    # 0x36ffdc
jns 0x6f0ba
movl $0x0, 0x300f22(%rip)    # 0x36ffdc
pushq %rbp
movq %rsp, %rbp
movl 0x2fdb34(%rip), %eax    # 0x36cbf8
testl %eax, %eax
je 0x6f106
cmpl $0x2, %eax
je 0x6f0ea
cmpl $0x1, %eax
jne 0x6f137
leaq 0xb621b(%rip), %rdi     # 0x1252f4
movl $0x1fc, %esi            # imm = 0x1FC
jmp 0x6f0f6
movl $0x2, %edi
jmp 0x8ab04
leaq 0xb48c7(%rip), %rdi     # 0x1239b8
movl $0x206, %esi            # imm = 0x206
callq 0x6e3bc
incl 0x2fdaf7(%rip)          # 0x36cbf8
jmp 0x6f4df
movl 0x300ed0(%rip), %eax    # 0x36ffdc
cmpq $0x33, %rax
ja 0x6f49f
leaq 0xafa7b(%rip), %rcx     # 0x11eb98
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xb16b5(%rip), %rdi     # 0x1207e2
movl $0x1f6, %esi            # imm = 0x1F6
jmp 0x6f49a
leaq 0xb487e(%rip), %rdi     # 0x1239bc
movl $0x262, %esi            # imm = 0x262
callq 0x6e3bc
movl $0x0, 0x2fdaa6(%rip)    # 0x36cbf8
jmp 0x6f4df
leaq 0xb491b(%rip), %rdi     # 0x123a79
movl $0x26b, %esi            # imm = 0x26B
jmp 0x6f49a
leaq 0xb48e0(%rip), %rdi     # 0x123a4f
movl $0x264, %esi            # imm = 0x264
jmp 0x6f49a
leaq 0xb48b5(%rip), %rdi     # 0x123a35
movl $0x25e, %esi            # imm = 0x25E
jmp 0x6f49a
leaq 0xb48d6(%rip), %rdi     # 0x123a67
movl $0x268, %esi            # imm = 0x268
jmp 0x6f49a
leaq 0xb4889(%rip), %rdi     # 0x123a2b
movl $0x25c, %esi            # imm = 0x25C
jmp 0x6f49a
leaq 0xb487d(%rip), %rdi     # 0x123a30
movl $0x25d, %esi            # imm = 0x25D
jmp 0x6f49a
leaq 0xb483f(%rip), %rdi     # 0x123a03
movl $0x216, %esi            # imm = 0x216
jmp 0x6f49a
leaq 0xb4851(%rip), %rdi     # 0x123a26
movl $0x25b, %esi            # imm = 0x25B
jmp 0x6f49a
leaq 0xb47fc(%rip), %rdi     # 0x1239e2
movl $0x20f, %esi            # imm = 0x20F
jmp 0x6f49a
leaq 0xb485e(%rip), %rdi     # 0x123a55
movl $0x265, %esi            # imm = 0x265
jmp 0x6f49a
leaq 0xb47d2(%rip), %rdi     # 0x1239da
movl $0x204, %esi            # imm = 0x204
jmp 0x6f49a
leaq 0xb4808(%rip), %rdi     # 0x123a21
movl $0x25a, %esi            # imm = 0x25A
jmp 0x6f49a
leaq 0xb4843(%rip), %rdi     # 0x123a6d
movl $0x269, %esi            # imm = 0x269
jmp 0x6f49a
leaq 0xb4797(%rip), %rdi     # 0x1239d2
movl $0x201, %esi            # imm = 0x201
jmp 0x6f49a
leaq 0xb4827(%rip), %rdi     # 0x123a73
movl $0x26a, %esi            # imm = 0x26A
jmp 0x6f49a
leaq 0xb1c9f(%rip), %rdi     # 0x120efc
movl $0x1fa, %esi            # imm = 0x1FA
jmp 0x6f49a
leaq 0xb47d6(%rip), %rdi     # 0x123a44
movl $0x261, %esi            # imm = 0x261
jmp 0x6f49a
leaq 0xb654d(%rip), %rdi     # 0x1257cc
movl $0x202, %esi            # imm = 0x202
jmp 0x6f49a
leaq 0xb2646(%rip), %rdi     # 0x1218d6
movl $0x1ff, %esi            # imm = 0x1FF
jmp 0x6f49a
leaq 0xb4758(%rip), %rdi     # 0x1239f9
movl $0x214, %esi            # imm = 0x214
jmp 0x6f49a
leaq 0xb4742(%rip), %rdi     # 0x1239f4
movl $0x213, %esi            # imm = 0x213
jmp 0x6f49a
leaq 0xb4703(%rip), %rdi     # 0x1239c6
movl $0x1f8, %esi            # imm = 0x1F8
jmp 0x6f49a
leaq 0xb470a(%rip), %rdi     # 0x1239de
movl $0x205, %esi            # imm = 0x205
jmp 0x6f49a
leaq 0xb65b3(%rip), %rdi     # 0x125898
movl $0x1f9, %esi            # imm = 0x1F9
jmp 0x6f49a
leaq 0xb46d4(%rip), %rdi     # 0x1239ca
movl $0x1fd, %esi            # imm = 0x1FD
jmp 0x6f49a
leaq 0xb46bb(%rip), %rdi     # 0x1239c2
movl $0x210, %esi            # imm = 0x210
jmp 0x6f49a
leaq 0xb46ff(%rip), %rdi     # 0x123a17
movl $0x258, %esi            # imm = 0x258
jmp 0x6f49a
leaq 0xb6400(%rip), %rdi     # 0x125729
movl $0x207, %esi            # imm = 0x207
jmp 0x6f49a
leaq 0xb4682(%rip), %rdi     # 0x1239bc
movl $0x262, %esi            # imm = 0x262
jmp 0x6f49a
leaq 0xb250b(%rip), %rdi     # 0x121856
movl $0x20b, %esi            # imm = 0x20B
jmp 0x6f49a
leaq 0xb2035(%rip), %rdi     # 0x121391
movl $0x1fb, %esi            # imm = 0x1FB
jmp 0x6f49a
leaq 0xb24f1(%rip), %rdi     # 0x12185e
movl $0x20c, %esi            # imm = 0x20C
jmp 0x6f49a
leaq 0xb4658(%rip), %rdi     # 0x1239d6
movl $0x203, %esi            # imm = 0x203
jmp 0x6f49a
leaq 0xb5f65(%rip), %rdi     # 0x1252f4
movl $0x1fc, %esi            # imm = 0x1FC
jmp 0x6f49a
leaq 0xb4647(%rip), %rdi     # 0x1239e7
movl $0x208, %esi            # imm = 0x208
jmp 0x6f49a
leaq 0xb24a9(%rip), %rdi     # 0x12185a
movl $0x200, %esi            # imm = 0x200
jmp 0x6f49a
leaq 0xb460c(%rip), %rdi     # 0x1239ce
movl $0x1fe, %esi            # imm = 0x1FE
jmp 0x6f49a
leaq 0xb463f(%rip), %rdi     # 0x123a12
movl $0x219, %esi            # imm = 0x219
jmp 0x6f49a
leaq 0xb4638(%rip), %rdi     # 0x123a1c
movl $0x259, %esi            # imm = 0x259
jmp 0x6f49a
leaq 0xb4666(%rip), %rdi     # 0x123a5b
movl $0x266, %esi            # imm = 0x266
jmp 0x6f49a
leaq 0xb245c(%rip), %rdi     # 0x121862
movl $0x20d, %esi            # imm = 0x20D
jmp 0x6f49a
leaq 0xb4628(%rip), %rdi     # 0x123a3f
movl $0x260, %esi            # imm = 0x260
jmp 0x6f49a
leaq 0xb45c6(%rip), %rdi     # 0x1239eb
movl $0x20a, %esi            # imm = 0x20A
jmp 0x6f49a
leaq 0xb4616(%rip), %rdi     # 0x123a49
movl $0x263, %esi            # imm = 0x263
jmp 0x6f49a
leaq 0xb45ae(%rip), %rdi     # 0x1239ef
movl $0x212, %esi            # imm = 0x212
jmp 0x6f49a
leaq 0xb45b9(%rip), %rdi     # 0x123a08
movl $0x217, %esi            # imm = 0x217
jmp 0x6f49a
leaq 0xb45b0(%rip), %rdi     # 0x123a0d
movl $0x218, %esi            # imm = 0x218
jmp 0x6f49a
leaq 0xb45cf(%rip), %rdi     # 0x123a3a
movl $0x25f, %esi            # imm = 0x25F
jmp 0x6f49a
leaq 0xb4585(%rip), %rdi     # 0x1239fe
movl $0x215, %esi            # imm = 0x215
jmp 0x6f49a
leaq 0xb45da(%rip), %rdi     # 0x123a61
movl $0x267, %esi            # imm = 0x267
jmp 0x6f49a
leaq 0xb45ea(%rip), %rdi     # 0x123a7f
movl $0x209, %esi            # imm = 0x209
callq 0x6e3bc
movl 0x300b37(%rip), %eax    # 0x36ffdc
leal 0x1(%rax), %ecx
movl %ecx, 0x300b2e(%rip)    # 0x36ffdc
cmpl $0x33, %eax
jl 0x6f4df
movl $0x0, 0x300b1f(%rip)    # 0x36ffdc
movl 0x2fc905(%rip), %eax    # 0x36bdc8
leal 0x1(%rax), %ecx
movl %ecx, 0x2fc8fc(%rip)    # 0x36bdc8
testl %eax, %eax
jne 0x6f4df
movl $0x7, %edi
movl $0x11f6, %esi           # imm = 0x11F6
callq 0x1120f
incl 0x300afb(%rip)          # 0x36ffe0
popq %rbp
retq