|
|
@ -17,14 +17,15 @@ int dmxfd; |
|
|
|
char dmxpacket[DMX_UNIVERSESIZE + DMX_PACKETSIZE]; |
|
|
|
char dmxpacket[DMX_UNIVERSESIZE + DMX_PACKETSIZE]; |
|
|
|
char *dmxuniverse; |
|
|
|
char *dmxuniverse; |
|
|
|
|
|
|
|
|
|
|
|
void dmx_open(void) |
|
|
|
int dmx_open(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct termios t; |
|
|
|
struct termios t; |
|
|
|
int flags; |
|
|
|
int flags; |
|
|
|
|
|
|
|
|
|
|
|
dmxfd = open(PORT, O_NONBLOCK | O_RDWR, 0); |
|
|
|
dmxfd = open(PORT, O_NONBLOCK | O_RDWR, 0); |
|
|
|
if (dmxfd == -1) { |
|
|
|
if (dmxfd == -1) { |
|
|
|
err(1, "failed to open DMX port"); |
|
|
|
warn("failed to open DMX port"); |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
flags = fcntl(dmxfd, F_GETFL); |
|
|
|
flags = fcntl(dmxfd, F_GETFL); |
|
|
@ -34,6 +35,8 @@ void dmx_open(void) |
|
|
|
cfmakeraw(&t); |
|
|
|
cfmakeraw(&t); |
|
|
|
t.c_cflag = CLOCAL | CREAD | CS8; |
|
|
|
t.c_cflag = CLOCAL | CREAD | CS8; |
|
|
|
tcsetattr(dmxfd, TCSANOW, &t); |
|
|
|
tcsetattr(dmxfd, TCSANOW, &t); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -94,7 +97,10 @@ out: |
|
|
|
|
|
|
|
|
|
|
|
int dmx_init(void) |
|
|
|
int dmx_init(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
dmx_open(); |
|
|
|
int rv; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rv = dmx_open(); |
|
|
|
|
|
|
|
|
|
|
|
dmxpacket[0] = 0x7e; |
|
|
|
dmxpacket[0] = 0x7e; |
|
|
|
dmxpacket[1] = 6; |
|
|
|
dmxpacket[1] = 6; |
|
|
|
dmxpacket[2] = (DMX_UNIVERSESIZE+1) & 0xff; |
|
|
|
dmxpacket[2] = (DMX_UNIVERSESIZE+1) & 0xff; |
|
|
@ -104,7 +110,7 @@ int dmx_init(void) |
|
|
|
dmxpacket[DMX_UNIVERSESIZE+5] = 0xe7; |
|
|
|
dmxpacket[DMX_UNIVERSESIZE+5] = 0xe7; |
|
|
|
dmxuniverse = dmxpacket+5; |
|
|
|
dmxuniverse = dmxpacket+5; |
|
|
|
// dmx_dumpparams();
|
|
|
|
// dmx_dumpparams();
|
|
|
|
return 1; |
|
|
|
return rv; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void dmx_setchannel(int channel, int value) |
|
|
|
void dmx_setchannel(int channel, int value) |
|
|
@ -118,6 +124,10 @@ void dmx_output(void) |
|
|
|
int off = 0; |
|
|
|
int off = 0; |
|
|
|
// char *buf = dmxpacket;
|
|
|
|
// 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]);
|
|
|
|
// 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) { |
|
|
|
while (off < DMX_PACKETSIZE) { |
|
|
|
int r; |
|
|
|
int r; |
|
|
|
r = write(dmxfd, dmxpacket + off, DMX_PACKETSIZE - off); |
|
|
|
r = write(dmxfd, dmxpacket + off, DMX_PACKETSIZE - off); |
|
|
|