OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_49/] [or1ksim/] [peripheral/] [channels/] [tty.c] - Diff between revs 1222 and 1308

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 1222 Rev 1308
Line 22... Line 22...
#include <stdio.h>
#include <stdio.h>
#include <termios.h>
#include <termios.h>
#include <unistd.h>
#include <unistd.h>
#include <string.h>
#include <string.h>
#include <fcntl.h>
#include <fcntl.h>
 
#include <stdlib.h>
 
 
#include "channel.h"
#include "channel.h"
#include "generic.h"
#include "generic.h"
#include "fd.h"
#include "fd.h"
 
 
Line 91... Line 92...
        baud = DEFAULT_BAUD;
        baud = DEFAULT_BAUD;
        device = DEFAULT_TTY_DEVICE;
        device = DEFAULT_TTY_DEVICE;
 
 
        // Parse command-line parameters
        // Parse command-line parameters
        // Command line looks like name1=value1,name2,name3=value3,...
        // Command line looks like name1=value1,name2,name3=value3,...
        while (param_name = strtok((char*)input, ",")) {
        while ((param_name = strtok((char*)input, ","))) {
 
 
                input = NULL;
                input = NULL;
 
 
                // Parse a parameter's name and value
                // Parse a parameter's name and value
                param_value = strchr(param_name,'=');
                param_value = strchr(param_name,'=');
Line 148... Line 149...
    // Set the new options for the port...
    // Set the new options for the port...
    if (tcsetattr(fd, TCSANOW, &options) < 0)
    if (tcsetattr(fd, TCSANOW, &options) < 0)
                goto error;
                goto error;
 
 
    channel->fds.fdin = channel->fds.fdout = fd;
    channel->fds.fdin = channel->fds.fdout = fd;
        free(input);
        free((void *)input);
    return channel;
    return channel;
 
 
error:
error:
    if (fd > 0)
    if (fd > 0)
                close(fd);
                close(fd);
    free(channel);
    free(channel);
        if (input)
        if (input)
                free(input);
                free((void *)input);
    return NULL;
    return NULL;
}
}
 
 
static int tty_open(void * data)
static int tty_open(void * data)
{
{

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.