[PD-cvs] SF.net SVN: pure-data: [10009] trunk/externals/iem/dmx512

zmoelnig at users.sourceforge.net zmoelnig at users.sourceforge.net
Mon Jun 16 12:24:42 CEST 2008


Revision: 10009
          http://pure-data.svn.sourceforge.net/pure-data/?rev=10009&view=rev
Author:   zmoelnig
Date:     2008-06-16 03:24:42 -0700 (Mon, 16 Jun 2008)

Log Message:
-----------
[dmxout] now can be used to set entire ranges

Modified Paths:
--------------
    trunk/externals/iem/dmx512/README.txt
    trunk/externals/iem/dmx512/src/Make.config.in
    trunk/externals/iem/dmx512/src/Makefile
    trunk/externals/iem/dmx512/src/dmxout.c

Added Paths:
-----------
    trunk/externals/iem/dmx512/dmx4linux2.6.1.patch

Modified: trunk/externals/iem/dmx512/README.txt
===================================================================
--- trunk/externals/iem/dmx512/README.txt	2008-06-16 10:10:36 UTC (rev 10008)
+++ trunk/externals/iem/dmx512/README.txt	2008-06-16 10:24:42 UTC (rev 10009)
@@ -2,3 +2,64 @@
 ======
 
 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
+
+
+
+
+
+
+
+
+
+

Added: trunk/externals/iem/dmx512/dmx4linux2.6.1.patch
===================================================================
--- trunk/externals/iem/dmx512/dmx4linux2.6.1.patch	                        (rev 0)
+++ trunk/externals/iem/dmx512/dmx4linux2.6.1.patch	2008-06-16 10:24:42 UTC (rev 10009)
@@ -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

Modified: trunk/externals/iem/dmx512/src/Make.config.in
===================================================================
--- trunk/externals/iem/dmx512/src/Make.config.in	2008-06-16 10:10:36 UTC (rev 10008)
+++ trunk/externals/iem/dmx512/src/Make.config.in	2008-06-16 10:24:42 UTC (rev 10009)
@@ -25,7 +25,7 @@
 BINTARNAME =  $(LIBNAME)-$(VERSION)-bin.tgz
 
 
-CFLAGS = $(DEFS) $(IFLAGS) $(WFLAGS) @CFLAGS@ 
+DMX4PD_CFLAGS = $(DEFS) $(IFLAGS) $(WFLAGS) @CFLAGS@ 
 
 LIBS = @LIBS@
 

Modified: trunk/externals/iem/dmx512/src/Makefile
===================================================================
--- trunk/externals/iem/dmx512/src/Makefile	2008-06-16 10:10:36 UTC (rev 10008)
+++ trunk/externals/iem/dmx512/src/Makefile	2008-06-16 10:24:42 UTC (rev 10009)
@@ -67,7 +67,7 @@
 -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 $@.$$$$
 

Modified: trunk/externals/iem/dmx512/src/dmxout.c
===================================================================
--- trunk/externals/iem/dmx512/src/dmxout.c	2008-06-16 10:10:36 UTC (rev 10008)
+++ trunk/externals/iem/dmx512/src/dmxout.c	2008-06-16 10:24:42 UTC (rev 10009)
@@ -21,6 +21,7 @@
 #include <string.h>
 
 static t_class *dmxout_class;
+static t_class *dmxout_class2;
 
 typedef struct _dmxout
 {
@@ -30,6 +31,7 @@
 
   int      x_device;
   t_float  x_port;
+  int  x_portrange;
 
 } t_dmxout;
 
@@ -64,19 +66,24 @@
   }
 }
 
-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);
+}
 
+
 static void dmxout_float(t_dmxout*x, t_float f)
 {
   unsigned char val=(unsigned char)f;
@@ -90,42 +97,86 @@
     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)
 {
-  t_dmxout *x = (t_dmxout *)pd_new(dmxout_class);
+  int count=(argc<x->x_portrange)?argc:x->x_portrange;
+  dmx_t*buffer=(dmx_t*)getbytes(count*sizeof(dmx_t));
+  int i=0;
 
-  t_symbol*devname=gensym("");
+  int errors=0;
 
-  x->x_portinlet=floatinlet_new(&x->x_obj, &x->x_port);
+  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");
+  }
 
-  x->x_device=-1;
-  x->x_port  =0;
+  dmxout_doout(x, x->x_port, count, buffer);
+}
 
+static void dmxout_port(t_dmxout*x, t_float f_baseport, t_floatarg f_portrange)
+{
+  short baseport =(short)f_baseport;
+  short portrange=(short)f_portrange;
+
+
+  if(baseport<0 || baseport>=512) {
+    pd_error(x, "port %f out of bounds [0..512]", f_baseport);
+    baseport =0;
+  }
+  x->x_port = baseport;
+
+  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 @@
 
   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


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