// File: /workspace/github_cpp_makefile_star2_O1/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 %r12
pushq %rbx
cmpl $0x12, %edi
ja 0x645d0
leaq 0x2d2ba9(%rip), %rax    # 0x33701a
cmpb $0x0, (%rax)
jne 0x645d0
leaq 0x1d9f17(%rip), %rax    # 0x23e398
cmpq $0x0, (%rax)
jne 0x645d0
movq %rsi, %rbx
movl %edi, %r14d
movl $0x23, %esi
xorl %edx, %edx
callq 0xbcc0
movl %r14d, %edi
xorl %esi, %esi
movl $0x2, %edx
callq 0xbcc0
movl $0x12c, %edi            # imm = 0x12C
callq 0xaff7
movl %r14d, %edi
callq 0x1ea2c
movl %r14d, %edi
callq 0xace66
movl %r14d, %edi
movl $0x23, %esi
xorl %edx, %edx
callq 0xbcc0
movl %r14d, %edi
xorl %esi, %esi
movl $0x2, %edx
callq 0xbcc0
movl $0x258, %edi            # imm = 0x258
callq 0xaff7
movl %r14d, %edi
callq 0x1ea2c
testq %rbx, %rbx
je 0x64557
cmpb $0x0, (%rbx)
je 0x6452b
movl $0x1, %r15d
xorl %r12d, %r12d
movzbl (%rbx,%r12), %esi
movl %r14d, %edi
xorl %edx, %edx
callq 0xbcc0
movl %r15d, %r12d
movq %rbx, %rdi
callq 0x9120
incl %r15d
cmpq %r12, %rax
ja 0x64509
movl %r14d, %edi
movl $0xd, %esi
xorl %edx, %edx
callq 0xbcc0
movl %r14d, %edi
xorl %esi, %esi
movl $0x2, %edx
callq 0xbcc0
movl $0x12c, %edi            # imm = 0x12C
callq 0xaff7
movb $0x57, %al
jmp 0x64559
movb $0x5a, %al
movzbl %al, %esi
movl %r14d, %edi
xorl %edx, %edx
callq 0xbcc0
movl %r14d, %edi
xorl %esi, %esi
movl $0x2, %edx
callq 0xbcc0
movl $0x12c, %edi            # imm = 0x12C
callq 0xaff7
movl $0xa, %edi
callq 0x1ea2c
movl %r14d, %edi
callq 0x5804f
movl $0xa, %edi
callq 0x1ea2c
testq %rbx, %rbx
je 0x645d0
leaq 0x10c6b9(%rip), %rax    # 0x170c60
cmpl $0x0, (%rax)
jne 0x645d0
leaq 0x1da9c9(%rip), %rax    # 0x23ef7c
movl $0x0, (%rax)
movl $0x7, %edi
movl $0x66, %esi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x1120f
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq