turned off asynchronous mode since this object is implemented to use synchronous mode; added up to COM40 (I wonder what the limit is?)
svn path=/trunk/externals/iem/comport/; revision=5035
This commit is contained in:
parent
6b4bddf139
commit
79b8f996c6
1 changed files with 24 additions and 17 deletions
|
|
@ -9,9 +9,12 @@
|
||||||
|
|
||||||
#include "m_pd.h"
|
#include "m_pd.h"
|
||||||
|
|
||||||
#ifdef NT
|
#ifdef _MSC_VER
|
||||||
#pragma warning( disable : 4244 )
|
#pragma warning( disable : 4244 )
|
||||||
#pragma warning( disable : 4305 )
|
#pragma warning( disable : 4305 )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#else
|
#else
|
||||||
|
|
@ -21,7 +24,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#define HANDLE int
|
#define HANDLE int
|
||||||
#define INVALID_HANDLE_VALUE -1
|
#define INVALID_HANDLE_VALUE -1
|
||||||
#endif
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
@ -35,7 +38,7 @@ typedef struct comport
|
||||||
|
|
||||||
HANDLE comhandle; /* holds the comport handle */
|
HANDLE comhandle; /* holds the comport handle */
|
||||||
|
|
||||||
#ifdef NT
|
#ifdef _WIN32
|
||||||
DCB dcb; /* holds the comm pars */
|
DCB dcb; /* holds the comm pars */
|
||||||
DCB dcb_old; /* holds the comm pars */
|
DCB dcb_old; /* holds the comm pars */
|
||||||
COMMTIMEOUTS old_timeouts;
|
COMMTIMEOUTS old_timeouts;
|
||||||
|
|
@ -73,13 +76,21 @@ typedef struct comport
|
||||||
#define RXBUFOVERRUN -4
|
#define RXBUFOVERRUN -4
|
||||||
#define TXBUFOVERRUN -5
|
#define TXBUFOVERRUN -5
|
||||||
|
|
||||||
#ifdef NT
|
#ifdef _WIN32
|
||||||
|
|
||||||
#define COMPORT_MAX 8
|
#define COMPORT_MAX 40
|
||||||
static char *sys_com_port[COMPORT_MAX] =
|
static char *sys_com_port[COMPORT_MAX] =
|
||||||
{
|
{
|
||||||
"COM1", "COM2", "COM3", "COM4",
|
"COM1", "COM2", "COM3", "COM4",
|
||||||
"COM5", "COM6", "COM7", "COM8"
|
"COM5", "COM6", "COM7", "COM8",
|
||||||
|
"COM9", "COM10", "COM11", "COM12",
|
||||||
|
"COM13", "COM14", "COM15", "COM16",
|
||||||
|
"COM17", "COM18", "COM19", "COM20",
|
||||||
|
"COM21", "COM22", "COM23", "COM24",
|
||||||
|
"COM25", "COM26", "COM27", "COM28",
|
||||||
|
"COM29", "COM30", "COM31", "COM32",
|
||||||
|
"COM33", "COM34", "COM35", "COM36",
|
||||||
|
"COM37", "COM38", "COM39", "COM40"
|
||||||
};
|
};
|
||||||
|
|
||||||
static
|
static
|
||||||
|
|
@ -102,7 +113,7 @@ long baudspeedbittable[] =
|
||||||
CBR_110
|
CBR_110
|
||||||
};
|
};
|
||||||
|
|
||||||
#else /* NT */
|
#else /* _WIN32 */
|
||||||
|
|
||||||
#ifdef IRIX
|
#ifdef IRIX
|
||||||
#define COMPORT_MAX 2
|
#define COMPORT_MAX 2
|
||||||
|
|
@ -161,7 +172,7 @@ short baudspeedbittable[] =
|
||||||
|
|
||||||
struct timeval null_tv;
|
struct timeval null_tv;
|
||||||
|
|
||||||
#endif /* else NT */
|
#endif /* else _WIN32 */
|
||||||
|
|
||||||
|
|
||||||
#define BAUDRATETABLE_LEN 15
|
#define BAUDRATETABLE_LEN 15
|
||||||
|
|
@ -213,7 +224,7 @@ static long get_baud_ratebits(t_float *baud)
|
||||||
|
|
||||||
/* --------------------- NT ------------------------------------ */
|
/* --------------------- NT ------------------------------------ */
|
||||||
|
|
||||||
#ifdef NT
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
|
||||||
static float set_baudrate(t_comport *x,t_float baud)
|
static float set_baudrate(t_comport *x,t_float baud)
|
||||||
|
|
@ -327,11 +338,7 @@ static HANDLE open_serial(int com_nr, t_comport *x)
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
OPEN_EXISTING,
|
OPEN_EXISTING,
|
||||||
#ifdef WIN2000
|
|
||||||
0,
|
0,
|
||||||
#else
|
|
||||||
FILE_FLAG_OVERLAPPED,
|
|
||||||
#endif
|
|
||||||
0);
|
0);
|
||||||
|
|
||||||
if(fd == INVALID_HANDLE_VALUE)
|
if(fd == INVALID_HANDLE_VALUE)
|
||||||
|
|
@ -679,7 +686,7 @@ static void comport_tick(t_comport *x)
|
||||||
if(fd == INVALID_HANDLE_VALUE) return;
|
if(fd == INVALID_HANDLE_VALUE) return;
|
||||||
|
|
||||||
/* while there are bytes, read them and send them out, ignore errors */
|
/* while there are bytes, read them and send them out, ignore errors */
|
||||||
#ifdef NT
|
#ifdef _WIN32
|
||||||
{
|
{
|
||||||
DWORD dwCommEvent;
|
DWORD dwCommEvent;
|
||||||
DWORD dwRead;
|
DWORD dwRead;
|
||||||
|
|
@ -775,7 +782,7 @@ static void *comport_new(t_floatarg comnr, t_floatarg fbaud) {
|
||||||
x->baud = test.baud;
|
x->baud = test.baud;
|
||||||
x->comhandle = fd; /* holds the comport handle */
|
x->comhandle = fd; /* holds the comport handle */
|
||||||
|
|
||||||
#ifdef NT
|
#ifdef _WIN32
|
||||||
memcpy(&(test.dcb_old),&(x->dcb_old),sizeof(DCB)); /* save the old com config */
|
memcpy(&(test.dcb_old),&(x->dcb_old),sizeof(DCB)); /* save the old com config */
|
||||||
memcpy(&(test.dcb),&(x->dcb),sizeof(DCB)); /* for the new com config */
|
memcpy(&(test.dcb),&(x->dcb),sizeof(DCB)); /* for the new com config */
|
||||||
#else
|
#else
|
||||||
|
|
@ -977,10 +984,10 @@ void comport_setup(void)
|
||||||
|
|
||||||
class_addmethod(comport_class, (t_method)comport_pollintervall, gensym("pollintervall"),
|
class_addmethod(comport_class, (t_method)comport_pollintervall, gensym("pollintervall"),
|
||||||
A_FLOAT, 0);
|
A_FLOAT, 0);
|
||||||
#ifndef NT
|
#ifndef _WIN32
|
||||||
null_tv.tv_sec = 0; /* no wait */
|
null_tv.tv_sec = 0; /* no wait */
|
||||||
null_tv.tv_usec = 0;
|
null_tv.tv_usec = 0;
|
||||||
#endif
|
#endif /* NOT _WIN32 */
|
||||||
post("comport - PD external for unix/windows\n"
|
post("comport - PD external for unix/windows\n"
|
||||||
"LGPL 1998-2005, Winfried Ritsch and others (see LICENCE.txt)\n"
|
"LGPL 1998-2005, Winfried Ritsch and others (see LICENCE.txt)\n"
|
||||||
"Institute for Electronic Music - Graz");
|
"Institute for Electronic Music - Graz");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue