[PD-cvs] SF.net SVN: pure-data: [10131] trunk/externals/iem/dmx512/src/dmxout.c
zmoelnig at users.sourceforge.net
zmoelnig at users.sourceforge.net
Wed Jul 2 13:31:27 CEST 2008
Revision: 10131
http://pure-data.svn.sourceforge.net/pure-data/?rev=10131&view=rev
Author: zmoelnig
Date: 2008-07-02 04:31:27 -0700 (Wed, 02 Jul 2008)
Log Message:
-----------
cleaned up a bit
Modified Paths:
--------------
trunk/externals/iem/dmx512/src/dmxout.c
Modified: trunk/externals/iem/dmx512/src/dmxout.c
===================================================================
--- trunk/externals/iem/dmx512/src/dmxout.c 2008-07-01 14:35:47 UTC (rev 10130)
+++ trunk/externals/iem/dmx512/src/dmxout.c 2008-07-02 11:31:27 UTC (rev 10131)
@@ -14,11 +14,11 @@
*
******************************************************/
-
#include "dmx4pd.h"
#include <unistd.h>
#include <string.h>
+#include <stdio.h>
static t_class *dmxout_class;
static t_class *dmxout_class2;
@@ -36,7 +36,6 @@
int x_portrange;
dmx_t x_values[NUM_DMXVALUES];
-
} t_dmxout;
static void dmxout_clearbuf(t_dmxout*x)
@@ -62,6 +61,8 @@
const char*devname="";
int fd;
+ dmxout_close(x);
+
if(s_devname && s_devname->s_name)
devname=s_devname->s_name;
@@ -75,39 +76,32 @@
}
verbose(1, "[dmxout] opening %s", devname);
- fd = open (devname, O_WRONLY);
+ fd = open (devname, O_WRONLY | O_NONBLOCK);
if(fd!=-1) {
- dmxout_close(x);
x->x_device=fd;
+ dmxout_clearbuf(x);
} else {
- error("failed to open DMX-device '%s'",devname);
+ pd_error(x, "failed to open DMX-device '%s'",devname);
}
}
-static void dmxout_doout(t_dmxout*x, dmx_t values[NUM_DMXVALUES])
-{
- int i;
- if(x->x_device<=0) {
+static void dmxout_doout(t_dmxout*x) {
+ int device = x->x_device;
+ if(device<=0) {
pd_error(x, "no DMX universe found");
return;
}
-#if 0
- for(i=0; i<NUM_DMXVALUES; i++) {
- post("dmx[%d]=%03d", i, values[i]);
- }
- endpost();
-#endif
- lseek (x->x_device, 0, SEEK_SET); /* set to the current channel */
- write (x->x_device, values, NUM_DMXVALUES); /* write the channel */
+ lseek (device, 0, SEEK_SET); /* set to the current channel */
+ write (device, x->x_values, NUM_DMXVALUES); /* write the channel */
}
+
static void dmxout_doout1(t_dmxout*x, short port, unsigned char value)
{
- dmxout_clearbuf(x);
x->x_values[port]=value;
- dmxout_doout(x, x->x_values);
+ dmxout_doout(x);
}
@@ -139,9 +133,6 @@
port=NUM_DMXVALUES-count;
}
- dmxout_clearbuf(x);
-
-
for(i=0; i<count; i++) {
t_float f=atom_getfloat(argv+i);
if(f<0. || f>255.) {
@@ -155,7 +146,7 @@
pd_error(x, "%d valu%s out of bound [0..255]", errors, (1==errors)?"e":"es");
}
- dmxout_doout(x, x->x_values);
+ dmxout_doout(x);
}
static void dmxout_port(t_dmxout*x, t_float f_baseport, t_floatarg f_portrange)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Pd-cvs
mailing list