// Called when new DMX data arrives. void NewDmx(unsigned int universe, uint8_t priority, const ola::DmxBuffer &data, const std::string &error) { if (error.empty()) { OLA_INFO << "Received " << data.Size() << " channels for universe " << universe << ", priority " << static_cast<int>(priority); } else { OLA_WARN << "Receive failed: " << error; } }
/* * Send some DMX data, allowing finer grained control of parameters. * @param universe the id of the universe to send * @param buffer the DMX data * @param cid the cid to send from * @param sequence_offset used to twiddle the sequence numbers, this doesn't * increment the sequence counter. * @param priority the priority to use * @param preview set to true to turn on the preview bit * @return true if it was sent successfully, false otherwise */ bool E131Node::SendDMXWithSequenceOffset(uint16_t universe, const ola::DmxBuffer &buffer, int8_t sequence_offset, uint8_t priority, bool preview) { map<unsigned int, tx_universe>::iterator iter = m_tx_universes.find(universe); tx_universe *settings; if (iter == m_tx_universes.end()) settings = SetupOutgoingSettings(universe); else settings = &iter->second; const uint8_t *dmp_data; unsigned int dmp_data_length; if (m_use_rev2) { dmp_data = buffer.GetRaw(); dmp_data_length = buffer.Size(); } else { unsigned int data_size = DMX_UNIVERSE_SIZE; buffer.Get(m_send_buffer + 1, &data_size); dmp_data = m_send_buffer; dmp_data_length = data_size + 1; } TwoByteRangeDMPAddress range_addr(0, 1, (uint16_t) dmp_data_length); DMPAddressData<TwoByteRangeDMPAddress> range_chunk(&range_addr, dmp_data, dmp_data_length); vector<DMPAddressData<TwoByteRangeDMPAddress> > ranged_chunks; ranged_chunks.push_back(range_chunk); const DMPPDU *pdu = NewRangeDMPSetProperty<uint16_t>(true, false, ranged_chunks); E131Header header(settings->source, priority, static_cast<uint8_t>(settings->sequence + sequence_offset), universe, preview, // preview false, // terminated m_use_rev2); bool result = m_e131_layer.SendDMP(header, pdu); if (result && !sequence_offset) settings->sequence++; delete pdu; return result; }