Example #1
0
bool LLDBDebugger::Start(const wxString& filename)
{
    if ( m_thread ) {
        // another instance is already running
        ::wxMessageBox(_("A Debug session is already in progress!"));
        return false;
    }
    
    m_debugeePid = wxNOT_FOUND;
    m_debugger = lldb::SBDebugger::Create();
    m_target = m_debugger.CreateTarget(filename.mb_str().data());
    if ( !m_target.IsValid() ) {
        ::wxMessageBox(_("Could not create target"));
        return false;
    }

    m_debugger.SetAsync(true);

    // Notify successful start of the debugger
    NotifyStarted();
    return true;
}
Example #2
0
void wxGetTextExtent(WXDisplay* display, const wxFont& font,
                     double scale, const wxString& str,
                     int* width, int* height, int* ascent, int* descent)
{
    WXFontStructPtr pFontStruct = font.GetFontStruct(scale, display);

    int direction, ascent2, descent2;
    XCharStruct overall;
    int slen = str.length();

    XTextExtents((XFontStruct*) pFontStruct,
                 const_cast<char*>((const char *)str.mb_str()), slen,
                 &direction, &ascent2, &descent2, &overall);

    if ( width )
        *width = (overall.width);
    if ( height )
        *height = (ascent2 + descent2);
    if ( descent )
        *descent = descent2;
    if ( ascent )
        *ascent = ascent2;
}
Example #3
0
/*  Wrapped interface from higher level objects   */
int Garmin_GPS_Init( wxString &port_name)
{
      int ret;
#ifdef GPS_DEBUG0
//      if (getenv("OPENCPN_GPS_ERROR") != NULL)
	GPS_Enable_Error();
//      if (getenv("OPENCPN_GPS_WARNING") != NULL)
	GPS_Enable_Warning();
//      if (getenv("OPENCPN_GPS_USER") != NULL)
	GPS_Enable_User();
//      if (getenv("OPENCPN_GPS_DIAGNOSE") != NULL)
	GPS_Enable_Diagnose();
#endif
      char m[1];
      m[0] = '\0';

      GPS_Error(m);

      ret = GPS_Init(port_name.mb_str());
      VerifyPortClosed();

      return ret;
}
Example #4
0
uint64_t cbDebuggerStringToAddress(const wxString &address)
{
    if (address.empty())
        return 0;
#if defined(__WXMSW__)
    // Workaround for the 'ToULongLong' bug in wxWidgets 2.8.12
#if wxCHECK_VERSION(2, 8, 12)
    return strtoull(address.mb_str(), nullptr, 16);
#else
    uint64_t result;
    if (address.ToULongLong(&result))
        return result;
    else
        return 0;
#endif // wxCHECK_VERSION
#else
    uint64_t result;
    if (address.ToULong(&result, 16))
        return result;
    else
        return 0;
#endif
}
void robotic_arm_kinematicsFrame::OnSaveBinary(wxCommandEvent& event)
{
	WX_START_TRY

	wxFileDialog dlg(
		this,
		_("Save kinematic chain"),
		_("."),
		_("*.kinbin"),
		wxT("Kinematic chains binary files (*.kinbin)|*.kinbin|All files (*.*)|*.*"),
		wxFD_SAVE | wxFD_OVERWRITE_PROMPT );

	if (dlg.ShowModal() != wxID_OK)
		return;

	const wxString sFil =  dlg.GetPath();
	const std::string fil = std::string(sFil.mb_str());

	mrpt::utils::CFileOutputStream f(fil);
	f << m_robot;

	WX_END_TRY
}
Example #6
0
map <string, string> SQLite::gettingSelectedUpletConn(SQLiteStatement *pStmt0, wxString uplet) {
    // méthode ad hoc : suppose uplet bien "formé", cad 4 token - entre autres !
    map <string, string> paramsDic;
    wxString host, port, dbname, user, password;
    wxStringTokenizer tokenizer(uplet, sep, wxTOKEN_STRTOK);
    int ijk = 0;
    while ( tokenizer.HasMoreTokens() )
    {
        switch (ijk)
        {
            case 0: { paramsDic["host"] = wxString(tokenizer.GetNextToken()); break; }
            case 1: { paramsDic["port"] = wxString(tokenizer.GetNextToken()); break; }
            case 2: { paramsDic["dbname"] = wxString(tokenizer.GetNextToken()); break; }
            case 3: { paramsDic["user"] = wxString(tokenizer.GetNextToken()); break; }
        }
        ijk = ijk + 1;
    }
    
    sql = "SELECT host, port, dbname, user, password FROM ";
    sql.Append(tblName);
    sql.Append(" WHERE host='"); sql.Append(paramsDic["host"]);
    sql.Append("' AND port='"); sql.Append(paramsDic["port"]);
    sql.Append("' AND dbname='"); sql.Append(paramsDic["dbname"]);
    sql.Append("' AND user='******';");
    pStmt0->Sql(string(sql.mb_str()));
    
    if (pStmt0->GetNumberOfRows() == 1) {
        while(pStmt0->FetchRow()) {
            paramsDic["password"] = wxString(pStmt0->GetColumnString(4));
        }
    } else {
        wxMessageBox(wxT("ERREUR FATALE"), wxT("OK"));
    };
    
    return paramsDic;
}
Example #7
0
void FileFunctionsTestCase::DoConcatFile(const wxString& filePath1,
                                         const wxString& filePath2,
                                         const wxString& destFilePath)
{
    const wxString msg = wxString::Format(wxT("File 1: %s  File 2: %s  File 3: %s"),
                                  filePath1.c_str(), filePath2.c_str(), destFilePath.c_str());
    const char *pUnitMsg = (const char*)msg.mb_str(wxConvUTF8);

    // Prepare source data
    wxFFile f1(filePath1, wxT("wb")),
            f2(filePath2, wxT("wb"));
    CPPUNIT_ASSERT_MESSAGE( pUnitMsg, f1.IsOpened() && f2.IsOpened() );

    wxString s1(wxT("1234567890"));
    wxString s2(wxT("abcdefghij"));
    CPPUNIT_ASSERT_MESSAGE( pUnitMsg, f1.Write(s1) );
    CPPUNIT_ASSERT_MESSAGE( pUnitMsg, f2.Write(s2) );

    CPPUNIT_ASSERT_MESSAGE( pUnitMsg, f1.Close() && f2.Close() );

    // Concatenate source files
    CPPUNIT_ASSERT_MESSAGE( pUnitMsg, wxConcatFiles(filePath1, filePath2, destFilePath) );

    // Verify content of destination file
    CPPUNIT_ASSERT_MESSAGE( pUnitMsg, wxFileExists(destFilePath) );
    wxString sSrc = s1 + s2;
    wxString s3;
    wxFFile f3(destFilePath, wxT("rb"));
    CPPUNIT_ASSERT_MESSAGE( pUnitMsg, f3.ReadAll(&s3) );
    CPPUNIT_ASSERT_MESSAGE( pUnitMsg, (sSrc.length() == s3.length()) &&
                    (memcmp(sSrc.c_str(), s3.c_str(), sSrc.length()) == 0) );
    CPPUNIT_ASSERT_MESSAGE( pUnitMsg, f3.Close() );

    CPPUNIT_ASSERT_MESSAGE( pUnitMsg, wxRemoveFile(filePath1) );
    CPPUNIT_ASSERT_MESSAGE( pUnitMsg, wxRemoveFile(filePath2) );
    CPPUNIT_ASSERT_MESSAGE( pUnitMsg, wxRemoveFile(destFilePath) );
}
Example #8
0
/**
 * Extract ()
 *
 * extracts the first hit of pattern to the given position
 *
 * @param pattern  A filename pattern (may contain * and ? chars)
 * @param filename The FileName where to temporary extract the file to
 * @return 0 at no file extracted<br>
 *         number of bytes extracted else
 */
size_t wxChmTools::Extract(const wxString& pattern, const wxString& filename)
{
    struct mschm_decompressor *d = m_decompressor;
    struct mschmd_header      *h = m_archive;
    struct mschmd_file        *f;

    wxString tmp;
    wxString pattern_tmp = (wxString(pattern)).MakeLower();

    for (f = h->files; f; f = f->next)
    {
        tmp = wxString::FromAscii(f->filename).MakeLower();
        if ( tmp.Matches(pattern_tmp) ||
             tmp.Mid(1).Matches(pattern_tmp) )
        {
            // ignore leading '/'
            if (d->extract(d, f,
                           (char*)(const char*)filename.mb_str(wxConvFile)))
            {
                // Error
                m_lasterror = d->last_error(d);
                wxLogError(_("Could not extract %s into %s: %s"),
                           wxString::FromAscii(f->filename).c_str(),
                           filename.c_str(),
                           ChmErrorMsg(m_lasterror).c_str());
                return 0;
            }
            else
            {
                return (size_t) f->length;
            }
        }
    }

    return 0;
}
Example #9
0
//Add the file to the File History
void SubMainFrame::AddFileToHistory(wxString strFilename)
{
    ConfigFile *clientConfig = Globals::Instance()->GetConfig();

    std::vector<std::string> listFileHistory =  clientConfig->getArray("FileHistory");

    for(std::vector<std::string>::iterator iter = listFileHistory.begin(); iter != listFileHistory.end(); iter++)
    {
        if(strFilename == wxString((*iter).c_str(), wxConvLocal))
        {
            listFileHistory.erase(iter);
            break;
        }
    }
    listFileHistory.push_back(std::string(strFilename.mb_str()));

    while(listFileHistory.size() > clientConfig->getInteger("FileHistorySize",4))
    {
        listFileHistory.erase(listFileHistory.begin());
    }
    clientConfig->setArray("FileHistory", listFileHistory);

    UpdateHistory();
}
Example #10
0
bool wxFfmpegMediaDecoder::Load(const wxString& fileName) {
	Close();
	if ((fileName.Find(wxT(':')) <= 0 || fileName.Find(wxT(':')) >= 8
			|| fileName.GetChar(fileName.Find(wxT(':')) - 1) == wxT('\\'))
			&& !wxFileExists(fileName)) {
		wxLogError(wxT("%s: no such file or directory"), fileName.c_str());
		return false;
	}
#ifdef __WXMSW__
	int err = avformat_open_input(&m_formatCtx, fileName.utf8_str(), NULL, NULL);
#else
	int err = avformat_open_input(&m_formatCtx, fileName.mb_str(), NULL, NULL);
#endif
	if (err != 0) {
		PrintError(fileName, err);
		return false;
	}
	// Retrieve stream information
	if (avformat_find_stream_info(m_formatCtx, NULL) < 0) {
		wxLogError(wxT("%s: could not find codec parameters"), fileName.c_str());
		return false;
	}
	return true;
}
Example #11
0
int RazdsParser::LoadFile( s52plib* plibArg, const wxString& PLib )
{

    plib = plibArg;

    FILE *fp = NULL;
    int nRead;

    fp = fopen( PLib.mb_str(), "r" );

    if( fp == NULL ) {
        wxString msg;
        msg = _T("   S52PLIB: Cannot open S52 rules file: ");
        msg += PLib;
        wxLogMessage( msg );
        return 0;
    }

    m_LUPSequenceNumber = 0;

    while( 1 == ( nRead = ReadS52Line( pBuf, NEWLN, 0, fp ) ) ) {
        // !!! order important !!!
        MOD_REC ( LBID ) ParseLBID( fp );
        MOD_REC ( COLS ) ParseCOLS( fp );
        MOD_REC ( LUPT ) ParseLUPT( fp );
        MOD_REC ( LNST ) ParseLNST( fp );
        MOD_REC ( PATT ) ParsePATT( fp );
        MOD_REC ( SYMB ) ParseSYMB( fp, plib->_symb_sym );

        MOD_REC ( 0001 ) continue;
        MOD_REC ( **** ) continue;

    }
    fclose( fp );
    return 1;
}
Example #12
0
void FileFunctionsTestCase::DoFindFile(const wxString& filePath)
{
    const wxString msg = wxString::Format(wxT("File: %s"),
                                          filePath.c_str());
    const char *pUnitMsg = (const char*)msg.mb_str(wxConvUTF8);

    // Create temporary file.
    wxTextFile file;
    CPPUNIT_ASSERT_MESSAGE( pUnitMsg, file.Create(filePath) );
    CPPUNIT_ASSERT_MESSAGE( pUnitMsg, file.Close() );

    // Check if file can be found (method 1).
    wxString foundFile = wxFindFirstFile(filePath, wxFILE);
    CPPUNIT_ASSERT_MESSAGE( pUnitMsg, foundFile == filePath );

    // Check if file can be found (method 2).
    wxFileSystem fs;
    wxString furl = fs.FindFirst(filePath, wxFILE);
    wxFileName fname = wxFileSystem::URLToFileName(furl);
    foundFile = fname.GetFullPath();
    CPPUNIT_ASSERT_MESSAGE( pUnitMsg, foundFile == filePath );

    wxRemoveFile(filePath);
}
Example #13
0
bool wxSetEnv(const wxString& variable, const wxChar *value)
{
#if defined(HAVE_SETENV)
    return setenv(variable.mb_str(), value ? wxString(value).mb_str().data()
                                           : NULL, 1 /* overwrite */) == 0;
#elif defined(HAVE_PUTENV)
    wxString s = variable;
    if ( value )
        s << _T('=') << value;

    // transform to ANSI
    const char *p = s.mb_str();

    // the string will be free()d by libc
    char *buf = (char *)malloc(strlen(p) + 1);
    strcpy(buf, p);

    return putenv(buf) == 0;
#else // no way to set an env var
    wxUnusedVar(variable);
    wxUnusedVar(value);
    return false;
#endif
}
Example #14
0
void
Client::StartWorker(workMode pMode, const wxString& pMessage) {
    char* tmpbuf = wxStrdup(pMessage.mb_str());
    int msgsize = strlen(tmpbuf);
    char* buf = CreateBuffer(&msgsize);
    memset(buf+2,0x0,msgsize);
    memcpy(buf+2,tmpbuf,msgsize);
    free(tmpbuf);

    if (pMode == THREADS) {
        ThreadWorker* c = new ThreadWorker(m_host,buf,msgsize+2);
        if (c->Create() != wxTHREAD_NO_ERROR) {
            wxLogError(wxT("Cannot create more threads"));
        } else {
            c->Run();
            m_threadWorkers.Append(c);
        }
    } else {
        EventWorker* e = new EventWorker(m_host,buf,msgsize+2);
        e->Run();
        m_eventWorkers.Append(e);
    }
    m_statConnecting++;
}
Example #15
0
bool pgConn::StartCopy(const wxString query)
{
	if (GetStatus() != PGCONN_OK)
		return false;

	// Execute the query and get the status
	PGresult *qryRes;

	wxLogSql(wxT("COPY query (%s:%d): %s"), this->GetHost().c_str(), this->GetPort(), query.c_str());
	qryRes = PQexec(conn, query.mb_str(*conv));
	lastResultStatus = PQresultStatus(qryRes);
	SetLastResultError(qryRes);

	// Check for errors
	if (lastResultStatus != PGRES_COPY_IN)
	{
		LogError(false);
		PQclear(qryRes);
		return false;
	}

	// NO cleanup & exit
	return  true;
}
Example #16
0
//-------------------------------------------------------------------------------
// Lecture complète d'un fichier GRIB
//-------------------------------------------------------------------------------
void GribReader::openFile(const wxString fname)
{
    debug("Open file: %s", (const char *)fname.mb_str());
    fileName = fname;
    ok = false;
    clean_all_vectors();
    //--------------------------------------------------------
    // Open the file
    //--------------------------------------------------------
    file = zu_open((const char *)fname.mb_str(), "rb", ZU_COMPRESS_AUTO);
    if (file == NULL) {
        erreur("Can't open file: %s", (const char *)fname.mb_str());
        return;
    }
    readGribFileContent();

    // Look for compressed files with alternate extensions
 	if (! ok) {
    	if (file != NULL)
			zu_close(file);
    	file = zu_open((const char *)fname.mb_str(), "rb", ZU_COMPRESS_BZIP);
    	if (file != NULL)
    		readGribFileContent();
    }
 	if (! ok) {
    	if (file != NULL)
			zu_close(file);
      file = zu_open((const char *)fname.mb_str(), "rb", ZU_COMPRESS_GZIP);
    	if (file != NULL)
    		readGribFileContent();
    }
 	if (! ok) {
    	if (file != NULL)
			zu_close(file);
      file = zu_open((const char *)fname.mb_str(), "rb", ZU_COMPRESS_NONE);
    	if (file != NULL)
    		readGribFileContent();
    }
}
Example #17
0
bool WriteWaveFile::WriteDate(wxString s)
{
  return (sf_set_string(sffile, SF_STR_DATE, s.mb_str(*wxConvCurrent)));
}
Example #18
0
bool WriteWaveFile::WriteComment(wxString s)
{
  return (sf_set_string(sffile, SF_STR_COMMENT, s.mb_str(*wxConvCurrent)));

}
Example #19
0
bool WriteWaveFile::WriteArtist(wxString s)
{
  return (sf_set_string(sffile, SF_STR_ARTIST, s.mb_str(*wxConvCurrent)));
}
Example #20
0
bool WriteWaveFile::WriteSoftware(wxString s)
{
  return (sf_set_string(sffile, SF_STR_SOFTWARE, s.mb_str(*wxConvCurrent)));
}
Example #21
0
bool WriteWaveFile::WriteCopyright(wxString s)
{
  return (sf_set_string(sffile, SF_STR_COPYRIGHT, s.mb_str(*wxConvCurrent)));
}
Example #22
0
bool WriteWaveFile::WriteTitle(wxString s)
{
  return (sf_set_string(sffile, SF_STR_TITLE, s.mb_str(*wxConvCurrent)));
}
int OCP_DataStreamInput_Thread::OpenComPortPhysical(const wxString &com_name, int baud_rate)
{

    // Declare the termios data structures
    termios ttyset_old;
    termios ttyset;

    // Open the serial port.
    int com_fd;
    if ((com_fd = open(com_name.mb_str(), O_RDWR|O_NONBLOCK|O_NOCTTY)) < 0)
        return com_fd;

    speed_t baud_parm;
    switch(baud_rate)
    {
        case     50: baud_parm =     B50; break;
        case     75: baud_parm =     B75; break;
        case    110: baud_parm =    B110; break;
        case    134: baud_parm =    B134; break;
        case    150: baud_parm =    B150; break;
        case    200: baud_parm =    B200; break;
        case    300: baud_parm =    B300; break;
        case    600: baud_parm =    B600; break;
        case   1200: baud_parm =   B1200; break;
        case   1800: baud_parm =   B1800; break;
        case   2400: baud_parm =   B2400; break;
        case   4800: baud_parm =   B4800; break;
        case   9600: baud_parm =   B9600; break;
        case  19200: baud_parm =  B19200; break;
        case  38400: baud_parm =  B38400; break;
        case  57600: baud_parm =  B57600; break;
        case 115200: baud_parm = B115200; break;
        
        default: baud_parm = B4800; break;
    }

    if (isatty(com_fd) != 0)
    {
        /* Save original terminal parameters */
        if (tcgetattr(com_fd,&ttyset_old) != 0)
            return -128;

        memcpy(&ttyset, &ttyset_old, sizeof(termios));

    //  Build the new parms off the old

    //  Baud Rate
        cfsetispeed(&ttyset, baud_parm);
        cfsetospeed(&ttyset, baud_parm);

        tcsetattr(com_fd, TCSANOW, &ttyset);

    // Set blocking/timeout behaviour
        memset(ttyset.c_cc,0,sizeof(ttyset.c_cc));
        ttyset.c_cc[VTIME] = 5;                        // 0.5 sec timeout
        fcntl(com_fd, F_SETFL, fcntl(com_fd, F_GETFL) & !O_NONBLOCK);

    // No Flow Control

        ttyset.c_cflag &= ~(PARENB | PARODD | CRTSCTS);
        ttyset.c_cflag |= CREAD | CLOCAL;
        ttyset.c_iflag = ttyset.c_oflag = ttyset.c_lflag = (tcflag_t) 0;

        int stopbits = 1;
        char parity = 'N';
        ttyset.c_iflag &=~ (PARMRK | INPCK);
        ttyset.c_cflag &=~ (CSIZE | CSTOPB | PARENB | PARODD);
        ttyset.c_cflag |= (stopbits==2 ? CS7|CSTOPB : CS8);
        switch (parity)
        {
            case 'E':
                ttyset.c_iflag |= INPCK;
                ttyset.c_cflag |= PARENB;
                break;
            case 'O':
                ttyset.c_iflag |= INPCK;
                ttyset.c_cflag |= PARENB | PARODD;
                break;
        }
        ttyset.c_cflag &=~ CSIZE;
        ttyset.c_cflag |= (CSIZE & (stopbits==2 ? CS7 : CS8));
        if (tcsetattr(com_fd, TCSANOW, &ttyset) != 0)
            return -129;

        tcflush(com_fd, TCIOFLUSH);
    }

    return com_fd;
}
Example #24
0
 inline std::string to_std(const wxString& wxstr)
 {
     return std::string(wxstr.mb_str(wxConvUTF8));
 }
Example #25
0
void wxTarOutputStream::SetHeaderString(int id, const wxString& str)
{
    strncpy(m_hdr->Get(id), str.mb_str(GetConv()), m_hdr->Len(id));
    if (str.length() > m_hdr->Len(id))
        SetExtendedHeader(m_hdr->Name(id), str);
}
Example #26
0
//-----------------------------------------------------------------------------
AssignIPDlg::AssignIPDlg( IPConfigureFrame* pParent, MVTLI_HANDLE hTL, const wxString& deviceMACAddress /* = wxEmptyString */,
                          const wxString& connectedIPAddress /* = wxEmptyString */, bool boShowDifferentSubnetWarning /* = false*/, bool boBuildMACFromSerialEnabled /*= true*/ )
    : wxDialog( pParent, wxID_ANY, wxString( wxT( "Assign A Temporary IPv4 Address To A Device" ) ), wxDefaultPosition,
                wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX ), pTCDeviceMACAddress_( 0 ),
    pTCDesiredIPAddress_( 0 ), pTCDesiredSubnetMask_( 0 ), pTCDesiredGateway_( 0 ), pBtnBuildMACAddress_( 0 ),
    pBtnExecute_( 0 ), pCBAdapterList_( 0 ), pParent_( pParent ), hTL_( hTL )
//-----------------------------------------------------------------------------
{
    /*
        |-------------------------------------|
        | pTopDownSizer                       |
        | |---------------------------------| |
        | |          spacer                 | |
        | | pGroupBoxSizer                  | |
        | | |-----------------------------| | |
        | | | pEditElementsGridSizer      | | |
        | | | |-------------------------| | | |
        | | | |                         | | | |
        | | | |            | pSizer   | | | | |
        | | | |                         | | | |
        | | | |-------------------------| | | |
        | | |-----------------------------| | |
        | |          spacer                 | |
        | |                    pBtnExecute_ | |
        | |---------------------------------| |
        |-------------------------------------|
    */

    wxBoxSizer* pTopDownSizer = new wxBoxSizer( wxVERTICAL );
    wxPanel* pPanel = new wxPanel( this );

    pTopDownSizer->AddSpacer( 10 );

    if( boShowDifferentSubnetWarning )
    {
        wxStaticBoxSizer* pNoticeBoxSizer = new wxStaticBoxSizer( wxVERTICAL, pPanel, wxT( "Notice:" ) );
        pNoticeBoxSizer->Add( new wxStaticText( pNoticeBoxSizer->GetStaticBox(), wxID_ANY, wxT( "This machine cannot communicate with the camera, because the camera is on a different subnet.\nPlease assign to the camera a temporary IP in the same subnet to restore communication." ) ), wxSizerFlags().Left() );
        pTopDownSizer->Add( pNoticeBoxSizer, wxSizerFlags().Expand().DoubleBorder() ); // see trac.wxwidgets.org/ticket/17239 before changing this
        pTopDownSizer->AddSpacer( 10 );
    }

    wxStaticBoxSizer* pGroupBoxSizer = new wxStaticBoxSizer( wxVERTICAL, pPanel, wxT( "Parameters:" ) );
    wxStaticBox* pGroupBoxSizerBox = pGroupBoxSizer->GetStaticBox();
    wxFlexGridSizer* pEditElementsGridSizer = new wxFlexGridSizer( 2 );
    pEditElementsGridSizer->AddGrowableCol( 1, 3 );

    // row 1
    pEditElementsGridSizer->Add( new wxStaticText( pGroupBoxSizerBox, wxID_ANY, wxT( "Device MAC Address:" ) ), wxSizerFlags().Left() );
    wxBoxSizer* pSizer = new wxBoxSizer( wxHORIZONTAL );
    pTCDeviceMACAddress_ = new wxTextCtrl( pGroupBoxSizerBox, widTCMACAddress, deviceMACAddress, wxDefaultPosition, wxDefaultSize, 0, MACStringValidator_ );
    pBtnBuildMACAddress_ = new wxButton( pGroupBoxSizerBox, widBtnBuildMACAddress, wxT( "&Build MAC Address" ) );
    pBtnBuildMACAddress_->SetToolTip( wxT( "If you don't know the MAC address of your MATRIX VISION device\n press this button to construct it from the device serial." ) );
    pSizer->Add( pTCDeviceMACAddress_, wxSizerFlags( 2 ).Expand() );
    pSizer->Add( pBtnBuildMACAddress_ );
    pEditElementsGridSizer->Add( pSizer, wxSizerFlags( 2 ).Expand() );
    if( boBuildMACFromSerialEnabled == false )
    {
        pTCDeviceMACAddress_->Enable( false );
        pBtnBuildMACAddress_->Hide();
    }
    // row 2
    pEditElementsGridSizer->Add( new wxStaticText( pGroupBoxSizerBox, wxID_ANY, wxT( "Temporary IP Address:" ) ), wxSizerFlags().Left() );
    pTCDesiredIPAddress_ = new wxTextCtrl( pGroupBoxSizerBox, widDesiredIPAddress, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, IPv4StringValidator_ );
    pEditElementsGridSizer->Add( pTCDesiredIPAddress_, wxSizerFlags( 2 ).Align( wxGROW | wxALIGN_CENTER_VERTICAL ) );
    // row 3
    pEditElementsGridSizer->Add( new wxStaticText( pGroupBoxSizerBox, wxID_ANY, wxT( "Temporary Subnet Mask:" ) ), wxSizerFlags().Left() );
    pTCDesiredSubnetMask_ = new wxTextCtrl( pGroupBoxSizerBox, widDesiredSubnetMask, wxT( "255.255.255.0" ), wxDefaultPosition, wxDefaultSize, 0, IPv4StringValidator_ );
    pEditElementsGridSizer->Add( pTCDesiredSubnetMask_, wxSizerFlags( 2 ).Align( wxGROW | wxALIGN_CENTER_VERTICAL ) );
    // row 4
    pEditElementsGridSizer->Add( new wxStaticText( pGroupBoxSizerBox, wxID_ANY, wxT( "Temporary Gateway:" ) ), wxSizerFlags().Left() );
    pTCDesiredGateway_ = new wxTextCtrl( pGroupBoxSizerBox, widDesiredGateway, wxT( "0.0.0.0" ), wxDefaultPosition, wxDefaultSize, 0, IPv4StringValidator_ );
    pEditElementsGridSizer->Add( pTCDesiredGateway_, wxSizerFlags( 2 ).Align( wxGROW | wxALIGN_CENTER_VERTICAL ) );
    // row 5
    pEditElementsGridSizer->Add( new wxStaticText( pGroupBoxSizerBox, wxID_ANY, wxT( "Local IP To Use For Sending:" ) ), wxSizerFlags().Left() );
    pCBAdapterList_ = new wxComboBox( pGroupBoxSizerBox, widAdapterList, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, 0, wxCB_DROPDOWN | wxCB_READONLY );
    pEditElementsGridSizer->Add( pCBAdapterList_, wxSizerFlags( 2 ).Align( wxGROW | wxALIGN_CENTER_VERTICAL ) );

    pGroupBoxSizer->Add( pEditElementsGridSizer, wxSizerFlags().Align( wxGROW ).DoubleBorder() ); // see trac.wxwidgets.org/ticket/17239 before changing this
    const InterfaceContainer& interfaces( pParent->GetInterfaces() );
    InterfaceContainer::const_iterator it = interfaces.begin();
    const InterfaceContainer::const_iterator itEND = interfaces.end();
    while( it != itEND )
    {
        const wxString interfaceTLType( ConvertedString( pParent->GetInterfaceStringInfo( it->second, INTERFACE_INFO_TLTYPE ) ) );
        if( !strncmp( interfaceTLType.mb_str(), "GEV", 3 ) )
        {
            pCBAdapterList_->AppendString( ConvertedString( pParent->GetInterfaceStringInfo( it->second, INTERFACE_INFO_IP_STRING ) ) );
        }
        ++it;
    }

    const unsigned int cnt = pCBAdapterList_->GetCount();
    if( cnt > 0 )
    {
        bool boSelected = false;
        if( !connectedIPAddress.IsEmpty() )
        {
            for( unsigned int i = 0; i < cnt; i++ )
            {
                if( connectedIPAddress == pCBAdapterList_->GetString( i ) )
                {
                    pCBAdapterList_->Select( i );
                    boSelected = true;
                    break;
                }
            }
        }
        if( !boSelected )
        {
            pCBAdapterList_->Select( 0 );
        }
    }

    pTopDownSizer->Add( pGroupBoxSizer, wxSizerFlags().Expand() );
    pTopDownSizer->AddSpacer( 10 );
    pBtnExecute_ = new wxButton( pPanel, widBtnExecute, wxT( "&Execute" ) );
    pTopDownSizer->Add( pBtnExecute_, wxSizerFlags().Right().Border( wxALL, 5 ) );
    pTopDownSizer->AddSpacer( 5 );
    pPanel->SetSizer( pTopDownSizer );
    pTopDownSizer->SetSizeHints( this );
}
Example #27
0
bool wxSetEnv(const wxString& variable, const wxString& value)
{
    return wxDoSetEnv(variable, value.mb_str());
}
Example #28
0
// These can be removed for wx 2.9/3
string wxstr_tostdstr(const wxString &s)
{
	return string(s.mb_str());
}
Example #29
0
void wxWebViewWebKit::DoSetPage(const wxString& html, const wxString& baseUri)
{
    webkit_web_view_load_html(m_web_view,
                              html.mb_str(wxConvUTF8),
                              baseUri.mb_str(wxConvUTF8));
}
Example #30
0
// Open a port, by name.  Return 0 on success, non-zero for error
int Serial::Open(const wxString& name)
{
	Close();
#if defined(LINUX)
	struct serial_struct kernel_serial_settings;
	int bits;
	port_fd = open(name.mb_str(), O_RDWR | O_NOCTTY | O_NONBLOCK);
	if (port_fd < 0) {
		if (errno == EACCES) {
		  error_msg = _("Unable to access ") + wxString(name,wxConvUTF8) + _(", insufficient permission");
			// TODO: we could look at the permission bits and owner
			// to make a better message here
		} else if (errno == EISDIR) {
		  error_msg = _("Unable to open ") + wxString(name,wxConvUTF8) +
		    _(", Object is a directory, not a serial port");
		} else if (errno == ENODEV || errno == ENXIO) {
		  error_msg = _("Unable to open ") + wxString(name,wxConvUTF8) +
		    _(", Serial port hardware not installed");
		} else if (errno == ENOENT) {
		  error_msg = _("Unable to open ") + wxString(name,wxConvUTF8) +
		    _(", Device name does not exist");
		} else {
		  error_msg = _("Unable to open ") + wxString(name,wxConvUTF8) +
		    _(", ") + wxString(strerror(errno),wxConvUTF8);
		}
		return -1;
	}
	if (ioctl(port_fd, TIOCMGET, &bits) < 0) {
		close(port_fd);
		error_msg = _("Unable to query serial port signals");
		return -1;
	}
	bits &= ~(TIOCM_DTR | TIOCM_RTS);
	if (ioctl(port_fd, TIOCMSET, &bits) < 0) {
		close(port_fd);
		error_msg = _("Unable to control serial port signals");
		return -1;
	}
	if (tcgetattr(port_fd, &settings_orig) != 0) {
		close(port_fd);
		error_msg = _("Unable to query serial port settings (perhaps not a serial port)");
		return -1;
	}
	memset(&settings, 0, sizeof(settings));
	settings.c_iflag = IGNBRK | IGNPAR;
	settings.c_cflag = CS8 | CREAD | HUPCL | CLOCAL;
	Set_baud(baud_rate);
	if (ioctl(port_fd, TIOCGSERIAL, &kernel_serial_settings) == 0) {
		kernel_serial_settings.flags |= ASYNC_LOW_LATENCY;
		ioctl(port_fd, TIOCSSERIAL, &kernel_serial_settings);
	}
	tcflush(port_fd, TCIFLUSH);
#elif defined(MACOSX)
	int bits;
	port_fd = open(name.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK);
	if (port_fd < 0) {
	  error_msg = _("Unable to open ") + name + _(", ") + strerror(errno);
		return -1;
	}
	if (ioctl(port_fd, TIOCEXCL) == -1) {
		close(port_fd);
		error_msg = _("Unable to get exclussive access to port ") + name;
		return -1;
	}
	if (ioctl(port_fd, TIOCMGET, &bits) < 0) {
		close(port_fd);
		error_msg = _("Unable to query serial port signals on ") + name;
		return -1;
	}
	bits &= ~(TIOCM_DTR | TIOCM_RTS);
	if (ioctl(port_fd, TIOCMSET, &bits) < 0) {
		close(port_fd);
		error_msg = _("Unable to control serial port signals on ") + name;
		return -1;
	}
	if (tcgetattr(port_fd, &settings_orig) < 0) {
		close(port_fd);
		error_msg = _("Unable to access baud rate on port ") + name;
		return -1;
	}
	memset(&settings, 0, sizeof(settings));
	settings.c_cflag = CS8 | CLOCAL | CREAD | HUPCL;
	settings.c_iflag = IGNBRK | IGNPAR;
	Set_baud(baud_rate);
	tcflush(port_fd, TCIFLUSH);
#elif defined(WINDOWS)
	COMMCONFIG cfg;
	COMMTIMEOUTS timeouts;
	int got_default_cfg=0, port_num;
	char buf[1024], name_createfile[64], name_commconfig[64], *p;
	DWORD len;

	snprintf(buf, sizeof(buf), _("%s"), name.c_str());
	p = strstr(buf, _("COM"));
	if (p && sscanf(p + 3, _("%d"), &port_num) == 1) {
	  printf(_("port_num = %d\n"), port_num);
	  snprintf(name_createfile, sizeof(name_createfile), _("\\\\.\\COM%d"), port_num);
	  snprintf(name_commconfig, sizeof(name_commconfig), _("COM%d"), port_num);
	} else {
	  snprintf(name_createfile, sizeof(name_createfile), _("%s"), name.c_str());
	  snprintf(name_commconfig, sizeof(name_commconfig), _("%s"), name.c_str());
	}
	len = sizeof(COMMCONFIG);
	if (GetDefaultCommConfig(name_commconfig, &cfg, &len)) {
		// this prevents unintentionally raising DTR when opening
		// might only work on COM1 to COM9
		got_default_cfg = 1;
		memcpy(&port_cfg_orig, &cfg, sizeof(COMMCONFIG));
		cfg.dcb.fDtrControl = DTR_CONTROL_DISABLE;
		cfg.dcb.fRtsControl = RTS_CONTROL_DISABLE;
		SetDefaultCommConfig(name_commconfig, &cfg, sizeof(COMMCONFIG));
	} else {
	  printf(_("error with GetDefaultCommConfig\n"));
	}
	port_handle = CreateFile(name_createfile, GENERIC_READ | GENERIC_WRITE,
	   0, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
	if (port_handle == INVALID_HANDLE_VALUE) {
		win32_err(buf);
		error_msg =  _("Unable to open ") + name + _(", ") + buf;
		return -1;
	}
	len = sizeof(COMMCONFIG);
	if (!GetCommConfig(port_handle, &port_cfg, &len)) {
		CloseHandle(port_handle);
		win32_err(buf);
		error_msg = _("Unable to read communication config on ") + name + _(", ") + buf;
		return -1;
	}
	if (!got_default_cfg) {
		memcpy(&port_cfg_orig, &port_cfg, sizeof(COMMCONFIG));
	}
	// http://msdn2.microsoft.com/en-us/library/aa363188(VS.85).aspx
	port_cfg.dcb.BaudRate = baud_rate;
	port_cfg.dcb.fBinary = TRUE;
	port_cfg.dcb.fParity = FALSE;
	port_cfg.dcb.fOutxCtsFlow = FALSE;
	port_cfg.dcb.fOutxDsrFlow = FALSE;
	port_cfg.dcb.fDtrControl = DTR_CONTROL_DISABLE;
	port_cfg.dcb.fDsrSensitivity = FALSE;
	port_cfg.dcb.fTXContinueOnXoff = TRUE;	// ???
	port_cfg.dcb.fOutX = FALSE;
	port_cfg.dcb.fInX = FALSE;
	port_cfg.dcb.fErrorChar = FALSE;
	port_cfg.dcb.fNull = FALSE;
	port_cfg.dcb.fRtsControl = RTS_CONTROL_DISABLE;
	port_cfg.dcb.fAbortOnError = FALSE;
	port_cfg.dcb.ByteSize = 8;
	port_cfg.dcb.Parity = NOPARITY;
	port_cfg.dcb.StopBits = ONESTOPBIT;
	if (!SetCommConfig(port_handle, &port_cfg, sizeof(COMMCONFIG))) {
		CloseHandle(port_handle);
		win32_err(buf);
		error_msg = _("Unable to write communication config to ") + name + _(", ") + buf;
		return -1;
	}
	if (!EscapeCommFunction(port_handle, CLRDTR | CLRRTS)) {
		CloseHandle(port_handle);
		win32_err(buf);
		error_msg = _("Unable to control serial port signals on ") + name + _(", ") + buf;
		return -1;
	}
	// http://msdn2.microsoft.com/en-us/library/aa363190(VS.85).aspx
	// setting to all zeros means timeouts are not used
	//timeouts.ReadIntervalTimeout		= 0;
	timeouts.ReadIntervalTimeout		= MAXDWORD;
	timeouts.ReadTotalTimeoutMultiplier	= 0;
	timeouts.ReadTotalTimeoutConstant	= 0;
	timeouts.WriteTotalTimeoutMultiplier	= 0;
	timeouts.WriteTotalTimeoutConstant	= 0;
	if (!SetCommTimeouts(port_handle, &timeouts)) {
		CloseHandle(port_handle);
		win32_err(buf);
		error_msg = _("Unable to write timeout settings to ") + name + _(", ") + buf;
		return -1;
	}
#endif
	port_name = name;
	port_is_open = 1;
	return 0;
}