InputHandlingControls::InputHandlingControls(HWND hwnd, vncServer *server) { m_server = server; // Remote input settings HWND hEnableRemoteInputs = GetDlgItem(hwnd, IDC_DISABLE_INPUTS); SendMessage(hEnableRemoteInputs, BM_SETCHECK, !(m_server->RemoteInputsEnabled()), 0); // Local input settings HWND hDisableLocalInputs = GetDlgItem(hwnd, IDC_DISABLE_LOCAL_INPUTS); SendMessage(hDisableLocalInputs, BM_SETCHECK, m_server->LocalInputsDisabled(), 0); // Local input prioity settings HWND hRemoteDisable = GetDlgItem(hwnd, IDC_REMOTE_DISABLE); SendMessage(hRemoteDisable, BM_SETCHECK, m_server->LocalInputPriority(), 0); HWND hDisableTime = GetDlgItem(hwnd, IDC_DISABLE_TIME); SetDlgItemInt(hwnd, IDC_DISABLE_TIME, m_server->DisableTime(), FALSE); EnableRemote(hwnd, false); EnableInputs(hwnd); }
void CMainDlg::OnBnClickedConnect() { CBusy busy; progress_Changed(0); if(!m_BootConnected) { // Unconnected state => try to connect to bootloader char tmpstrCom[512]; char tmpstr[1024]; CString tmpStrFormat; EnableInputs(false); ; if(m_fileS19.GetLBText(m_fileS19.GetCurSel(),tmpstr) < 0) { EnableInputs(true); printf("S19 file must be selected!\n"); return; } if(m_comPorts.GetLBText(m_comPorts.GetCurSel(),tmpstr) < 0) { EnableInputs(true); printf("Serial Com Port must be selected!\n"); return; } if(m_cbComSpeed.GetLBText(m_cbComSpeed.GetCurSel(),tmpstr) < 0) { EnableInputs(true); printf("Speed of serial ComPort must be selected!\n"); return; } // Dual mode !!! if(m_chbSingleWire.GetCheck()) { if(m_chbVerify.GetCheck()) tmpStrFormat = "COM%d!S"; else tmpStrFormat = "COM%d!s"; }else { if(m_chbVerify.GetCheck()) tmpStrFormat = "COM%d!D"; else tmpStrFormat = "COM%d!d"; } sprintf(tmpstrCom, tmpStrFormat, (int)m_comPorts.GetItemData(m_comPorts.GetCurSel())); m_cbComSpeed.GetLBText(m_cbComSpeed.GetCurSel(),tmpstr); // open serial port if(init_uart(tmpstrCom, tmpstr) < 0) { EnableInputs(true); return; } LogResetReplaceLine(); // wait for reset if(hook_reset() < 0) { close_uart(); EnableInputs(true); return; } LogResetReplaceLine(); // calibrate target's oscilator if(calibrate_speed(m_chbShortTrim.GetCheck()) < 0) { close_uart(); EnableInputs(true); return; } LogResetReplaceLine(); // read info if(!read_mcu_info()) { printf("\nBootloader protocol version: 0x%02X (%s, ", bl_version , Version_string(bl_version)); printf("read command "); if (!bl_rcs) printf("NOT "); printf("supported)\n"); printf("CRC protocol "); if (!bl_crcs) printf("NOT "); printf("supported)\n"); printf("Bootloader version string: %s\n", ident.targ_name); if (!bl_rcs) m_chbVerify.SetCheck(0); if (bl_version == BL_HC08) // HC08 { unsigned i; printf("Available flash memory: 0x%04X-0x%04X\n", ident.mem_start[0], ident.mem_end[0]-1); printf("Erase block size: %3d bytes\n", ident.erblk); printf("Write block size: %3d bytes\n", ident.wrblk); printf("Original vector table: 0x%04X\n",ident.int_vect_tbl); printf("Bootloader user table: 0x%04X\n",ident.bl_tbl); printf("Bootloader data (hex): "); for(i=0; i<sizeof(ident.priv_data); i++) printf("%02x ", ident.priv_data[i]); printf("\n"); } else if (bl_version == BL_HCS08) // S08 { unsigned i; printf("System device ID: 0x%03X [%s] rev. %u\n", ident.sdid, chipid ,ident.sdidrev); printf("Number of memory blocks: %u\n", ident.num_blocks); for(i=0; i<ident.num_blocks; i++) printf("Memory block #%u: 0x%04X-0x%04X\n", i+1, ident.mem_start[i], ident.mem_end[i]-1); printf("Erase block size: %3d bytes\n", ident.erblk); printf("Write block size: %3d bytes\n", ident.wrblk); printf("Original vector table: 0x%04X-0xFFFF\n",ident.int_vect_tbl); printf("New vector table: 0x%04X-0x%04X\n",ident.bl_tbl, ident.bl_tbl+(0xFFFF-ident.int_vect_tbl)); } else if (bl_version == BL_HC08_LARGE) // large HC08 { unsigned i; printf("Number of memory blocks: %u\n", ident.num_blocks); for(i=0; i<ident.num_blocks; i++) printf("Memory block #%u: 0x%04X-0x%04X\n", i+1, ident.mem_start[i], ident.mem_end[i]-1); printf("Erase block size: %3d bytes\n", ident.erblk); printf("Write block size: %3d bytes\n", ident.wrblk); printf("Original vector table: 0x%04X\n",ident.int_vect_tbl); printf("Bootloader user table: 0x%04X\n",ident.bl_tbl); } else if ((bl_version == BL_HCS08_LARGE) || (bl_version == BL_HCS08_LONG))// large + long S08 { unsigned i; printf("System device ID: 0x%03X [%s] rev. %u\n", ident.sdid, chipid ,ident.sdidrev); printf("Number of memory blocks: %u\n", ident.num_blocks); for(i=0; i<ident.num_blocks; i++) printf("Memory block #%u: 0x%06X-0x%06X\n", i+1, ident.mem_start[i], ident.mem_end[i]-1); printf("Erase block size: %3d bytes\n", ident.erblk); printf("Write block size: %3d bytes\n", ident.wrblk); printf("Original vector table: 0x%04X\n",ident.int_vect_tbl); printf("Bootloader user table: 0x%04X\n",ident.bl_tbl); } else if (bl_version == BL_CFV1) // CFV1 { unsigned i; printf("System device ID: 0x%03X [%s] rev. %u\n", ident.sdid, chipid ,ident.sdidrev); printf("Number of memory blocks: %u\n", ident.num_blocks); for(i=0; i<ident.num_blocks; i++) printf("Memory block #%u: 0x%08X-0x%08X\n", i+1, ident.mem_start[i], ident.mem_end[i]); printf("Erase block size: %3d bytes\n", ident.erblk); printf("Write block size: %3d bytes\n", ident.wrblk); if (ident.int_vect_tbl != NULL) { printf("Original vector table: 0x%08X-0x%08X\n",NULL, ident.int_vect_tbl-1); printf("New vector table: 0x%08X-0x%08X\n",ident.bl_tbl,ident.bl_tbl+ident.int_vect_tbl-1); } else printf("Vector table not relocated\n"); } else if (bl_version == BL_KINETIS) // Kinetis { unsigned i; printf("System device ID: 0x%03X [%s] rev. %u\n", ident.sdid, chipid ,ident.sdidrev); printf("Kinetis Package: %s .\n", get_package_str(ident.sdid)); printf("Number of memory blocks: %u\n", ident.num_blocks); for(i=0; i<ident.num_blocks; i++) printf("Memory block #%u: 0x%08X-0x%08X\n", i+1, ident.mem_start[i], ident.mem_end[i]); printf("Erase block size: %3d bytes\n", ident.erblk); printf("Write block size: %3d bytes\n", ident.wrblk); printf("Original vector table: 0x%08X-0x%08X\n",ident.int_vect_tbl,ident.int_vect_tbl + 0x3FF); printf("New vector table: 0x%08X-0x%08X\n",ident.bl_tbl, ident.bl_tbl + 0x3FF); } else { fprintf(stderr, "This version [0x%02X] of protocol is not (yet) supported! Check AN2295SW for update!\n", bl_version); close_uart(); EnableInputs(true); return; } } else { fprintf(stderr, "Can't read MCU info. Could be protocol error.\n"); fprintf(stderr, "(Or forgot to set single wire mode?)\n"); close_uart(); EnableInputs(true); return; } printf("\nS19 Image Control.\n"); LogResetReplaceLine(); // read S19 file reset_S19image(&image); m_fileS19.GetLBText(m_fileS19.GetCurSel(),tmpstr); if(read_s19(tmpstr, &image) < 0) { close_uart(); EnableInputs(true); return; } sprintf(tmpstrCom, "0x%04x", S19_GetCRC()); m_edbCheckSum.SetWindowTextA(tmpstrCom); if(S19_GetTotal() > 1024) sprintf(tmpstrCom, "0x%x B, %d KB", S19_GetTotal(), S19_GetTotal()/1024); else sprintf(tmpstrCom, "0x%x B, %d B", S19_GetTotal(), S19_GetTotal()); m_edbImageSize.SetWindowTextA(tmpstrCom); LogResetReplaceLine(); // masquerade vector table if(setup_vect_tbl(ident.int_vect_tbl , ident.bl_tbl) < 0) { close_uart(); EnableInputs(true); return; } LogResetReplaceLine(); // check if code goes to valid memory only - issue warning only, but continue! (r30323) check_image(); LogResetReplaceLine(); printf("\n "); printf("\n "); m_btConnect.SetWindowTextA("Quit/&Run"); m_BootConnected = true; FillUpIdentification(); EnableControlBtn(true); }else { // Connected state => Quit and run MCU application unhook(); LogResetReplaceLine(); close_uart(); m_btConnect.SetWindowTextA("Connect"); EnableInputs(true); m_BootConnected = false; FillUpIdentification(); EnableControlBtn(false); //LogClear(); } }