Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit 0468ac5f6b1db59901874a5fd20a7432ad685bcd unknown committed May 27, 2011
9 README.txt
@@ -0,0 +1,9 @@
+*Install RXTXserial.dll (32bit) into C:\Program Files (x86)\Cycling '74\Max 5.0\support
+*Install RXTXcomm.jar into C:\Program Files (x86)\Cycling '74\Max 5.0\java\lib
+
+*Add dmx external to max classpath Loader (max.java.config.txt):
+
+ ; add /Users/topher/myclasses to the dynamic classpath of MXJClassLoader ;
+ max.dynamic.class.dir C:/Users/tim/Desktop/eclipse-workspace/dmx
+
+*
57 RXTX/INSTALL
@@ -0,0 +1,57 @@
+Trent Here. I do those ugly brown pages at rxtx.org. Documentation is not
+what I do well :) So please help me when you see problems or something is
+confusing.
+
+For more information provided by end users please visit the rxtx wiki at
+http://rxtx.qbang.org/wiki. This is also where you can help.
+
+Short Install Instructions
+
+Windows
+
+RXTXcomm.jar goes in \jre\lib\ext (under java)
+rxtxSerial.dll goes in \jre\bin
+
+Mac OS X (x86 and ppc) (there is an Installer with the source)
+
+RXTXcomm.jar goes in /Library/Java/Extensions
+librxtxSerial.jnilib goes in /Library/Java/Extensions
+Run fixperm.sh thats in the directory. Fix perms is in the Mac_OS_X
+subdirectory.
+
+Linux (only x86, x86_64, ia64 here but more in the ToyBox)
+
+RXTXcomm.jar goes in /jre/lib/ext (under java)
+librxtxSerial.so goes in /jre/lib/[machine type] (i386 for instance)
+Make sure the user is in group lock or uucp so lockfiles work.
+
+Solaris (sparc only so far)
+
+RXTXcomm.jar goes in /jre/lib/ext (under java)
+librxtxSerial.so goes in /jre/lib/[machine type]
+Make sure the user is in group uucp so lockfiles work.
+
+
+
+
+A person is added to group lock or uucp by editing /etc/groups. Distributions
+have various tools but this works:
+
+lock:x:54: becomes:
+lock:x:53:jarvi,taj
+
+Now jarvi and taj are in group lock.
+
+Also make sure jarvi and taj have read and write permissions on the port.
+
+
+
+
+If there are problems please help each other on the wiki and ask questions
+on the mail-list. User contributed changes will be used here in the next
+release. If you don't like the documentation, you can improve it.
+
+
+--
+Trent Jarvi
+tjarvi@qbang.org
BIN RXTX/RXTXcomm.jar
Binary file not shown.
BIN RXTX/Windows/64bit/rxtxSerial.dll
Binary file not shown.
3 RXTX/Windows/i368-mingw32/README
@@ -0,0 +1,3 @@
+Wed Mar 1 12:01:05 MST 2006
+rxtxSerial.dll had to be recomopiled to link in missing native methods.
+
BIN RXTX/Windows/i368-mingw32/rxtxParallel.dll
Binary file not shown.
BIN RXTX/Windows/i368-mingw32/rxtxSerial.dll
Binary file not shown.
BIN bin/lzrdm/comms/SerialPort.class
Binary file not shown.
BIN bin/lzrdm/dmx/Channel8.class
Binary file not shown.
BIN dmx_patch.amxd
Binary file not shown.
BIN lib/RXTXcomm.jar
Binary file not shown.
BIN lib/core.jar
Binary file not shown.
BIN lib/max.jar
Binary file not shown.
BIN lib/serial.jar
Binary file not shown.
BIN rxtxSerial.dll
Binary file not shown.
131 src/lzrdm/comms/SerialPort.java
@@ -0,0 +1,131 @@
+package lzrdm.comms;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import gnu.io.CommPortIdentifier;
+//import gnu.io.SerialPort;
+import gnu.io.SerialPortEvent;
+import gnu.io.SerialPortEventListener;
+import java.util.Enumeration;
+
+import com.cycling74.max.MaxObject;
+
+
+public class SerialPort implements SerialPortEventListener {
+ gnu.io.SerialPort serialPort;
+ /** The port we're normally going to use. */
+ private static final String PORT_NAMES[] = {
+ "/dev/tty.usbserial-A9007UX1", // Mac OS X
+ "/dev/ttyUSB0", // Linux
+ "COM3", // Windows
+ };
+ /** Buffered input stream from the port */
+ private InputStream input;
+ /** The output stream to the port */
+ private OutputStream output;
+ /** Milliseconds to block while waiting for port open */
+ private static final int TIME_OUT = 2000;
+ /** Default bits per second for COM port. */
+ private static final int DATA_RATE = 9600;
+
+ private MaxObject max;
+
+ public void initialize() {
+ //System.out.println(System.getProperty("java.library.path")); // debug classpath
+
+ CommPortIdentifier portId = null;
+ Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();
+
+ // iterate through, looking for the port
+ while (portEnum.hasMoreElements()) {
+ CommPortIdentifier currPortId = (CommPortIdentifier) portEnum.nextElement();
+ for (String portName : PORT_NAMES) {
+ if (currPortId.getName().equals(portName)) {
+ portId = currPortId;
+ break;
+ }
+ }
+ }
+
+ if (portId == null) {
+ System.out.println("Could not find COM port.");
+ return;
+ }
+
+ try {
+ // open serial port, and use class name for the appName.
+ serialPort = (gnu.io.SerialPort) portId.open(this.getClass().getName(),TIME_OUT);
+
+ // set port parameters
+ serialPort.setSerialPortParams(DATA_RATE,
+ gnu.io.SerialPort.DATABITS_8,
+ gnu.io.SerialPort.STOPBITS_1,
+ gnu.io.SerialPort.PARITY_NONE);
+
+ // open the streams
+ input = serialPort.getInputStream();
+ output = serialPort.getOutputStream();
+
+ // add event listeners
+ serialPort.addEventListener(this);
+ serialPort.notifyOnDataAvailable(true);
+ } catch (Exception e) {
+ System.err.println(e.toString());
+ }
+ }
+
+ /**
+ * This should be called when you stop using the port.
+ * This will prevent port locking on platforms like Linux.
+ */
+ public synchronized void close() {
+ if (serialPort != null) {
+ serialPort.removeEventListener();
+ serialPort.close();
+ }
+ }
+
+ /**
+ * Handle an event on the serial port. Read the data and print it.
+ */
+ public synchronized void serialEvent(SerialPortEvent oEvent) {
+ if (oEvent.getEventType() == SerialPortEvent.DATA_AVAILABLE) {
+ try {
+ int available = input.available();
+ byte chunk[] = new byte[available];
+ input.read(chunk, 0, available);
+
+ // Displayed results are codepage dependent
+ //System.out.print(new String(chunk));
+ max.post(new String(chunk));
+ } catch (Exception e) {
+ System.err.println(e.toString());
+ }
+ }
+ // Ignore all the other eventTypes, but you should consider the other ones.
+ }
+ /**
+ * Write data to serial port
+ */
+ public void write(int i){
+ try {
+ output.write(i);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ public static void main(String[] args) throws Exception {
+ SerialPort main = new SerialPort();
+ main.initialize();
+ int x = 0;
+ while(x<100){
+ main.write(x);
+ x++;
+ }
+ System.out.println("Started");
+ }
+ public void setMax(MaxObject m){
+ max = m;
+ }
+}
57 src/lzrdm/dmx/Channel8.java
@@ -0,0 +1,57 @@
+package lzrdm.dmx;
+
+import lzrdm.comms.SerialPort;
+
+import com.cycling74.max.DataTypes;
+import com.cycling74.max.MaxObject;
+import processing.serial.*;
+
+
+public class Channel8 extends MaxObject{
+ //private static final int[] INLETS = new int[]{ DataTypes.ALL };
+ //private static final int[] OUTLETS = new int[] { DataTypes.ALL, };
+
+ private int serial_rate;
+ private int start_address; //start DMX address
+
+ private int[] channel_data;
+
+ public Channel8(){
+ this(9600, 0); //default rate
+ }
+ public Channel8(int start_add){
+ this(9600, start_add);
+ }
+ public Channel8(int sr, int start_add){
+ serial_rate = sr;
+ start_address = start_add;
+
+ declareIO(8,1);
+ //declareInlets(INLETS);
+ //declareOutlets(OUTLETS);
+
+ //==--- max info labels ---==//
+ //createInfoOutlet(false); //info off
+ setInletAssist(new String[] {"DMX channel "+start_address,"DMX channel "+(start_address+1),
+ "DMX channel "+(start_address+1),"DMX channel "+(start_address+3),
+ "DMX channel "+(start_address+4),"DMX channel "+(start_address+5),
+ "DMX channel "+(start_address+6),"DMX channel "+(start_address+7)
+ });
+ setOutletAssist(new String[] {"blah"});
+
+ //== serial ==//
+ SerialPort port = new SerialPort();
+ port.initialize();
+ port.setMax(this);
+ //port.write(512);
+ }
+ public void setAllChannels(int val){
+ val = bound(val);
+ for (int i : channel_data) channel_data[i] = val;
+ }
+ public int bound(int v){
+ v = (v < 0) ? 0 : v;
+ v = (v > 255) ? 255 : v;
+ return v;
+ }
+}

0 comments on commit 0468ac5

Please sign in to comment.