コード例 #1
0
ファイル: dut_tb.cpp プロジェクト: 32bitmicro/migen
int main(int argc, char **argv, char **env)
{
	float speed;

#ifndef WITH_SERIAL_PTY
	set_conio_terminal_mode();
#endif

	Verilated::commandArgs(argc, argv);
	dut = new Vdut;

	Verilated::traceEverOn(true);
	tfp = new VerilatedVcdC;
	dut->trace(tfp, 99);
	tfp->open("dut.vcd");

	struct sim s;
	sim_init(&s);

#ifdef WITH_SERIAL_PTY
	console_init(&s);
	console_open(&s);
#endif

#ifdef WITH_ETH
	eth_init(&s, "/dev/net/tap0", "tap0"); // XXX get this from /tmp/simethernet
	eth_open(&s);
#endif

	s.run = true;
	while(s.run) {
		sim_tick(&s);
		if(SYS_CLK) {
#ifdef WITH_SERIAL
			if(console_service(&s) != 0)
				s.run = false;
#endif
#ifdef WITH_ETH
			ethernet_service(&s);
#endif
		}
	}
	s.end = clock();

	speed = (s.tick/2)/((s.end-s.start)/CLOCKS_PER_SEC);

	printf("average speed: %3.3f MHz\n\r", speed/1000000);

	tfp->close();


#ifdef WITH_SERIAL_PTY
	console_close(&s);
#endif
#ifdef WITH_ETH
	eth_close(&s);
#endif

	exit(0);
}
コード例 #2
0
ファイル: console.c プロジェクト: MaikelS11/OpenRCT2
void console_toggle()
{
	if (gConsoleOpen)
		console_close();
	else
		console_open();
}
コード例 #3
0
ファイル: init.c プロジェクト: zuopucuen/lfsinit
static void
sysinit ()
{
	int status, fd;

	if (fork () == 0)
	{
		setsid ();
		if ((fd = console_open (O_RDWR | O_NOCTTY)) >= 0)
		{
			/* Take over controlling tty by force */
			(void) ioctl (fd, TIOCSCTTY, 1);
			dup (fd);
			dup (fd);
		}
		execl (SHELL, "bash", SYSINIT, NULL);
		exit (1);
	}

	wait (&status);

	if (status > 0)
	{
		initlog ("sysinit error!");
	}
}
コード例 #4
0
ファイル: init.c プロジェクト: zuopucuen/lfsinit
static void
print (char *s)
{
	int fd;

	if ((fd = console_open (O_WRONLY | O_NOCTTY | O_NDELAY)) >= 0)
	{
		write (fd, s, strlen (s));
		close (fd);
	}
}
コード例 #5
0
ファイル: init.c プロジェクト: CarlChenCC/examples
/*
 *	Print to the system console
 */
void print(char const* dev, char *s)
{
    int fd;

    if ((fd = console_open(dev, O_WRONLY|O_NOCTTY|O_NDELAY)) >= 0) {
        int rc = write(fd, s, strlen(s));
        int rc2 = close(fd);
        fprintf(fp_log, "In print, write returned %d, close %d\n", rc, rc2);
    } else {
        fprintf(fp_log, "Error printing because failed to open dev %s\n", dev);
    }
}
コード例 #6
0
ファイル: qnxscrn.c プロジェクト: Azarien/open-watcom-v2
static bool TryQConsole( void )
{
    struct _psinfo              psinfo;
    struct _sidinfo             info;
    struct _dev_info_entry      dev;
    char                        *ptr;
    const char                  *term;

    if( qnx_psinfo( PROC_PID, getpid(), &psinfo, 0, 0 ) != getpid() ) {
        StartupErr( "unable to obtain process information" );
    }
    if( qnx_sid_query( PROC_PID, psinfo.sid, &info ) != psinfo.sid ) {
        StartupErr( "unable to obtain console name" );
    }
    ptr = info.tty_name + strlen( info.tty_name );
    for( ;; ) {
        --ptr;
        if( *ptr < '0' || *ptr > '9' ) {
            break;
        }
    }
    if( DbgConsole != 0 ) {
        ptr[1] = '0' + DbgConsole / 10;
        ptr[2] = '0' + DbgConsole % 10;
        ptr += 2;
    }
    ptr[1] = NULLCHAR;
    DbgConHandle = open( info.tty_name, O_RDWR );
    if( DbgConHandle == -1 ) {
        StartupErr( "unable to open system console" );
    }
    term = getenv( "TERM" );
    if( term != NULL && strcmp( term, "qnxw" ) == 0 ) {
        /* in QNX windows */
#define PROP_STRING     "\033\"pwd\""
        write( DbgConHandle, PROP_STRING, sizeof( PROP_STRING ) - 1 );
    }

    ConCtrl = console_open( DbgConHandle, O_WRONLY );
    if( ConCtrl == NULL ) {
        close( DbgConHandle );
        return( false );
    }
    if( dev_info( DbgConHandle, &dev ) == -1 ) {
        StartupErr( "unable to obtain console information" );
    }
    DbgConsole = dev.unit;
    console_size( ConCtrl, DbgConsole, 0, 0, &PrevLines, &PrevColumns );
    console_size( ConCtrl, DbgConsole, DbgLines, DbgColumns, 0, 0 );
    InitConsole = console_active( ConCtrl, -1 );
    return( true );
}
コード例 #7
0
/*
 * ScreenInit - get screen info
 */
void ScreenInit( void )
{
    struct _osinfo              info;
    int                         rows, cols;
    unsigned                    size;
    unsigned                    seg;
    vi_rc                       rc;


    QNXCon = console_open( QNXConHandle, O_WRONLY );
    if( QNXCon == NULL ) {
        // FatalError( ERR_WIND_NO_MORE_WINDOWS );
        ChangeDirectory( HomeDirectory );
        exit( 0 );
    }
    if( console_size( QNXCon, QNXConsole, 0, 0, &rows, &cols ) != 0 ) {
        console_close( QNXCon );
        FatalError( ERR_WIND_NO_MORE_WINDOWS );
    }
    rc = BIOSKeyboardInit();
    if( rc != ERR_NO_ERR ) {
        console_close( QNXCon );
        FatalError( rc );
    }
    EditVars.WindMaxWidth = cols;
    EditVars.WindMaxHeight = rows;

    qnx_osinfo( 0, &info );
    switch( info.primary_monitor ) {
    case _MONITOR_PGS:
    case _MONITOR_CGA:
    case _MONITOR_PS30_COLOR:
    case _MONITOR_EGA_COLOR:
    case _MONITOR_VGA_COLOR:
        EditFlags.Color = TRUE;
        break;
    case _MONITOR_EGA_MONO:
    case _MONITOR_VGA_MONO:
    case _MONITOR_PS30_MONO:
        EditFlags.BlackAndWhite = TRUE;
        break;
    default:
        EditFlags.Monocolor = TRUE;
        break;
    }
    size = cols * rows * sizeof( char_info );
    seg = qnx_segment_alloc( size );
    Scrn = MK_FP( seg, 0 );
    ScreenPage( 0 );

} /* ScreenInit */
コード例 #8
0
trap_retval ReqRead_user_keyboard( void )
{
    struct _console_ctrl    *con;
    unsigned                con_num;
    int                     con_hdl;
    int                     con_mode;
    char                    chr;
    //NYI: what about QNX windows?
    static char             con_name[] = "/dev/conXX";
    unsigned                timeout;
    read_user_keyboard_req      *acc;
    read_user_keyboard_ret      *ret;

#   define FIRST_DIGIT (sizeof( con_name ) - 3)

    acc = GetInPtr( 0 );
    ret = GetOutPtr( 0 );
    timeout = acc->wait * 10;
    if( timeout == 0 ) timeout = -1;
    ret->key = '\0';
    con = console_open( 2, O_WRONLY );
    if( con == NULL ) {
        return( sizeof( *ret ) );
    }
    con_num = console_active( con, -1 );
    console_close( con );
    con_name[ FIRST_DIGIT + 0 ] = (con_num / 10) + '0';
    con_name[ FIRST_DIGIT + 1 ] = (con_num % 10) + '0';

    con_hdl = open( con_name, O_RDONLY );
    if( con_hdl < 0 ) {
        if( timeout == -1 ) timeout = 50;
        sleep( timeout / 10 );
        return( sizeof( *ret ) );
    }
    con_mode = dev_mode( con_hdl, 0, _DEV_MODES );
    if( dev_read( con_hdl, &chr, 1, 1, 0, timeout, 0, 0 ) == 1 ) {
        if( chr == 0xff ) {
            read( con_hdl, &chr, 1 );
            chr = '\0';
        }
        ret->key = chr;
    }
    dev_mode( con_hdl, con_mode, _DEV_MODES );
    close( con_hdl );
    return( sizeof( *ret ) );
}
コード例 #9
0
ファイル: cfe_console.c プロジェクト: Noltari/cfe_bcm63xx
int cfe_set_console(char *name)
{
    xprinthook = console_xprint;

#if !CFG_MINIMAL_SIZE
    if (strcmp(name,CFE_BUFFER_CONSOLE) == 0) {
	console_buffer_flg = 1;
	return 0;
	}
#endif

    if (name) {
	int res;
	res = env_setenv("BOOT_CONSOLE",name,
		   ENV_FLG_BUILTIN | ENV_FLG_READONLY | ENV_FLG_ADMIN);
	return console_open(name);
	}
    return -1;
}
コード例 #10
0
void cfe_command_restart(uint64_t status)
{
    /*
     * Stop alternate CPU(s).  If they're already stopped, this
     * command will make sure they're stopped.
     */

#if CFG_MULTI_CPUS
    altcpu_cmd_stop(1);
#endif

    /*
     * Call board reset functions
     */
    board_device_reset();

    /*
     * Reset devices
     */
    cfe_device_reset();

    /*
     * Reset timers
     */
    cfe_timer_init();

    /*
     * Reopen console 
     */
    console_open(console_name);

    /*
     * Display program return status
     */

    xprintf("*exit status = %d\n", (int)status);

    /*
     * Back to processing user commands
     */
    cfe_command_loop();
}
コード例 #11
0
ファイル: init.c プロジェクト: zuopucuen/lfsinit
static void
start_login ()
{
	int fd, status;

	login_pid = fork ();
	if (login_pid == 0)
	{
		setsid ();
		if ((fd = console_open (O_RDWR | O_NOCTTY)) >= 0)
		{
			/* Take over controlling tty by force */
			(void) ioctl (fd, TIOCSCTTY, 1);
			dup (fd);
			dup (fd);
		}

		execv (LOGIN, NULL);
	}
}
コード例 #12
0
int OpenDUT()
{
    ENTRY;
    if(strlen(interface_name) == 0)
    {
        strcpy(interface_name,INTERFACE_NAME);
    }
    connection = console_open(interface_name);
    if(connection == NULL)
    {
        sprintf(is_error, "Failed to open \"%s\"",interface_name);
        error_msg = is_error;
        RETURNI(-1);
    }

    current_channel = 1;

    error_msg = no_error;
    RETURNI(SUCCESS);
}
コード例 #13
0
ファイル: pm.c プロジェクト: BackupTheBerlios/uuu
PM_HWND PMAPI PM_openConsole(
    PM_HWND hwndUser,
    int device,
    int xRes,
    int yRes,
    int bpp,
    ibool fullScreen)
{
#ifndef __QNXNTO__
    int fd;

    if (console_count++)
        return 0;
    if ((fd = open("/dev/con1", O_RDWR)) == -1)
        return -1;
    cc = console_open(fd, O_RDWR);
    close(fd);
    if (cc == NULL)
        return -1;
#endif
    return 1;
}
コード例 #14
0
ファイル: uimon.c プロジェクト: martinpiper/VICE
console_t *uimon_window_open(void)
{
  console_log = console_open("Monitor");
  return console_log;
}
コード例 #15
0
ファイル: uxcons.c プロジェクト: chemhack/putty
int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
{
    size_t curr_prompt;
    FILE *outfp = NULL;
    int infd;

    /*
     * Zero all the results, in case we abort half-way through.
     */
    {
	int i;
	for (i = 0; i < p->n_prompts; i++)
            prompt_set_result(p->prompts[i], "");
    }

    if (p->n_prompts && console_batch_mode)
	return 0;

    console_open(&outfp, &infd);

    /*
     * Preamble.
     */
    /* We only print the `name' caption if we have to... */
    if (p->name_reqd && p->name) {
	size_t l = strlen(p->name);
	console_prompt_text(outfp, p->name, l);
	if (p->name[l-1] != '\n')
	    console_prompt_text(outfp, "\n", 1);
    }
    /* ...but we always print any `instruction'. */
    if (p->instruction) {
	size_t l = strlen(p->instruction);
	console_prompt_text(outfp, p->instruction, l);
	if (p->instruction[l-1] != '\n')
	    console_prompt_text(outfp, "\n", 1);
    }

    for (curr_prompt = 0; curr_prompt < p->n_prompts; curr_prompt++) {

	struct termios oldmode, newmode;
	int len;
	prompt_t *pr = p->prompts[curr_prompt];

	tcgetattr(infd, &oldmode);
	newmode = oldmode;
	newmode.c_lflag |= ISIG | ICANON;
	if (!pr->echo)
	    newmode.c_lflag &= ~ECHO;
	else
	    newmode.c_lflag |= ECHO;
	tcsetattr(infd, TCSANOW, &newmode);

	console_prompt_text(outfp, pr->prompt, strlen(pr->prompt));

        len = 0;
        while (1) {
            int ret;

            prompt_ensure_result_size(pr, len * 5 / 4 + 512);
            ret = read(infd, pr->result + len, pr->resultsize - len - 1);
            if (ret <= 0) {
                len = -1;
                break;
            }
            len += ret;
            if (pr->result[len - 1] == '\n') {
                len--;
                break;
            }
        }

	tcsetattr(infd, TCSANOW, &oldmode);

	if (!pr->echo)
	    console_prompt_text(outfp, "\n", 1);

        if (len < 0) {
            console_close(outfp, infd);
            return 0;                  /* failure due to read error */
        }

	pr->result[len] = '\0';
    }

    console_close(outfp, infd);

    return 1; /* success */
}
コード例 #16
0
ファイル: elbug.c プロジェクト: denrusio/vak-opensource
int main(int argc, char *argv[]) {
    int c, status, err = 0;
    static int idlewait = 0;
    unsigned short int dcd, cts;
    
    while ((c = getopt(argc, argv, "f:w:s:di")) != -1) {
	switch (c) {
	    case 'f':
		tone = strtoul(optarg, NULL, 0);
		if (tone && (tone < 50 || tone > 5000)) {
		    printf("tone %d out of range 0 or 50...5000 Hz\n", tone);
    		    err++;
		}
		break;
	    case 's':
		name_ptt = optarg;
		if (! strcmp (name_ptt, "/dev/ttyS0")) {
		    port = 0x03F8;
		    break;
		}
		if (! strcmp (name_ptt, "/dev/ttyS1")) {
		    port = 0x02F8;
		    break;
		}
		if (! strcmp (name_ptt, "/dev/ttyS2")) {
		    port = 0x03E8;
		    break;
		}
		if (! strcmp (name_ptt, "/dev/ttyS3")) {
		    port = 0x02E8;
		    break;
		}
		break;
    	    case 'd':
		pin = TIOCM_DTR;
    		break;
            case 'i':
	        invert_ptt = 1;
    	        break;
    	    case 'w':
		wpm = strtoul(optarg, NULL, 0);
		if (wpm < 3 || wpm > 90) {
		    printf("Speed %d out of range 3...90 wpm\n", wpm);
    		    err++;
		}
		break;
	    default:
        	err++;
        	break;
    	}
    	if (err) {
    	  printf("/* dl4mge's elbug.*/\n"
		"usage: elbug [-w <speed wpm>] [-s <ptt comm port>] [-d] [-i] \n"
			"  -w: speed in wpm              (default: 12 words per minute)\n"
			"  -f: tone frequency in Hz      (default: 440 Hz, enter 0 for silent mode)\n"
			"  -s: serial port for in/output (default: /dev/ttyS0)\n"
			"  -d: output through DTR pin    (default is RTS)\n"
			"  -i: invert PTT                (default: PTT = positive)\n"
			"%s", cable);
	exit (0);
	}
    }
    if ((err = IOPERM(port, 8, 1))) {
	printf("permission problem for serial port %04x: ioperm = %d\n", port, err);
	printf("This program has to be called with root permissions.\n");
    }
    if ((fd_ptt = open(name_ptt, O_RDWR, 0)) < 0) {
	printf("error in opening ptt device %s - maybe try another one?\n", 
	    name_ptt);
    }
    
    dotus = 1000000 / (wpm * 50 / 60);
    if (tone) argp = 1193180/tone; else argp = 0;
    /* from man console_ioctl */
    		
    printf("%s",cable);
    printf("\nelbug: %d wpm at %s, address %04x, %s %s\n",
	wpm, name_ptt, port,
	invert_ptt ? "inverted ptt output," : "",
	pin == TIOCM_DTR ? "DTR output" : "RTS output");
    printf("A dit will last %d ms.\n", dotus/1000);
    printf("See options by elbug -h. Stop me by <strg>c.\n");
    
    output_elbug_serial(0);
#ifdef KIOCSOUND
    if (argp) spkr = console_open();
#endif        
    
    /* main loop */
    for (;;) {
    	status = 0;
        ioctl(fd_ptt, TIOCMGET, &status);
	cts = status & TIOCM_CTS;
	dcd = status & TIOCM_CAR;
//	printf("cts: %d, dcd: %d\n", cts, dcd);
 	if (cts) {
		elbug_send_dit();
		decode(DIT);
	}
	if (dcd) {
		elbug_send_dah();
		decode(DAH);
	}
	wait(3000);
	idlewait += 3000;
	if (idlewait > dotus) {
		idlewait = 0;
		decode(PAUSE);
	}
    }
}
コード例 #17
0
ファイル: init.c プロジェクト: zuopucuen/lfsinit
static void
console_stty (void)
{
	struct termios tty;

	int fd;

	if ((fd = console_open (O_RDWR | O_NOCTTY)) < 0)
	{
		initlog ("can't open console!");
		return;
	}

	(void) tcgetattr (fd, &tty);

	tty.c_cflag &= CBAUD | CBAUDEX | CSIZE | CSTOPB | PARENB | PARODD;
	tty.c_cflag |= HUPCL | CLOCAL | CREAD;

	tty.c_cc[VINTR] = CINTR;
	tty.c_cc[VQUIT] = CQUIT;
	tty.c_cc[VERASE] = CERASE;	/* ASCII DEL (0177) */
	tty.c_cc[VKILL] = CKILL;
	tty.c_cc[VEOF] = CEOF;
	tty.c_cc[VTIME] = 0;
	tty.c_cc[VMIN] = 1;
	tty.c_cc[VSWTC] = _POSIX_VDISABLE;
	tty.c_cc[VSTART] = CSTART;
	tty.c_cc[VSTOP] = CSTOP;
	tty.c_cc[VSUSP] = CSUSP;
	tty.c_cc[VEOL] = _POSIX_VDISABLE;
	tty.c_cc[VREPRINT] = CREPRINT;
	tty.c_cc[VDISCARD] = CDISCARD;
	tty.c_cc[VWERASE] = CWERASE;
	tty.c_cc[VLNEXT] = CLNEXT;
	tty.c_cc[VEOL2] = _POSIX_VDISABLE;

	/*
	 *  Set pre and post processing
	 */
	tty.c_iflag = IGNPAR | ICRNL | IXON | IXANY;
#ifdef IUTF8					/* Not defined on FreeBSD */
	tty.c_iflag |= IUTF8;
#endif							/* IUTF8 */
	tty.c_oflag = OPOST | ONLCR;
	tty.c_lflag = ISIG | ICANON | ECHO | ECHOCTL | ECHOPRT | ECHOKE;

#if defined(SANE_TIO) && (SANE_TIO == 1)
	/*
	 *  Disable flow control (-ixon), ignore break (ignbrk),
	 *  and make nl/cr more usable (sane).
	 */
	tty.c_iflag |= IGNBRK;
	tty.c_iflag &= ~(BRKINT | INLCR | IGNCR | IXON);
	tty.c_oflag &= ~(OCRNL | ONLRET);
#endif
	/*
	 *  Now set the terminal line.
	 *  We don't care about non-transmitted output data
	 *  and non-read input data.
	 */
	(void) tcsetattr (fd, TCSANOW, &tty);
	(void) tcflush (fd, TCIOFLUSH);
	(void) close (fd);
}
コード例 #18
0
ファイル: serialtest.c プロジェクト: vladsor/chaos
int main (void)
{
  keyboard_packet_type keyboard_packet;
  int event_type;
  bool local_echo = FALSE;
  int baudrate_num = 4;

  log_init (&log_structure, PACKAGE_NAME, &empty_tag);
  
  system_call_process_name_set (PACKAGE_NAME);

  console_init (&console_structure, &empty_tag,
                IPC_CONSOLE_CONNECTION_CLASS_CLIENT);
  console_open (&console_structure, 80, 50, 4, VIDEO_MODE_TYPE_TEXT);
  console_use_keyboard (&console_structure, TRUE, CONSOLE_KEYBOARD_NORMAL);
  console_clear (&console_structure);
  console_print (&console_structure,
                 "Terminator 2000 - The final terminator.\n\n");
    
  if (system_call_thread_create () == STORM_RETURN_THREAD_NEW)
  {
    unsigned char buffer[100];
    int length = 1;
    
    while (TRUE)
    {
      if (config1 != FALSE)
      {
        while (lock == TRUE)
        {
          system_call_dispatch_next ();
        }
        lock = TRUE;

        if (serial_init (&ipc_structure1, &empty_tag) != SERIAL_RETURN_SUCCESS)
        {
          log_print (&log_structure, LOG_URGENCY_EMERGENCY,
                     "Could not establish connection to a serial service.");
          return -1;
        }
        config1 = FALSE;
        lock = FALSE;
        log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "COM %d opened rx.", port_num+1);
      }

      if (serial_read (&ipc_structure1, buffer, length) != SERIAL_RETURN_SUCCESS)
      {
        log_print (&log_structure, LOG_URGENCY_ERROR,
                   "Error reading from port.");
      }
      else
      {
        buffer[length] = 0;
        console_print (&console_structure, buffer);
      }
    }
  }

  while (TRUE)
  {
    bool send = TRUE;
    bool configure = FALSE;
    char key;

    if (config2 != FALSE)
    {
      if (serial_init (&ipc_structure2, &empty_tag) != SERIAL_RETURN_SUCCESS)
      {
        log_print (&log_structure, LOG_URGENCY_EMERGENCY,
                   "Could not establish connection to a serial service.");
        return -1;
      }
      config2 = FALSE;
      log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "COM %d opened tx.", port_num+1);
    }

    console_event_wait (&console_structure, &keyboard_packet,
                        &event_type, TRUE);

    if (keyboard_packet.key_pressed == TRUE)
    {
      if (keyboard_packet.has_character_code == 1)
      {
        key = keyboard_packet.character_code[0];
      }
      else if (keyboard_packet.has_special_key == 1)
      {
        switch (keyboard_packet.special_key)
        {
          case IPC_KEYBOARD_SPECIAL_KEY_ESCAPE:
          {
            log_print (&log_structure, LOG_URGENCY_DEBUG, "Local echo toggled.");
            local_echo = !local_echo;
            send = FALSE;
            break;
          }

          case IPC_KEYBOARD_SPECIAL_KEY_F10:
          {
            if (++port_num >= PORT_NUM)
            {
              port_num = 0;
            }

            send = FALSE;
            config2 = TRUE;

            while (lock == TRUE)
            {
              system_call_dispatch_next ();
            }
            lock = TRUE;
            config1 = TRUE;
            lock = FALSE;
            break;
          }

          case IPC_KEYBOARD_SPECIAL_KEY_F11:
          {
            if (--baudrate_num < 0)
            {
              baudrate_num = BAUDRATE_NUM - 1;
            }

            send = FALSE;
            configure = TRUE;
            break;
          }

          case IPC_KEYBOARD_SPECIAL_KEY_F12:
          {
            if (++baudrate_num >= BAUDRATE_NUM)
            {
              baudrate_num = 0;
            }

            send = FALSE;
            configure = TRUE;
            break;
          }

          case IPC_KEYBOARD_SPECIAL_KEY_TAB:
          {
            key = '\t';
            break;
          }

          case IPC_KEYBOARD_SPECIAL_KEY_BACK_SPACE:
          {
            key = 8;
            break;
          }
          
          case IPC_KEYBOARD_SPECIAL_KEY_ENTER:
          {
            key = '\n';
            break;
          }
        }
      }

      if (send)
      {
        if (serial_write (&ipc_structure2, &key, 1) != SERIAL_RETURN_SUCCESS)
        {
          log_print (&log_structure, LOG_URGENCY_ERROR, "Error writing to port.");
        }
        else
        {
          if (local_echo)
          {         
            char buffer[] = { key, 0 };
            console_print (&console_structure, buffer);
          }
        }
      }

      if (configure != FALSE)
      {
        if (serial_config_line (&ipc_structure2, baudrates[baudrate_num], 8, 
            0, SERIAL_PARITY_NONE) != SERIAL_RETURN_SUCCESS)
        {
          log_print (&log_structure, LOG_URGENCY_ERROR, "Error configuring port.");
        }
        else
        {
          log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "%d 8/N/1 selected.", baudrates[baudrate_num]);
        }
      }
    }
  }

  return 0;
}