Example #1
0
char *RemoteLink( char *parm, bool server )
{
    char *result;

    server = server;
    if( parm == NULL )
        parm = "";
    result = SetLinkParms( &parm );  /* set com: port & max baud rate */
    if( result != NULL ) {
        DonePort();
        return( result );
    }
    result = InitSys();
    if( result != NULL ) {
        DonePort();
        return( result );
    }
    result = SetupModem( parm );
    if( result != NULL )
        RemoteUnLink();
    return( result );
}
Example #2
0
char *ParsePortSpec( const char **spec )
{
    int         port;
    int         nid;
    char        ch;
    const char  *parm;
    char        *start;
    static char name[PATH_MAX + 1];

    parm = (spec == NULL) ? "" : *spec;
    nid = 0;
    port = 0;
    if( *parm == '/' ) {
        start = name;
        do {
            *start++ = *parm++;
            ch = *parm;
        } while( ch != '.' && ch != '\0' );
        *start = '\0';
        if( ComPort != 0 ) {
            DonePort();
        }
        ComPort = open( name, O_RDWR );
        if( spec != NULL ) {
            *spec = parm;
        }
    } else {
        for( ;; ) {
            ch = *parm;
            if( ch < '0' || ch > '9' )
                break;
            port = port * 10 + ( ch - '0' );
            ++parm;
        }
        if( ch == ',' ) {
            nid = port;
            if( nid > 255 )
                return( TRP_QNX_invalid_node_number );
            port = 0;
            for( ;; ) {
                ++parm;
                ch = *parm;
                if( ch < '0' || ch > '9' )
                    break;
                port = port * 10 + (ch-'0');
            }
        }
        if( port == 0 )
            port = 1;
        if( port > 99 )
            return( TRP_ERR_invalid_serial_port_number );
        if( spec != NULL )
            *spec = parm;
        strcpy( name, "//___/dev/ser__" );
        name[4] = nid % 10 + '0';
        nid /= 10;
        name[3] = nid % 10 + '0';
        nid /= 10;
        name[2] = nid % 10 + '0';
        if( ComPort != 0 ) {
        name[14] = port % 10 + '0';
        name[13] = port / 10 + '0';
            DonePort();
        }
        ComPort = open( name, O_RDWR );
    }
    if( ComPort < 0 ) {
        ComPort = 0;
        return( (errno == ENOENT) ?
                TRP_ERR_serial_port_does_not_exist : TRP_ERR_serial_port_not_available );
    }
    tcgetattr( ComPort, &SavePort );
    CurrPort = SavePort;
    CurrPort.c_iflag = PARMRK;
    CurrPort.c_oflag = 0;
    CurrPort.c_cflag = CREAD | CS8;
    CurrPort.c_lflag = 0;
    if( tcsetattr( ComPort, TCSADRAIN, &CurrPort ) != 0 ) {
        return( TRP_ERR_could_not_set_serial_port_characteristics );
    }
    return( NULL );
}
Example #3
0
void RemoteUnLink( void )
{
    ResetSys();       /* reset system to initial state */
    DonePort();
}