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

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

   if(need_cs_timeset && cs_remote) {  // set the HP5071A date and time from the system clock
      set_cs_time(need_cs_timeset);
      restore_cs_remote();
   }

   test = 1;
   if(test && (polled_q_in != polled_q_out)) {  // we have a special message request queued
      send_queued_cmd(1);
   }
   else if((cs_msg_id != polled_msg_id) && (cs_msg_id != CS_MJD_MSG)) ;  // only process last requested message
   else if(polled_msg_id == CS_TIME_MSG) { // 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 {
         if(polled_req < 0) polled_req = 0;

         if((polled_seq % 10) == 0)   poll_cs_log();
         else {
            if     (polled_req ==  0) send_polled_cmd("*IDN?",              SCPI_ID_MSG);
            else if(polled_req ==  1) send_polled_cmd("SYST:REM?",          CS_REM_MSG);
            else if(polled_req ==  2) send_polled_cmd(":DISP:ENAB?",        CS_DISP_MSG);
            else if(polled_req ==  3) send_polled_cmd(":PTIM:STAN?",        CS_STANDBY_MSG);
            else if(polled_req ==  4) send_polled_cmd(":ROSC:CONT?",        SCPI_EFC_MSG);
            else if(polled_req ==  5) send_polled_cmd("DIAG:CBTS?",         CS_CBTID_MSG);
            else if(polled_req ==  6) send_polled_cmd("DIAG:CONT:STAT?",    CS_LAMP_MSG);
            else if(polled_req ==  7) send_polled_cmd("DIAG:CURR:BEAM?",    CS_BEAM_MSG);
            else if(polled_req ==  8) send_polled_cmd("DIAG:CURR:PUMP?",    CS_PUMP_MSG);
            else if(polled_req ==  9) send_polled_cmd("DIAG:GAIN?",         CS_GAIN_MSG);
            else if(polled_req == 10) send_polled_cmd("DIAG:RFAM?",         CS_RFAM_MSG);
            else if(polled_req == 11) send_polled_cmd("DIAG:STAT:GLOB?",    CS_GLOB_MSG);
            else if(polled_req == 12) send_polled_cmd("DIAG:STAT:SUPP?",    CS_SUPPLY_MSG);
            else if(polled_req == 13) send_polled_cmd("DIAG:TEMP?",         CS_TEMP_MSG);
            else if(polled_req == 14) send_polled_cmd("DIAG:VOLT:COV?",     CS_COVEN_MSG);
            else if(polled_req == 15) send_polled_cmd("DIAG:VOLT:ROSC?",    CS_QOVEN_MSG);
            else if(polled_req == 16) send_polled_cmd("DIAG:VOLT:EMUL?",    CS_EMUL_MSG);
            else if(polled_req == 17) send_polled_cmd("DIAG:VOLT:HWI?",     CS_HWI_MSG);
            else if(polled_req == 18) send_polled_cmd("DIAG:VOLT:MSP?",     CS_MSP_MSG);
            else if(polled_req == 19) send_polled_cmd("DIAG:VOLT:PLL?",     CS_PLL_MSG);
            else if(polled_req == 20) send_polled_cmd("DIAG:VOLT:SUPP?",    CS_VOLT_MSG);
            else if(polled_req == 21) send_polled_cmd("DIAG:CURR:CFI?",     CS_CFIELD_MSG);
            else if(polled_req == 22) send_polled_cmd(":ROSC:FREQ1?",       CS_FREQ1_MSG);
            else if(polled_req == 23) send_polled_cmd(":ROSC:FREQ2?",       CS_FREQ2_MSG);
            else if(polled_req == 24) send_polled_cmd(":ROSC:STE?",         CS_STER_MSG);
            else if(polled_req == 25) send_polled_cmd(":PTIM:SYNC?",        CS_SYNC_MSG);
            else if(polled_req == 26) send_polled_cmd(":PTIM:LEAP:STAT?",   CS_LEAPSTAT_MSG);
            else if(polled_req == 27) send_polled_cmd(":PTIM:LEAP:DUR?",    CS_LEAPDUR_MSG);
            else if(polled_req == 28) send_polled_cmd(":PTIM:LEAP:MJD?",    CS_LEAPMJD_MSG);
            else if(polled_req == 29) send_polled_cmd("DIAG:LOG:COUN?",     CS_LOGCOUNT_MSG);

            if(++polled_req > 29) {  // start the request cycle over
               polled_req = 0;
               if(all_polled == 0) {
                  new_queue(RESET_ALL_QUEUES, 123);
               }
               ++all_polled;
            }
         }
         ++polled_seq;
      }
   }
   else {
      send_polled_cmd(":PTIM:MJD?", CS_MJD_MSG);   // request date message
      send_polled_cmd(":PTIM:TIME?", CS_TIME_MSG); // request time message
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
leaq 0x1e3131(%rip), %rax    # 0x279bf0
cmpb $0x0, (%rax)
je 0x96ae4
leaq 0x1e30f1(%rip), %rax    # 0x279bbc
cmpl $0x0, (%rax)
je 0x96ae4
leaq 0x1e3119(%rip), %rax    # 0x279bf0
movsbl (%rax), %edi
callq 0xdc810
callq 0x89260
movl $0x1, -0x4(%rbp)
cmpl $0x0, -0x4(%rbp)
je 0x96b0e
movl 0x3386a9(%rip), %eax    # 0x3cf1a0
cmpl 0x3386a7(%rip), %eax    # 0x3cf1a4
je 0x96b0e
movl $0x1, %edi
callq 0xbd7c0
jmp 0x96fda
movl 0x33a6dc(%rip), %eax    # 0x3d11f0
cmpl 0x3352b6(%rip), %eax    # 0x3cbdd0
je 0x96b2d
cmpl $0x12d, 0x33a6ca(%rip)  # imm = 0x12D
je 0x96b2d
jmp 0x96fd8
cmpl $0x12c, 0x335299(%rip)  # imm = 0x12C
jne 0x96fb4
cmpl $0x0, -0x4(%rbp)
jne 0x96b60
movl 0x338657(%rip), %eax    # 0x3cf1a0
cmpl 0x338655(%rip), %eax    # 0x3cf1a4
je 0x96b60
movl $0x2, %edi
callq 0xbd7c0
jmp 0x96fb2
cmpl $0x0, 0x338645(%rip)    # 0x3cf1ac
jge 0x96b73
movl $0x0, 0x338639(%rip)    # 0x3cf1ac
movl 0x338637(%rip), %eax    # 0x3cf1b0
movl $0xa, %ecx
xorl %edx, %edx
divl %ecx
cmpl $0x0, %edx
jne 0x96b91
callq 0xdc700
jmp 0x96fa3
cmpl $0x0, 0x338614(%rip)    # 0x3cf1ac
jne 0x96bb0
leaq 0xeddb6(%rip), %rdi     # 0x184957
movl $0x1c, %esi
callq 0x96370
jmp 0x96f5c
cmpl $0x1, 0x3385f5(%rip)    # 0x3cf1ac
jne 0x96bcf
leaq 0xecea9(%rip), %rdi     # 0x183a69
movl $0x146, %esi            # imm = 0x146
callq 0x96370
jmp 0x96f5a
cmpl $0x2, 0x3385d6(%rip)    # 0x3cf1ac
jne 0x96bee
leaq 0xf1f0b(%rip), %rdi     # 0x188aea
movl $0x145, %esi            # imm = 0x145
callq 0x96370
jmp 0x96f58
cmpl $0x3, 0x3385b7(%rip)    # 0x3cf1ac
jne 0x96c0d
leaq 0xedaef(%rip), %rdi     # 0x1846ed
movl $0x143, %esi            # imm = 0x143
callq 0x96370
jmp 0x96f56
cmpl $0x4, 0x338598(%rip)    # 0x3cf1ac
jne 0x96c2c
leaq 0xed9c5(%rip), %rdi     # 0x1845e2
movl $0xb, %esi
callq 0x96370
jmp 0x96f54
cmpl $0x5, 0x338579(%rip)    # 0x3cf1ac
jne 0x96c4b
leaq 0xf1eba(%rip), %rdi     # 0x188af6
movl $0x12e, %esi            # imm = 0x12E
callq 0x96370
jmp 0x96f52
cmpl $0x6, 0x33855a(%rip)    # 0x3cf1ac
jne 0x96c6a
leaq 0xecd3c(%rip), %rdi     # 0x183997
movl $0x14d, %esi            # imm = 0x14D
callq 0x96370
jmp 0x96f50
cmpl $0x7, 0x33853b(%rip)    # 0x3cf1ac
jne 0x96c89
leaq 0xf1e87(%rip), %rdi     # 0x188b01
movl $0x130, %esi            # imm = 0x130
callq 0x96370
jmp 0x96f4e
cmpl $0x8, 0x33851c(%rip)    # 0x3cf1ac
jne 0x96ca8
leaq 0xf1e78(%rip), %rdi     # 0x188b11
movl $0x131, %esi            # imm = 0x131
callq 0x96370
jmp 0x96f4c
cmpl $0x9, 0x3384fd(%rip)    # 0x3cf1ac
jne 0x96cc7
leaq 0xf1e69(%rip), %rdi     # 0x188b21
movl $0x132, %esi            # imm = 0x132
callq 0x96370
jmp 0x96f4a
cmpl $0xa, 0x3384de(%rip)    # 0x3cf1ac
jne 0x96ce6
leaq 0xf1e55(%rip), %rdi     # 0x188b2c
movl $0x133, %esi            # imm = 0x133
callq 0x96370
jmp 0x96f48
cmpl $0xb, 0x3384bf(%rip)    # 0x3cf1ac
jne 0x96d05
leaq 0xf1e41(%rip), %rdi     # 0x188b37
movl $0x134, %esi            # imm = 0x134
callq 0x96370
jmp 0x96f46
cmpl $0xc, 0x3384a0(%rip)    # 0x3cf1ac
jne 0x96d24
leaq 0xf1e32(%rip), %rdi     # 0x188b47
movl $0x135, %esi            # imm = 0x135
callq 0x96370
jmp 0x96f44
cmpl $0xd, 0x338481(%rip)    # 0x3cf1ac
jne 0x96d43
leaq 0xedb7d(%rip), %rdi     # 0x1848b1
movl $0x136, %esi            # imm = 0x136
callq 0x96370
jmp 0x96f42
cmpl $0xe, 0x338462(%rip)    # 0x3cf1ac
jne 0x96d62
leaq 0xf1e04(%rip), %rdi     # 0x188b57
movl $0x137, %esi            # imm = 0x137
callq 0x96370
jmp 0x96f40
cmpl $0xf, 0x338443(%rip)    # 0x3cf1ac
jne 0x96d81
leaq 0xf1df4(%rip), %rdi     # 0x188b66
movl $0x13c, %esi            # imm = 0x13C
callq 0x96370
jmp 0x96f3e
cmpl $0x10, 0x338424(%rip)   # 0x3cf1ac
jne 0x96da0
leaq 0xf1de5(%rip), %rdi     # 0x188b76
movl $0x138, %esi            # imm = 0x138
callq 0x96370
jmp 0x96f3c
cmpl $0x11, 0x338405(%rip)   # 0x3cf1ac
jne 0x96dbf
leaq 0xf1dd6(%rip), %rdi     # 0x188b86
movl $0x139, %esi            # imm = 0x139
callq 0x96370
jmp 0x96f3a
cmpl $0x12, 0x3383e6(%rip)   # 0x3cf1ac
jne 0x96dde
leaq 0xf1dc6(%rip), %rdi     # 0x188b95
movl $0x13a, %esi            # imm = 0x13A
callq 0x96370
jmp 0x96f38
cmpl $0x13, 0x3383c7(%rip)   # 0x3cf1ac
jne 0x96dfd
leaq 0xf1db6(%rip), %rdi     # 0x188ba4
movl $0x13b, %esi            # imm = 0x13B
callq 0x96370
jmp 0x96f36
cmpl $0x14, 0x3383a8(%rip)   # 0x3cf1ac
jne 0x96e1c
leaq 0xf1da6(%rip), %rdi     # 0x188bb3
movl $0x13d, %esi            # imm = 0x13D
callq 0x96370
jmp 0x96f34
cmpl $0x15, 0x338389(%rip)   # 0x3cf1ac
jne 0x96e3b
leaq 0xf1d97(%rip), %rdi     # 0x188bc3
movl $0x13e, %esi            # imm = 0x13E
callq 0x96370
jmp 0x96f32
cmpl $0x16, 0x33836a(%rip)   # 0x3cf1ac
jne 0x96e5a
leaq 0xf1d87(%rip), %rdi     # 0x188bd2
movl $0x13f, %esi            # imm = 0x13F
callq 0x96370
jmp 0x96f30
cmpl $0x17, 0x33834b(%rip)   # 0x3cf1ac
jne 0x96e79
leaq 0xf1d75(%rip), %rdi     # 0x188bdf
movl $0x140, %esi            # imm = 0x140
callq 0x96370
jmp 0x96f2e
cmpl $0x18, 0x33832c(%rip)   # 0x3cf1ac
jne 0x96e98
leaq 0xf1d63(%rip), %rdi     # 0x188bec
movl $0x141, %esi            # imm = 0x141
callq 0x96370
jmp 0x96f2c
cmpl $0x19, 0x33830d(%rip)   # 0x3cf1ac
jne 0x96eb4
leaq 0xf1d4f(%rip), %rdi     # 0x188bf7
movl $0x142, %esi            # imm = 0x142
callq 0x96370
jmp 0x96f2a
cmpl $0x1a, 0x3382f1(%rip)   # 0x3cf1ac
jne 0x96ed0
leaq 0xf1d3f(%rip), %rdi     # 0x188c03
movl $0x147, %esi            # imm = 0x147
callq 0x96370
jmp 0x96f28
cmpl $0x1b, 0x3382d5(%rip)   # 0x3cf1ac
jne 0x96eec
leaq 0xf1d34(%rip), %rdi     # 0x188c14
movl $0x148, %esi            # imm = 0x148
callq 0x96370
jmp 0x96f26
cmpl $0x1c, 0x3382b9(%rip)   # 0x3cf1ac
jne 0x96f08
leaq 0xf1d28(%rip), %rdi     # 0x188c24
movl $0x149, %esi            # imm = 0x149
callq 0x96370
jmp 0x96f24
cmpl $0x1d, 0x33829d(%rip)   # 0x3cf1ac
jne 0x96f22
leaq 0xf1d1c(%rip), %rdi     # 0x188c34
movl $0x14a, %esi            # imm = 0x14A
callq 0x96370
jmp 0x96f24
jmp 0x96f26
jmp 0x96f28
jmp 0x96f2a
jmp 0x96f2c
jmp 0x96f2e
jmp 0x96f30
jmp 0x96f32
jmp 0x96f34
jmp 0x96f36
jmp 0x96f38
jmp 0x96f3a
jmp 0x96f3c
jmp 0x96f3e
jmp 0x96f40
jmp 0x96f42
jmp 0x96f44
jmp 0x96f46
jmp 0x96f48
jmp 0x96f4a
jmp 0x96f4c
jmp 0x96f4e
jmp 0x96f50
jmp 0x96f52
jmp 0x96f54
jmp 0x96f56
jmp 0x96f58
jmp 0x96f5a
jmp 0x96f5c
movl 0x33824a(%rip), %eax    # 0x3cf1ac
addl $0x1, %eax
movl %eax, 0x338241(%rip)    # 0x3cf1ac
cmpl $0x1d, %eax
jle 0x96fa1
movl $0x0, 0x338232(%rip)    # 0x3cf1ac
cmpl $0x0, 0x334027(%rip)    # 0x3cafa8
jne 0x96f92
movl $0x7, %edi
movl $0x7b, %esi
callq 0x14df0
movl 0x334010(%rip), %eax    # 0x3cafa8
addl $0x1, %eax
movl %eax, 0x334007(%rip)    # 0x3cafa8
jmp 0x96fa3
movl 0x338207(%rip), %eax    # 0x3cf1b0
addl $0x1, %eax
movl %eax, 0x3381fe(%rip)    # 0x3cf1b0
jmp 0x96fd6
leaq 0xed901(%rip), %rdi     # 0x1848bc
movl $0x12d, %esi            # imm = 0x12D
callq 0x96370
leaq 0xed8fb(%rip), %rdi     # 0x1848c7
movl $0x12c, %esi            # imm = 0x12C
callq 0x96370
jmp 0x96fd8
jmp 0x96fda
addq $0x10, %rsp
popq %rbp
retq