aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2008-06-16 10:24:42 +0000
committerIOhannes m zmölnig <zmoelnig@iem.at>2015-10-14 15:08:24 +0200
commit3d0ac4fc230dfdebd5dcc1eaab4a7ad222279193 (patch)
treef59428e084dbdf0e602f8fef963ce7c790dbb9a2
parenta1130c53ea736d68d8d2a260d80a7e182a638813 (diff)
[dmxout] now can be used to set entire ranges
svn path=/trunk/externals/iem/dmx512/; revision=10009
-rw-r--r--dmx512/README.txt61
-rw-r--r--dmx512/dmx4linux2.6.1.patch196
-rw-r--r--dmx512/src/Make.config.in2
-rw-r--r--dmx512/src/Makefile2
-rw-r--r--dmx512/src/dmxout.c116
5 files changed, 348 insertions, 29 deletions
diff --git a/dmx512/README.txt b/dmx512/README.txt
index 96579bc..7cb93f8 100644
--- a/dmx512/README.txt
+++ b/dmx512/README.txt
@@ -2,3 +2,64 @@ DMX512
======
controlling DMX from within Pd
+
+
+
+A. setting up dmx4linux
+=======================
+note: there are debian(etch)-packages for dmx4linux,
+ but these seem to be pretty old (2.5)
+ i haven't really tried these.
+ instead i used dmx4linux-2.6.1
+
+first get dmx4linux from http://llg.cubic.org/dmx4linux/
+and extract it.
+
+the drivers should compile fine with 2.6.18 kernels, but
+alas! i am using 2.6.25 and there are some quirks to make
+these work.
+
+first of all i had problems compiling the ISA/PCI/parport drivers,
+but since i only wanted to use a USB device, i just disabled those.
+second, dmx4linux's build-system tries to override CFLAGS when building
+the kernel-modules, which newer kernel versions (e.g. 2.6.25) do not like
+at all. i had to modify the makefiles in order to use the EXTRA_CFLAGS
+
+all the changes i did can be found in the dmx4linux2.6.1.patch
+just run:
+% patch -p1 < dmx4linux2.6.1.patch
+
+then do
+% ./configure
+(which will produce a /tmp/dmxconfig.mk)
+and run
+% make
+
+finally become root and do
+# make install
+
+
+load the appropriate kernel modules
+
+
+B. permissions
+the dmx device-files created by udev will be owned by root.root and not be
+read/writeable by anyone but root.
+in order to use them as an ordinary user, become root and create a group
+"dmx" and add users who need access to the dmx-devices to this group:
+# addgroup dmx
+# adduser zmoelnig dmx
+
+in theory this should be enough to allow you access to your dmx devices
+the next time you load a dmx-driver
+if you have problems, try plugging your device out and in again
+
+
+
+
+
+
+
+
+
+
diff --git a/dmx512/dmx4linux2.6.1.patch b/dmx512/dmx4linux2.6.1.patch
new file mode 100644
index 0000000..842a3ba
--- /dev/null
+++ b/dmx512/dmx4linux2.6.1.patch
@@ -0,0 +1,196 @@
+diff -Naur dmx4linux-2.6.1/configure dmx4linux-2.6.1.new/configure
+--- dmx4linux-2.6.1/configure 2008-04-25 02:13:31.000000000 +0200
++++ dmx4linux-2.6.1.new/configure 2008-06-14 16:56:21.000000000 +0200
+@@ -43,7 +43,7 @@
+
+ echo "AS31=$DMXROOT/tools/as31-unix" >> /tmp/dmxconfig.mk
+
+-echo "CFLAGS+=-Wall -O2 -I$DMXROOT/include" >> /tmp/dmxconfig.mk
++echo "DMX_CFLAGS+=-Wall -O2 -I$DMXROOT/include" >> /tmp/dmxconfig.mk
+ echo "LDFLAGS+=-L$DMXROOT/libs" >> /tmp/dmxconfig.mk
+
+ if [ -f /usr/include/gpm.h -o -f /usr/local/include/gpm.h ] ; then
+diff -Naur dmx4linux-2.6.1/drivers/devices/dgm/Makefile dmx4linux-2.6.1.new/drivers/devices/dgm/Makefile
+--- dmx4linux-2.6.1/drivers/devices/dgm/Makefile 2008-04-25 02:13:32.000000000 +0200
++++ dmx4linux-2.6.1.new/drivers/devices/dgm/Makefile 2008-06-14 16:53:25.000000000 +0200
+@@ -17,7 +17,7 @@
+ endif
+
+ ifneq ($(KERNELRELEASE),)
+-EXTRA_CFLAGS:=-DDMXVERSION=\"${DMXVERSION}\"
++EXTRA_CFLAGS:=-DDMXVERSION=\"${DMXVERSION}\" $(DMX_CFLAGS)
+ else
+
+ PWD := $(shell pwd)
+diff -Naur dmx4linux-2.6.1/drivers/devices/isa/Makefile dmx4linux-2.6.1.new/drivers/devices/isa/Makefile
+--- dmx4linux-2.6.1/drivers/devices/isa/Makefile 2008-04-25 02:13:32.000000000 +0200
++++ dmx4linux-2.6.1.new/drivers/devices/isa/Makefile 2008-06-14 16:54:02.000000000 +0200
+@@ -5,7 +5,7 @@
+ obj-m := dmxenlight.o
+
+ ifneq ($(KERNELRELEASE),)
+-EXTRA_CFLAGS:=-DDMXVERSION=\"${DMXVERSION}\"
++EXTRA_CFLAGS:=-DDMXVERSION=\"${DMXVERSION}\" $(DMX_CFLAGS)
+ else
+
+ PWD := $(shell pwd)
+diff -Naur dmx4linux-2.6.1/drivers/devices/isa/soundlight/Makefile dmx4linux-2.6.1.new/drivers/devices/isa/soundlight/Makefile
+--- dmx4linux-2.6.1/drivers/devices/isa/soundlight/Makefile 2008-04-25 02:13:32.000000000 +0200
++++ dmx4linux-2.6.1.new/drivers/devices/isa/soundlight/Makefile 2008-06-14 16:53:57.000000000 +0200
+@@ -4,7 +4,7 @@
+
+ ifneq ($(KERNELRELEASE),)
+ dmxsoundlight-objs=soundlight.o autoprobe.o slh_general.o slh1512a.o slh1512b.o slh1512c.o card_access.o
+-EXTRA_CFLAGS:=-DDMXVERSION=\"${DMXVERSION}\"
++EXTRA_CFLAGS:=-DDMXVERSION=\"${DMXVERSION}\" $(DMX_CFLAGS)
+
+ $(src)/%.h : $(src)/%.asm
+ $(AS31)/as31 -Fbin -s $< | sh $(src)/bin2hex.sh $< > $@
+diff -Naur dmx4linux-2.6.1/drivers/devices/Makefile dmx4linux-2.6.1.new/drivers/devices/Makefile
+--- dmx4linux-2.6.1/drivers/devices/Makefile 2008-04-25 02:13:32.000000000 +0200
++++ dmx4linux-2.6.1.new/drivers/devices/Makefile 2008-06-14 16:58:50.000000000 +0200
+@@ -5,15 +5,15 @@
+ ifneq ($(CONFIG_USB),)
+ $(MAKE) -C usb $@
+ endif
+-ifneq ($(CONFIG_ISA),)
+- $(MAKE) -C isa $@
+-endif
+-ifneq ($(CONFIG_PCI),)
+- $(MAKE) -C pci $@
+-endif
+-ifneq ($(CONFIG_PARPORT),)
+- $(MAKE) -C parport $@
+-endif
++#ifneq ($(CONFIG_ISA),)
++# $(MAKE) -C isa $@
++#endif
++#ifneq ($(CONFIG_PCI),)
++# $(MAKE) -C pci $@
++#endif
++#ifneq ($(CONFIG_PARPORT),)
++# $(MAKE) -C parport $@
++#endif
+
+ # PCMCIA dmx drivers are currently not supported on 2.6 kernels
+ #ifneq ($(CONFIG_PCMCIA),)
+diff -Naur dmx4linux-2.6.1/drivers/devices/misc/Makefile dmx4linux-2.6.1.new/drivers/devices/misc/Makefile
+--- dmx4linux-2.6.1/drivers/devices/misc/Makefile 2008-04-25 02:13:32.000000000 +0200
++++ dmx4linux-2.6.1.new/drivers/devices/misc/Makefile 2008-06-14 16:54:07.000000000 +0200
+@@ -3,7 +3,7 @@
+ obj-m := dmxdummy.o
+
+ ifneq ($(KERNELRELEASE),)
+-EXTRA_CFLAGS:=-DDMXVERSION=\"${DMXVERSION}\"
++EXTRA_CFLAGS:=-DDMXVERSION=\"${DMXVERSION}\" $(DMX_CFLAGS)
+ else
+
+ PWD := $(shell pwd)
+diff -Naur dmx4linux-2.6.1/drivers/devices/parport/Makefile dmx4linux-2.6.1.new/drivers/devices/parport/Makefile
+--- dmx4linux-2.6.1/drivers/devices/parport/Makefile 2008-04-25 02:13:32.000000000 +0200
++++ dmx4linux-2.6.1.new/drivers/devices/parport/Makefile 2008-06-14 16:53:52.000000000 +0200
+@@ -5,7 +5,7 @@
+ obj-m := avrdmx.o dmx30.o dmx43.o dmxpcp.o okddmx.o lpr2dmx.o
+
+ ifneq ($(KERNELRELEASE),)
+-EXTRA_CFLAGS:=-DDMXVERSION=\"${DMXVERSION}\"
++EXTRA_CFLAGS:=-DDMXVERSION=\"${DMXVERSION}\" $(DMX_CFLAGS)
+ else
+
+ PWD := $(shell pwd)
+diff -Naur dmx4linux-2.6.1/drivers/devices/pci/Makefile dmx4linux-2.6.1.new/drivers/devices/pci/Makefile
+--- dmx4linux-2.6.1/drivers/devices/pci/Makefile 2008-04-25 02:13:32.000000000 +0200
++++ dmx4linux-2.6.1.new/drivers/devices/pci/Makefile 2008-06-14 16:53:47.000000000 +0200
+@@ -5,7 +5,7 @@
+ obj-m += slh1514pci.o
+
+ ifneq ($(KERNELRELEASE),)
+-EXTRA_CFLAGS:=-DDMXVERSION=\"${DMXVERSION}\" -DDMXPCI_DMX4LINUX=1
++EXTRA_CFLAGS:=-DDMXVERSION=\"${DMXVERSION}\" -DDMXPCI_DMX4LINUX=1 $(DMX_CFLAGS)
+ else
+
+ PWD := $(shell pwd)
+diff -Naur dmx4linux-2.6.1/drivers/devices/pcmcia/Makefile dmx4linux-2.6.1.new/drivers/devices/pcmcia/Makefile
+--- dmx4linux-2.6.1/drivers/devices/pcmcia/Makefile 2008-04-25 02:13:32.000000000 +0200
++++ dmx4linux-2.6.1.new/drivers/devices/pcmcia/Makefile 2008-06-14 16:53:38.000000000 +0200
+@@ -5,7 +5,7 @@
+ obj-m += digimedia_cs.o
+
+ ifneq ($(KERNELRELEASE),)
+-EXTRA_CFLAGS:=-DDMXVERSION=\"${DMXVERSION}\"
++EXTRA_CFLAGS:=-DDMXVERSION=\"${DMXVERSION}\" $(DMX_CFLAGS)
+ else
+
+ PWD := $(shell pwd)
+diff -Naur dmx4linux-2.6.1/drivers/devices/usb/Makefile dmx4linux-2.6.1.new/drivers/devices/usb/Makefile
+--- dmx4linux-2.6.1/drivers/devices/usb/Makefile 2008-04-25 02:13:32.000000000 +0200
++++ dmx4linux-2.6.1.new/drivers/devices/usb/Makefile 2008-06-14 16:53:14.000000000 +0200
+@@ -5,7 +5,7 @@
+ obj-m := usb2dmx.o ftdi2dmx.o sunlite.o
+
+ ifneq ($(KERNELRELEASE),)
+-EXTRA_CFLAGS:=-DDMXVERSION=\"${DMXVERSION}\"
++EXTRA_CFLAGS:=-DDMXVERSION=\"${DMXVERSION}\" $(DMX_CFLAGS)
+ else
+
+ PWD := $(shell pwd)
+diff -Naur dmx4linux-2.6.1/drivers/dmxdev/Makefile dmx4linux-2.6.1.new/drivers/dmxdev/Makefile
+--- dmx4linux-2.6.1/drivers/dmxdev/Makefile 2008-04-25 02:13:32.000000000 +0200
++++ dmx4linux-2.6.1.new/drivers/dmxdev/Makefile 2008-06-14 16:54:22.000000000 +0200
+@@ -8,7 +8,8 @@
+ dmxdev-objs:=dmx_dev.o dmx_proc.o dmx_props.o dmx_family.o dmx_driver.o dmx_interface.o dmx_universe.o dmx_fileinfo.o
+ EXTRA_CFLAGS:=-DDMXVERSION=\"${DMXVERSION}\" \
+ -DDMXOUTMINOR=$(DMXOUTMINOR) -DDMXINMINOR=$(DMXINMINOR) \
+- -DVERSIONMAJOR=$(VERSIONMAJOR) -DVERSIONMINOR=$(VERSIONMINOR)
++ -DVERSIONMAJOR=$(VERSIONMAJOR) -DVERSIONMINOR=$(VERSIONMINOR) \
++ $(DMX_CFLAGS)
+
+ else
+
+diff -Naur dmx4linux-2.6.1/examples/htmlexamples/Makefile dmx4linux-2.6.1.new/examples/htmlexamples/Makefile
+--- dmx4linux-2.6.1/examples/htmlexamples/Makefile 2008-04-25 02:13:31.000000000 +0200
++++ dmx4linux-2.6.1.new/examples/htmlexamples/Makefile 2008-06-14 16:54:42.000000000 +0200
+@@ -2,7 +2,7 @@
+
+ TARGETS= nonblockread selectread simpleread simplewrite
+
+-CFLAGS+= -Wall
++CFLAGS+= $(DMX_CFLAGS) -Wall
+
+ all: $(TARGETS)
+
+diff -Naur dmx4linux-2.6.1/examples/Makefile dmx4linux-2.6.1.new/examples/Makefile
+--- dmx4linux-2.6.1/examples/Makefile 2008-04-25 02:13:31.000000000 +0200
++++ dmx4linux-2.6.1.new/examples/Makefile 2008-06-14 17:00:15.000000000 +0200
+@@ -6,6 +6,8 @@
+
+ -include /tmp/dmxconfig.mk
+
++CFLAGS += $(DMX_CFLAGS)
++
+ TARGETS= pingdmx setdmx dmxinfo dmxdump
+
+ all: $(TARGETS)
+diff -Naur dmx4linux-2.6.1/tools/Makefile dmx4linux-2.6.1.new/tools/Makefile
+--- dmx4linux-2.6.1/tools/Makefile 2008-04-25 02:13:32.000000000 +0200
++++ dmx4linux-2.6.1.new/tools/Makefile 2008-06-14 16:55:16.000000000 +0200
+@@ -4,7 +4,7 @@
+ MANINSTALLPATH=$(DMXPREFIX)/man/man1
+
+ DMXCONSOLELIBS+= -Lpointer pointer/pointer.a
+-CFLAGS+= -Ipointer
++CFLAGS+= -Ipointer $(DMX_CFLAGS)
+
+ ifdef CONFIG_HAVE_LIRC
+ CFLAGS+= -DHAVE_LIRC=1
+diff -Naur dmx4linux-2.6.1/tools/pointer/Makefile dmx4linux-2.6.1.new/tools/pointer/Makefile
+--- dmx4linux-2.6.1/tools/pointer/Makefile 2008-04-25 02:13:32.000000000 +0200
++++ dmx4linux-2.6.1.new/tools/pointer/Makefile 2008-06-14 16:59:35.000000000 +0200
+@@ -1,5 +1,7 @@
+ -include /tmp/dmxconfig.mk
+
++CFLAGS+=$(DMX_CFLAGS)
++
+ C= js.c pointer.c ps2.c serial.c
+ ifdef CONFIG_HAVE_GPM
+ C+= gpm.c
diff --git a/dmx512/src/Make.config.in b/dmx512/src/Make.config.in
index d3ac25f..3386e58 100644
--- a/dmx512/src/Make.config.in
+++ b/dmx512/src/Make.config.in
@@ -25,7 +25,7 @@ TARNAME = $(LIBNAME)-$(VERSION).tgz
BINTARNAME = $(LIBNAME)-$(VERSION)-bin.tgz
-CFLAGS = $(DEFS) $(IFLAGS) $(WFLAGS) @CFLAGS@
+DMX4PD_CFLAGS = $(DEFS) $(IFLAGS) $(WFLAGS) @CFLAGS@
LIBS = @LIBS@
diff --git a/dmx512/src/Makefile b/dmx512/src/Makefile
index e634df6..36b92bc 100644
--- a/dmx512/src/Makefile
+++ b/dmx512/src/Makefile
@@ -67,7 +67,7 @@ ifeq (,$(findstring clean, $(MAKECMDGOALS)))
-include $(SOURCES:.c=.d)
%.d: %.c
@set -e; rm -f $@; \
- $(CC) $(MAKEDEP_FLAGS) $(CFLAGS) $< > $@.$$$$; \
+ $(CC) $(MAKEDEP_FLAGS) $(DMX4PD_CFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
diff --git a/dmx512/src/dmxout.c b/dmx512/src/dmxout.c
index 08d70b2..6066567 100644
--- a/dmx512/src/dmxout.c
+++ b/dmx512/src/dmxout.c
@@ -21,6 +21,7 @@
#include <string.h>
static t_class *dmxout_class;
+static t_class *dmxout_class2;
typedef struct _dmxout
{
@@ -30,6 +31,7 @@ typedef struct _dmxout
int x_device;
t_float x_port;
+ int x_portrange;
} t_dmxout;
@@ -64,16 +66,21 @@ static void dmxout_open(t_dmxout*x, t_symbol*s_devname)
}
}
-static void dmxout_doout(t_dmxout*x, short port, unsigned char value)
+static void dmxout_doout(t_dmxout*x, short baseport, short portrange, dmx_t*values)
{
- dmx_t buffer[1] = {value};
if(x->x_device<=0) {
pd_error(x, "no DMX universe found");
return;
}
- lseek (x->x_device, sizeof(buffer)*port, SEEK_SET); /* set to the current channel */
- write (x->x_device, buffer, sizeof(buffer)); /* write the channel */
+ lseek (x->x_device, sizeof(dmx_t)*baseport, SEEK_SET); /* set to the current channel */
+ write (x->x_device, values, portrange*sizeof(dmx_t)); /* write the channel */
+}
+
+static void dmxout_doout1(t_dmxout*x, short port, unsigned char value)
+{
+ dmx_t buffer[1] = {value};
+ dmxout_doout(x, port, 1, buffer);
}
@@ -90,42 +97,86 @@ static void dmxout_float(t_dmxout*x, t_float f)
return;
}
- dmxout_doout(x, port, val);
+ dmxout_doout1(x, port, val);
}
-static void *dmxout_new(t_symbol*s, int argc, t_atom*argv)
+static void dmxout_list(t_dmxout*x, t_symbol*s, int argc, t_atom*argv)
+{
+ int count=(argc<x->x_portrange)?argc:x->x_portrange;
+ dmx_t*buffer=(dmx_t*)getbytes(count*sizeof(dmx_t));
+ int i=0;
+
+ int errors=0;
+
+ for(i=0; i<count; i++) {
+ t_float f=atom_getfloat(argv+i);
+ if(f<0. || f>255.) {
+ errors++;
+ if(f<0.)f=0.;
+ if(f>255)f=255;
+ }
+ buffer[i]=(unsigned char)f;
+ }
+ if(errors) {
+ pd_error(x, "%d valu%s out of bound [0..255]", errors, (1==errors)?"e":"es");
+ }
+
+ dmxout_doout(x, x->x_port, count, buffer);
+}
+
+static void dmxout_port(t_dmxout*x, t_float f_baseport, t_floatarg f_portrange)
{
- t_dmxout *x = (t_dmxout *)pd_new(dmxout_class);
+ short baseport =(short)f_baseport;
+ short portrange=(short)f_portrange;
- t_symbol*devname=gensym("");
- x->x_portinlet=floatinlet_new(&x->x_obj, &x->x_port);
+ if(baseport<0 || baseport>=512) {
+ pd_error(x, "port %f out of bounds [0..512]", f_baseport);
+ baseport =0;
+ }
+ x->x_port = baseport;
- x->x_device=-1;
- x->x_port =0;
+ if(portrange<0) {
+ pd_error(x, "portrange %f<0! setting to 1", portrange);
+ portrange=1;
+ } else if (portrange==0) {
+ portrange=x->x_portrange;
+ }
+
+ if (baseport+portrange>512) {
+ pd_error(x, "upper port exceeds 512! clamping");
+ portrange=512-baseport;
+ }
+ x->x_portrange=portrange;
+}
+
+static void *dmxout_new(t_symbol*s, int argc, t_atom*argv)
+{
+ t_floatarg baseport=0.f, portrange=0.f;
+ t_dmxout *x = 0;
switch(argc) {
- case 0: break;
+ case 2:
+ x=(t_dmxout *)pd_new(dmxout_class2);
+ x->x_portinlet=inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("port"));
+ baseport=atom_getfloat(argv);
+ portrange=atom_getfloat(argv+1);
+ dmxout_port(x, baseport, portrange);
+ break;
case 1:
- if(A_FLOAT==argv->a_type) {
- x->x_port=atom_getfloat(argv);
- } else {
- devname=atom_getsymbol(argv);
- }
+ baseport=atom_getfloat(argv);
+ case 0:
+ x=(t_dmxout *)pd_new(dmxout_class);
+ x->x_portinlet=floatinlet_new(&x->x_obj, &x->x_port);
+ x->x_port = baseport;
+ x->x_portrange = -1;
break;
default:
- if((A_FLOAT==(argv+0)->a_type) && (A_SYMBOL==(argv+1)->a_type)) {
- x->x_port=atom_getfloat(argv+0);
- devname=atom_getsymbol(argv+1);
- } else if(A_FLOAT==(argv+1)->a_type && A_SYMBOL==(argv+0)->a_type) {
- x->x_port=atom_getfloat(argv+1);
- devname=atom_getsymbol (argv+0);
- }
- break;
+ return 0;
}
+ x->x_device=-1;
-
- dmxout_open(x, devname);
+ dmxout_open(x, gensym(""));
return (x);
}
@@ -144,6 +195,17 @@ void dmxout_setup(void)
class_addfloat(dmxout_class, dmxout_float);
+ dmxout_class2 = class_new(gensym("dmxout"), (t_newmethod)dmxout_new, (t_method)dmxout_free,
+ sizeof(t_dmxout),
+ 0,
+ A_GIMME, A_NULL);
+
+ class_addlist(dmxout_class2, dmxout_list);
+
+
+ class_addmethod(dmxout_class2, (t_method)dmxout_port, gensym("port"),
+ A_FLOAT, A_DEFFLOAT, A_NULL);
+
#ifdef DMX4PD_POSTBANNER
DMX4PD_POSTBANNER
#endif