コード例 #1
0
ファイル: dmxout.c プロジェクト: Duality4Y/dmx2artnet
int dg_echo(int sockfd, SA *pcliaddr, socklen_t clilen)
{
    int ret;

#ifndef EMULATE
#ifdef FTDI
	if ((ret = dmx_init(&ftdic)) == EXIT_SUCCESS)
#endif // FTDI
#ifdef SC12
	if ((ret = dmx_init(port, 250000L, FOSSIL_PARITY_NO, 8, 2)) == EXIT_SUCCESS)
//	if ((ret = dmx_init(port, 19200L, FOSSIL_PARITY_NO, 8, 1)) == EXIT_SUCCESS)
#endif // SC12
#endif // EMULATE
	{
		int                     n, m;
		int             channel;
		int             nchars;
		socklen_t       len;
		unsigned char   mesg[MAXLINE];
		int             i;
#ifdef SC12
		int error;
#endif

		bzero(dmx, sizeof(dmx));
#ifndef EMULATE
#ifndef SC12
		set_timer();
#endif
#endif
		for ( ; ; ) {
#ifdef SC12
			n = recvfrom(sockfd, mesg, MAXLINE, MSG_BLOCKING, 0L, pcliaddr, &error);
			if (n >= 20) // minimum required ArtDMX size
			{
#else
			len = clilen;
			n = recvfrom(sockfd, mesg, MAXLINE, 0, pcliaddr, &len);
#endif
			if (strcmp(mesg, "Art-Net") == 0)
			{
				int opcode = mesg[8] | mesg[9] << 8; 
				if (opcode == 0x5000) // OpDmx
				{
					int length = mesg[16] << 8 | (mesg[17] & 0xFE); // force even
					if (length <= 512)
					{
						bcopy(mesg + 18, dmx + 1, length);
						dmx_write(port, dmx, length + 1);
						fossil_flush_output(port);
					}
				}
			}
#ifdef SC12
			}
#endif
		}
	}
	return ret;
}
コード例 #2
0
ファイル: dmx_service.c プロジェクト: ati/dmx-room-lights
static int universe_set(struct dmx_t dmx, size_t size)
{
    int ret = EXIT_FAILURE;

    if ((do_dmx_break(&ftdic) == EXIT_SUCCESS) && (dmx_write(&ftdic, dmx, size) == EXIT_SUCCESS))
    {
        ret = EXIT_SUCCESS;
    }
    return ret;
}
コード例 #3
0
ファイル: dmxout.c プロジェクト: Duality4Y/dmx2artnet
void alarm_wakeup(int i)
{
	dmx_write(&ftdic, dmx, sizeof(dmx));
}