|
|
|
@ -17,14 +17,15 @@ int dmxfd;
|
|
|
|
|
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 @@ out:
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|