// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: set_ticc_config(unsigned int, char*)
void set_ticc_config(unsigned port, char *s)
{
unsigned i;
int old_ticc_mode;
#define TICC_CHAR_WAIT 0    // 60  - possible delay needed after each char sent
#define TICC_MSG_WAIT  300  // 200 - delay needed after a param change command sent (min val that worked was 150)
#define TICC_MENU_WAIT 600  // 1000 - delay after entering menu mode (min val that worked was 300)
#define TICC_EE_WAIT   300  // 200 ok 2000  - delay after sending an EEPROM write command (min value that worked was 100)
                            // warm_reset() and factory_reset() commands have longer delays in them

   // send a config command to the TICC   // aaaaahhhhh
   // if (s == 0) get the TICC configuration from the menu
   if(read_only) return;
   if(ticc_sim_file) return;  //lfs LARS_TICC

   if(port >= NUM_COM_PORTS) return;
   old_ticc_mode = ticc_mode;

   sendout(port, '#', ADD_CHAR);  // break TICC out of the processing loop and get to the menu
   sendout(port, 0, FLUSH_COM);
   Sleep(TICC_MSG_WAIT);     // allow TICC to process the data
   reset_com_timer(port);

   get_ticc_info(port);      // process the ticc menu config header

   sendout(port, '#', ADD_CHAR);  // get to the TICC config menu
   sendout(port, 0, FLUSH_COM);
   Sleep(TICC_MENU_WAIT);
reset_com_timer(port);

   if(s) {   // send the command to the TICC
      for(i=0; i<strlen(s); i++) {  // send command string to the TICC
         sendout(port, s[i], ADD_CHAR);
         if(TICC_CHAR_WAIT) Sleep(TICC_CHAR_WAIT);
      }
      sendout(port, 0x0D, ADD_CHAR);
      sendout(port, 0, FLUSH_COM);
      Sleep(TICC_MSG_WAIT);    // wait for TICC to resend the menu

      sendout(port, 'W', ADD_CHAR); // W)rite changes to TICC EEPROM and exit menu
      sendout(port, 0, FLUSH_COM);
      Sleep(TICC_EE_WAIT);     // we must rate limit EEPROM commands
   }
   else {    // we were just getting the config
      sendout(port, 'Z', ADD_CHAR); // Exit menu without writing to TICC EEPROM
      sendout(port, 0, FLUSH_COM);
      Sleep(TICC_MSG_WAIT);
   }

reset_com_timer(RCVR_PORT);
   drain_port(port);  // flush TICC output
reset_com_timer(RCVR_PORT);

if(s == 0) ; 
else if(dont_reset_queues) ; 
   else {
      ticc_packets = 0;  // causes queues to flush after 10 packets
      new_queue(RESET_ALL_QUEUES, 102);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x12, %edi
ja 0x5c5f7
leaq 0x2c4b71(%rip), %rax    # 0x32101a
cmpb $0x0, (%rax)
jne 0x5c5f7
leaq 0x1cbedf(%rip), %rax    # 0x228398
cmpq $0x0, (%rax)
jne 0x5c5f7
movq %rsi, %rbx
movl %edi, %r14d
pushq $0x23
popq %r15
xorl %r13d, %r13d
movl %r15d, %esi
xorl %edx, %edx
callq 0xba3b
pushq $0x2
popq %r12
movl %r14d, %edi
xorl %esi, %esi
movl %r12d, %edx
callq 0xba3b
movl $0x12c, %edi            # imm = 0x12C
callq 0xae83
movl %r14d, %edi
callq 0x1d93f
movl %r14d, %edi
callq 0x9d11f
movl %r14d, %edi
movl %r15d, %esi
xorl %edx, %edx
callq 0xba3b
movl %r14d, %edi
xorl %esi, %esi
movl %r12d, %edx
callq 0xba3b
movl $0x258, %edi            # imm = 0x258
callq 0xae83
movl %r14d, %edi
callq 0x1d93f
testq %rbx, %rbx
jne 0x5c54d
movb $0x5a, %al
jmp 0x5c583
movzbl (%rbx,%r15), %esi
movl %r14d, %edi
xorl %edx, %edx
callq 0xba3b
leal 0x1(%r15), %r13d
movl %r13d, %r15d
movq %rbx, %rdi
callq 0x9120
cmpq %r15, %rax
ja 0x5c53a
pushq $0xd
popq %rsi
movl %r14d, %edi
xorl %edx, %edx
callq 0xba3b
pushq $0x2
popq %rdx
movl %r14d, %edi
xorl %esi, %esi
callq 0xba3b
movl $0x12c, %edi            # imm = 0x12C
callq 0xae83
movb $0x57, %al
movzbl %al, %esi
movl %r14d, %edi
xorl %edx, %edx
callq 0xba3b
pushq $0x2
popq %rdx
movl %r14d, %edi
xorl %esi, %esi
callq 0xba3b
movl $0x12c, %edi            # imm = 0x12C
callq 0xae83
pushq $0xa
popq %r15
movl %r15d, %edi
callq 0x1d93f
movl %r14d, %edi
callq 0x5142f
movl %r15d, %edi
callq 0x1d93f
testq %rbx, %rbx
je 0x5c5f7
leaq 0xfe691(%rip), %rax     # 0x15ac60
cmpl $0x0, (%rax)
jne 0x5c5f7
leaq 0x1cc9a1(%rip), %rax    # 0x228f7c
andl $0x0, (%rax)
pushq $0x7
popq %rdi
pushq $0x66
popq %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10a99
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq