The unified diff between revisions [9cb69bf6..] and [84a0b39f..] is displayed below. It can also be downloaded as a raw diff.

This diff has been restricted to the following files: 'src/lsi/dmx.c'

#
# old_revision [9cb69bf681632171c5140ab3801212de4c31e6b2]
# new_revision [84a0b39f678926ca2848e2a0da300842a9cf5809]
#
# patch "src/lsi/dmx.c"
#  from [d291829ae082bb1bea5c8eb16cffc5f0ab62e22b]
#    to [4a4db0cf9441f248b420da5ea0cb72f0ff099e31]
#
============================================================
--- src/lsi/dmx.c	d291829ae082bb1bea5c8eb16cffc5f0ab62e22b
+++ src/lsi/dmx.c	4a4db0cf9441f248b420da5ea0cb72f0ff099e31
@@ -17,14 +17,15 @@ char *dmxuniverse;
 char dmxpacket[DMX_UNIVERSESIZE + DMX_PACKETSIZE];
 char *dmxuniverse;
 
-void dmx_open(void)
+int dmx_open(void)
 {
 	struct termios t;
 	int flags;
 
 	dmxfd = open(PORT, O_NONBLOCK | O_RDWR, 0);
 	if (dmxfd == -1) {
-		err(1, "failed to open DMX port");
+		warn("failed to open DMX port");
+		return 0;
 	}
 
 	flags = fcntl(dmxfd, F_GETFL);
@@ -34,6 +35,8 @@ void dmx_open(void)
 	cfmakeraw(&t);
 	t.c_cflag = CLOCAL | CREAD | CS8;
 	tcsetattr(dmxfd, TCSANOW, &t);
+
+	return 1;
 }
 
 
@@ -94,7 +97,10 @@ int dmx_init(void)
 
 int dmx_init(void)
 {
-	dmx_open();
+	int rv;
+
+	rv = dmx_open();
+
 	dmxpacket[0] = 0x7e;
 	dmxpacket[1] = 6;
 	dmxpacket[2] = (DMX_UNIVERSESIZE+1) & 0xff;
@@ -104,7 +110,7 @@ int dmx_init(void)
 	dmxpacket[DMX_UNIVERSESIZE+5] = 0xe7;
 	dmxuniverse = dmxpacket+5;
 //	dmx_dumpparams();
-	return 1;
+	return rv;
 }
 
 void dmx_setchannel(int channel, int value)
@@ -118,6 +124,10 @@ void dmx_output(void)
 	int off = 0;
 //	char *buf = dmxpacket;
 //	printf("%x %x %x %x %x %x %x %x %x %x %x %x\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]);
+
+	if (dmxfd == -1)
+		return;
+
 	while (off < DMX_PACKETSIZE) {
 		int r;
 		r = write(dmxfd, dmxpacket + off, DMX_PACKETSIZE - off);