From af93ca96c383b1b862033eb1ca1595c123ac8db6 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Wed, 26 Dec 2012 10:51:19 -0800 Subject: [PATCH] Added /dev/ttyAMAn devices as possible serial port lines on *nix systems. Fixed reset disconnect logic for serial lines --- sim_serial.c | 9 +++++++++ sim_tmxr.c | 8 +------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/sim_serial.c b/sim_serial.c index 1bba576f..ff9ba2b9 100644 --- a/sim_serial.c +++ b/sim_serial.c @@ -897,6 +897,15 @@ for (i=0; (ports < max) && (i < 64); ++i) { close (port); } } +for (i=0; (ports < max) && (i < 64); ++i) { + sprintf (list[ports].name, "/dev/ttyAMA%d", i); + port = open (list[ports].name, O_RDWR | O_NOCTTY | O_NONBLOCK); /* open the port */ + if (port != -1) { /* open OK? */ + if (isatty (port)) /* is device a TTY? */ + ++ports; + close (port); + } + } for (i=1; (ports < max) && (i < 64); ++i) { sprintf (list[ports].name, "/dev/tty.serial%d", i); port = open (list[ports].name, O_RDWR | O_NOCTTY | O_NONBLOCK); /* open the port */ diff --git a/sim_tmxr.c b/sim_tmxr.c index 3299b695..441300af 100644 --- a/sim_tmxr.c +++ b/sim_tmxr.c @@ -901,14 +901,8 @@ if ((lp->destination) && (!lp->serport)) { if (lp->connecting) sim_close_sock (lp->connecting, 0); lp->connecting = sim_connect_sock (lp->destination, "localhost", NULL); - lp->ipad = malloc (1 + strlen (lp->destination)); - strcpy (lp->ipad, lp->destination); - lp->cnms = sim_os_msec (); } -else { - tmxr_init_line (lp); /* initialize line state */ - } -lp->conn = FALSE; /* remove connection flag */ +tmxr_init_line (lp); /* initialize line state */ /* Revise the unit's connect string to reflect the current attachments */ lp->mp->uptr->filename = _mux_attach_string (lp->mp->uptr->filename, lp->mp); /* No connections or listeners exist, then we're equivalent to being fully detached. We should reflect that */