From 3eedcabd4a121465600a38be89a264ebe06a6839 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Sat, 26 Aug 2006 20:30:32 +0000 Subject: added quick function to display the available ports using the [info( message. Yes, this is a quick hack svn path=/trunk/externals/iem/comport/; revision=5751 --- comport/comport.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++---- comport/makefile | 2 +- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/comport/comport.c b/comport/comport.c index 70d22a3..6a4d0de 100644 --- a/comport/comport.c +++ b/comport/comport.c @@ -43,12 +43,13 @@ typedef struct comport { t_object x_obj; long n; /* the state of a last input */ - HANDLE comhandle; /* holds the comport handle */ #ifdef _WIN32 + HANDLE comhandle; /* holds the comport handle */ DCB dcb; /* holds the comm pars */ DCB dcb_old; /* holds the comm pars */ COMMTIMEOUTS old_timeouts; #else + int comhandle; /* holds the comport handle */ struct termios oldcom_termio; /* save the old com config */ struct termios com_termio; /* for the new com config */ #endif @@ -700,7 +701,7 @@ static int set_xonxoff(t_comport *x, int nr) static int open_serial(unsigned int com_num, t_comport *x) { - HANDLE fd; + int fd; struct termios *old = &(x->oldcom_termio); struct termios *new = &(x->com_termio); float *baud = &(x->baud); @@ -883,8 +884,12 @@ static void comport_pollintervall(t_comport *x, t_floatarg g) static void comport_tick(t_comport *x) { +#ifdef _WIN32 + HANDLE fd = x->comhandle; +#else + int fd = x->comhandle; +#endif /* _WIN32 */ int err; - HANDLE fd = x->comhandle; x->x_hit = 0; @@ -1036,7 +1041,7 @@ static void *comport_new(t_floatarg com_num, t_floatarg fbaud) static void comport_free(t_comport *x) { - post("free serial..."); + post("[comport] free serial..."); clock_unset(x->x_clock); clock_free(x->x_clock); x->comhandle = close_serial(x); @@ -1231,6 +1236,44 @@ static void comport_print(t_comport *x, t_symbol *s, int argc, t_atom *argv) } } +static void comport_output_print(t_comport *x) +{ + unsigned int i; + + post("[comport]: available serial ports:"); +#ifdef _WIN32 + post("\t0 - COM1"); + for(i=1; iserial_device_name, 0, NULL, &glob_buffer ) ) + { + case GLOB_NOSPACE: + error("[comport] out of memory for \"%s\"",x->serial_device_name); + break; +# ifdef GLOB_ABORTED + case GLOB_ABORTED: + error("[comport] aborted \"%s\"",x->serial_device_name); + break; +# endif /* GLOB_ABORTED */ +# ifdef GLOB_NOMATCH + case GLOB_NOMATCH: + error("[comport] no serial devices found for \"%s\"",x->serial_device_name); + break; +# endif /* GLOB_NOMATCH */ + } + for(i=0; i