The unified diff between revisions [4839c414..] and [ce9d6288..] 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 [4839c414876f813b3873cc350a8e42d6c01957fc] # new_revision [ce9d628825328f2576769426f4d3544fe89a14ce] # # patch "src/lsi/dmx.c" # from [fd9f9e6aae06abf60b5def045a152dbb6ad9cf3a] # to [4a4db0cf9441f248b420da5ea0cb72f0ff099e31] # ============================================================ --- src/lsi/dmx.c fd9f9e6aae06abf60b5def045a152dbb6ad9cf3a +++ 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; } @@ -92,9 +95,12 @@ out: 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]); } -void 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,6 +110,7 @@ void dmx_init(void) dmxpacket[DMX_UNIVERSESIZE+5] = 0xe7; dmxuniverse = dmxpacket+5; // dmx_dumpparams(); + return rv; } void dmx_setchannel(int channel, int value) @@ -117,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);