/* ---------------------------------------------------------------------------- * receive Art-Net packet */ void artnet_get(void) { struct artnet_header *header; header = (struct artnet_header *) uip_appdata; /* check the id */ if (strncmp_P((char *) header->id, artnet_ID, 8)) { ARTNET_DEBUG("Wrong ArtNet header, discarded\r\n"); artnet_status = RC_PARSE_FAIL; return; } switch (header->opcode) { case OP_POLL:; struct artnet_poll *poll; ARTNET_DEBUG("Received artnet poll packet!\r\n"); poll = (struct artnet_poll *) uip_appdata; processPollPacket(poll); break; case OP_POLLREPLY:; ARTNET_DEBUG("Received artnet poll reply packet!\r\n"); break; case OP_OUTPUT:; uip_ipaddr_t artnet_pollReplyTarget; struct artnet_dmx *dmx; ARTNET_DEBUG("Received artnet output packet!\r\n"); dmx = (struct artnet_dmx *) uip_appdata; uip_ipaddr_copy(&artnet_pollReplyTarget, BUF->srcipaddr); if (dmx->universe == ((artnet_subNet << 4) | artnet_outputUniverse)) { if (artnet_dmxDirection == 0) { uint16_t len = ((dmx->lengthHi << 8) + dmx->length); set_dmx_channels((const uint8_t *) &dmx->dataStart, artnet_outputUniverse, 0, len); if (artnet_sendPollReplyOnChange == TRUE) { artnet_pollReplyCounter++; artnet_sendPollReply(&artnet_pollReplyTarget); } } } break; case OP_ADDRESS:; case OP_IPPROG:; break; default: ARTNET_DEBUG("Received an invalid artnet packet!\r\n"); break; } }
// ---------------------------------------------------------------------------- // receive Art-Net packet void artnet_get(unsigned char index) { struct artnet_header *header; header = (struct artnet_header *)ð_buffer[UDP_DATA_START]; //check the id if(strcasestr_P((char*)&header->id,PSTR("Art-Net")) == 0){ //ARTNET_DEBUG("Wrong ArtNet header, discarded\r\n"); artnet_status = RC_PARSE_FAIL; return; } switch(header->opcode) { //OP_POLL case (OP_POLL):{ struct artnet_poll *poll; //ARTNET_DEBUG("Received artnet poll packet!\r\n"); poll = (struct artnet_poll *)ð_buffer[UDP_DATA_START]; processPollPacket(poll); return; } //OP_POLLREPLY case (OP_POLLREPLY):{ //ARTNET_DEBUG("Received artnet poll reply packet!\r\n"); return; } //OP_OUTPUT case (OP_OUTPUT):{ struct artnet_dmx *dmx; //ARTNET_DEBUG("Received artnet output packet!\r\n"); dmx = (struct artnet_dmx *)ð_buffer[UDP_DATA_START]; if (dmx->universe == ((artnet_subNet << 4) | artnet_outputUniverse1)) { if (artnet_dmxDirection == 0) { artnet_dmxChannels = (dmx->lengthHi << 8) | dmx->length; memcpy((unsigned char*)&artnet_dmxUniverse[0], &(dmx->dataStart), artnet_dmxChannels); if (artnet_dmxTransmitting == FALSE) { // setup USART DMXPort |= (1 << DMXDIR_IO); DMXPort |= (1 << DMXTXD); UBRR0 = (F_CPU / (250000* 16L) - 1); UCSR0C|= (1<<USBS0); //USBS0 2 Stop bits UCSR0B|= (1<<TXEN0)|(1<<TXCIE0); // TXEN0 Transmitter enable / TXCIE0 TX complete interrupt enable UDR0 = 0;//start transmitting artnet_dmxTransmitting = TRUE; if (artnet_sendPollReplyOnChange == TRUE) { artnet_pollReplyCounter++; artnet_sendPollReply(); } } isActive = 1; } } return; } //OP_ADDRESS case (OP_ADDRESS):{ struct artnet_address *address; //ARTNET_DEBUG("Received artnet address packet!\r\n"); address = (struct artnet_address *)ð_buffer[UDP_DATA_START]; //processAddressPacket(address); return; } //OP_IPPROG case (OP_IPPROG):{ struct artnet_ipprog *ipprog; //ARTNET_DEBUG("Received artnet ip prog packet!\r\n"); ipprog = (struct artnet_ipprog *)ð_buffer[UDP_DATA_START]; //processIpProgPacket(ipprog); return; } } }