// File: /workspace/github_cpp_makefile_star2_O3/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 0x300fb6(%rip), %eax    # 0x36ffd0
cmpl 0x300fb4(%rip), %eax    # 0x36ffd4
jne 0x6f05e
movl 0x300fb4(%rip), %eax    # 0x36ffdc
testl %eax, %eax
jns 0x6f038
movl $0x0, 0x300fa6(%rip)    # 0x36ffdc
xorl %eax, %eax
pushq %rbp
movq %rsp, %rbp
movl 0x2fdbb6(%rip), %ecx    # 0x36cbf8
testl %ecx, %ecx
je 0x6f084
cmpl $0x2, %ecx
je 0x6f068
cmpl $0x1, %ecx
jne 0x6f0b0
leaq 0xb637d(%rip), %rdi     # 0x1253d4
movl $0x1fc, %esi            # imm = 0x1FC
jmp 0x6f074
movl $0x2, %edi
jmp 0x8aadd
leaq 0xb4a29(%rip), %rdi     # 0x123a98
movl $0x206, %esi            # imm = 0x206
callq 0x6e2d1
incl 0x2fdb79(%rip)          # 0x36cbf8
jmp 0x6f458
cmpl $0x33, %eax
ja 0x6f42c
movl %eax, %eax
leaq 0xafbc2(%rip), %rcx     # 0x11ec58
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xb181c(%rip), %rdi     # 0x1208c2
movl $0x1f6, %esi            # imm = 0x1F6
jmp 0x6f413
leaq 0xb49e5(%rip), %rdi     # 0x123a9c
movl $0x262, %esi            # imm = 0x262
callq 0x6e2d1
movl $0x0, 0x2fdb2d(%rip)    # 0x36cbf8
jmp 0x6f458
leaq 0xb4a82(%rip), %rdi     # 0x123b59
movl $0x26b, %esi            # imm = 0x26B
jmp 0x6f413
leaq 0xb4a47(%rip), %rdi     # 0x123b2f
movl $0x264, %esi            # imm = 0x264
jmp 0x6f413
leaq 0xb4a1c(%rip), %rdi     # 0x123b15
movl $0x25e, %esi            # imm = 0x25E
jmp 0x6f413
leaq 0xb4a3d(%rip), %rdi     # 0x123b47
movl $0x268, %esi            # imm = 0x268
jmp 0x6f413
leaq 0xb49f0(%rip), %rdi     # 0x123b0b
movl $0x25c, %esi            # imm = 0x25C
jmp 0x6f413
leaq 0xb49e4(%rip), %rdi     # 0x123b10
movl $0x25d, %esi            # imm = 0x25D
jmp 0x6f413
leaq 0xb49a6(%rip), %rdi     # 0x123ae3
movl $0x216, %esi            # imm = 0x216
jmp 0x6f413
leaq 0xb49b8(%rip), %rdi     # 0x123b06
movl $0x25b, %esi            # imm = 0x25B
jmp 0x6f413
leaq 0xb4963(%rip), %rdi     # 0x123ac2
movl $0x20f, %esi            # imm = 0x20F
jmp 0x6f413
leaq 0xb49c5(%rip), %rdi     # 0x123b35
movl $0x265, %esi            # imm = 0x265
jmp 0x6f413
leaq 0xb4939(%rip), %rdi     # 0x123aba
movl $0x204, %esi            # imm = 0x204
jmp 0x6f413
leaq 0xb496f(%rip), %rdi     # 0x123b01
movl $0x25a, %esi            # imm = 0x25A
jmp 0x6f413
leaq 0xb49aa(%rip), %rdi     # 0x123b4d
movl $0x269, %esi            # imm = 0x269
jmp 0x6f413
leaq 0xb48fe(%rip), %rdi     # 0x123ab2
movl $0x201, %esi            # imm = 0x201
jmp 0x6f413
leaq 0xb498e(%rip), %rdi     # 0x123b53
movl $0x26a, %esi            # imm = 0x26A
jmp 0x6f413
leaq 0xb1e06(%rip), %rdi     # 0x120fdc
movl $0x1fa, %esi            # imm = 0x1FA
jmp 0x6f413
leaq 0xb493d(%rip), %rdi     # 0x123b24
movl $0x261, %esi            # imm = 0x261
jmp 0x6f413
leaq 0xb66b4(%rip), %rdi     # 0x1258ac
movl $0x202, %esi            # imm = 0x202
jmp 0x6f413
leaq 0xb27ad(%rip), %rdi     # 0x1219b6
movl $0x1ff, %esi            # imm = 0x1FF
jmp 0x6f413
leaq 0xb48bf(%rip), %rdi     # 0x123ad9
movl $0x214, %esi            # imm = 0x214
jmp 0x6f413
leaq 0xb48a9(%rip), %rdi     # 0x123ad4
movl $0x213, %esi            # imm = 0x213
jmp 0x6f413
leaq 0xb486a(%rip), %rdi     # 0x123aa6
movl $0x1f8, %esi            # imm = 0x1F8
jmp 0x6f413
leaq 0xb4871(%rip), %rdi     # 0x123abe
movl $0x205, %esi            # imm = 0x205
jmp 0x6f413
leaq 0xb671a(%rip), %rdi     # 0x125978
movl $0x1f9, %esi            # imm = 0x1F9
jmp 0x6f413
leaq 0xb483b(%rip), %rdi     # 0x123aaa
movl $0x1fd, %esi            # imm = 0x1FD
jmp 0x6f413
leaq 0xb4822(%rip), %rdi     # 0x123aa2
movl $0x210, %esi            # imm = 0x210
jmp 0x6f413
leaq 0xb4866(%rip), %rdi     # 0x123af7
movl $0x258, %esi            # imm = 0x258
jmp 0x6f413
leaq 0xb6567(%rip), %rdi     # 0x125809
movl $0x207, %esi            # imm = 0x207
jmp 0x6f413
leaq 0xb47e9(%rip), %rdi     # 0x123a9c
movl $0x262, %esi            # imm = 0x262
jmp 0x6f413
leaq 0xb2672(%rip), %rdi     # 0x121936
movl $0x20b, %esi            # imm = 0x20B
jmp 0x6f413
leaq 0xb219c(%rip), %rdi     # 0x121471
movl $0x1fb, %esi            # imm = 0x1FB
jmp 0x6f413
leaq 0xb2658(%rip), %rdi     # 0x12193e
movl $0x20c, %esi            # imm = 0x20C
jmp 0x6f413
leaq 0xb47bf(%rip), %rdi     # 0x123ab6
movl $0x203, %esi            # imm = 0x203
jmp 0x6f413
leaq 0xb60cc(%rip), %rdi     # 0x1253d4
movl $0x1fc, %esi            # imm = 0x1FC
jmp 0x6f413
leaq 0xb47ae(%rip), %rdi     # 0x123ac7
movl $0x208, %esi            # imm = 0x208
jmp 0x6f413
leaq 0xb2610(%rip), %rdi     # 0x12193a
movl $0x200, %esi            # imm = 0x200
jmp 0x6f413
leaq 0xb4773(%rip), %rdi     # 0x123aae
movl $0x1fe, %esi            # imm = 0x1FE
jmp 0x6f413
leaq 0xb47a6(%rip), %rdi     # 0x123af2
movl $0x219, %esi            # imm = 0x219
jmp 0x6f413
leaq 0xb479f(%rip), %rdi     # 0x123afc
movl $0x259, %esi            # imm = 0x259
jmp 0x6f413
leaq 0xb47cd(%rip), %rdi     # 0x123b3b
movl $0x266, %esi            # imm = 0x266
jmp 0x6f413
leaq 0xb25c3(%rip), %rdi     # 0x121942
movl $0x20d, %esi            # imm = 0x20D
jmp 0x6f413
leaq 0xb478f(%rip), %rdi     # 0x123b1f
movl $0x260, %esi            # imm = 0x260
jmp 0x6f413
leaq 0xb472d(%rip), %rdi     # 0x123acb
movl $0x20a, %esi            # imm = 0x20A
jmp 0x6f413
leaq 0xb477d(%rip), %rdi     # 0x123b29
movl $0x263, %esi            # imm = 0x263
jmp 0x6f413
leaq 0xb4715(%rip), %rdi     # 0x123acf
movl $0x212, %esi            # imm = 0x212
jmp 0x6f413
leaq 0xb4720(%rip), %rdi     # 0x123ae8
movl $0x217, %esi            # imm = 0x217
jmp 0x6f413
leaq 0xb4717(%rip), %rdi     # 0x123aed
movl $0x218, %esi            # imm = 0x218
jmp 0x6f413
leaq 0xb4736(%rip), %rdi     # 0x123b1a
movl $0x25f, %esi            # imm = 0x25F
jmp 0x6f413
leaq 0xb46ec(%rip), %rdi     # 0x123ade
movl $0x215, %esi            # imm = 0x215
jmp 0x6f413
leaq 0xb4741(%rip), %rdi     # 0x123b41
movl $0x267, %esi            # imm = 0x267
jmp 0x6f413
leaq 0xb4751(%rip), %rdi     # 0x123b5f
movl $0x209, %esi            # imm = 0x209
callq 0x6e2d1
movl 0x300bbe(%rip), %eax    # 0x36ffdc
leal 0x1(%rax), %ecx
movl %ecx, 0x300bb5(%rip)    # 0x36ffdc
cmpl $0x33, %eax
jl 0x6f458
movl $0x0, 0x300ba6(%rip)    # 0x36ffdc
movl 0x2fc98c(%rip), %eax    # 0x36bdc8
leal 0x1(%rax), %ecx
movl %ecx, 0x2fc983(%rip)    # 0x36bdc8
testl %eax, %eax
jne 0x6f458
movl $0x7, %edi
movl $0x11f6, %esi           # imm = 0x11F6
callq 0x1118c
incl 0x300b82(%rip)          # 0x36ffe0
popq %rbp
retq