// File: 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
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
leaq 0x30c7f4(%rip), %rax    # 0x3961fa
cmpb $0x0, (%rax)
je 0x89a10
jmp 0x89bba
leaq 0x213b61(%rip), %rax    # 0x29d578
cmpq $0x0, (%rax)
je 0x89a22
jmp 0x89bba
cmpl $0x13, -0x4(%rbp)
jb 0x89a2d
jmp 0x89bba
leaq 0x2e24b8(%rip), %rax    # 0x36beec
movl (%rax), %eax
movl %eax, -0x18(%rbp)
movl -0x4(%rbp), %edi
movl $0x23, %esi
xorl %edx, %edx
callq 0xd160
movl -0x4(%rbp), %edi
xorl %esi, %esi
movl $0x2, %edx
callq 0xd160
movl $0x12c, %edi            # imm = 0x12C
callq 0xb8b0
movl -0x4(%rbp), %edi
callq 0x2bd30
movl -0x4(%rbp), %edi
callq 0xeadf0
movl -0x4(%rbp), %edi
movl $0x23, %esi
xorl %edx, %edx
callq 0xd160
movl -0x4(%rbp), %edi
xorl %esi, %esi
movl $0x2, %edx
callq 0xd160
movl $0x258, %edi            # imm = 0x258
callq 0xb8b0
movl -0x4(%rbp), %edi
callq 0x2bd30
cmpq $0x0, -0x10(%rbp)
je 0x89b41
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x9120
movq %rax, %rcx
movq -0x20(%rbp), %rax
cmpq %rcx, %rax
jae 0x89aef
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
xorl %edx, %edx
movzbl (%rax,%rcx), %esi
callq 0xd160
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x89ab3
movl -0x4(%rbp), %edi
movl $0xd, %esi
xorl %edx, %edx
callq 0xd160
movl -0x4(%rbp), %edi
xorl %esi, %esi
movl $0x2, %edx
callq 0xd160
movl $0x12c, %edi            # imm = 0x12C
callq 0xb8b0
movl -0x4(%rbp), %edi
movl $0x57, %esi
xorl %edx, %edx
callq 0xd160
movl -0x4(%rbp), %edi
xorl %esi, %esi
movl $0x2, %edx
callq 0xd160
movl $0x12c, %edi            # imm = 0x12C
callq 0xb8b0
jmp 0x89b69
movl -0x4(%rbp), %edi
movl $0x5a, %esi
xorl %edx, %edx
callq 0xd160
movl -0x4(%rbp), %edi
xorl %esi, %esi
movl $0x2, %edx
callq 0xd160
movl $0x12c, %edi            # imm = 0x12C
callq 0xb8b0
movl $0xa, %edi
callq 0x2bd30
movl -0x4(%rbp), %edi
callq 0x79900
movl $0xa, %edi
callq 0x2bd30
cmpq $0x0, -0x10(%rbp)
jne 0x89b8e
jmp 0x89bba
leaq 0x1462ab(%rip), %rax    # 0x1cfe40
cmpl $0x0, (%rax)
je 0x89b9c
jmp 0x89bb8
leaq 0x2145b9(%rip), %rax    # 0x29e15c
movl $0x0, (%rax)
movl $0x7, %edi
movl $0x66, %esi
callq 0x14df0
jmp 0x89bba
addq $0x20, %rsp
popq %rbp
retq