/**
 * Send a GET request
 */
void SimpleE133Controller::SendGetRequest(const UID &dst_uid,
                                          uint16_t endpoint,
                                          uint16_t pid,
                                          const uint8_t *data,
                                          unsigned int length) {
  // send a second one
  ola::rdm::RDMGetRequest *command = new ola::rdm::RDMGetRequest(
      m_src_uid,
      dst_uid,
      0,  // transaction #
      1,  // port id
      0,  // message count
      ola::rdm::ROOT_RDM_DEVICE,  // sub device
      pid,  // param id
      data,  // data
      length);  // data length

  if (!SendRequest(dst_uid, endpoint, command)) {
    OLA_FATAL << "Failed to send request";
    m_ss.Terminate();
  } else if (dst_uid.IsBroadcast()) {
    OLA_INFO << "Request broadcast";
    m_ss.Terminate();
  } else {
    OLA_INFO << "Request sent, waiting for response";
  }
}
Esempio n. 2
0
void SimpleE133Monitor::Input(int c) {
  switch (c) {
    case 'q':
      m_ss.Terminate();
      break;
    default:
      break;
  }
}
Esempio n. 3
0
/**
 * Called when a de-registration request completes.
 */
void DeRegisterCallback(ola::io::SelectServer *ss,
                        unsigned int *registrations_active, bool ok) {
  if (ok) {
    OLA_INFO << "Registered E1.33 device";
  } else {
    OLA_WARN << "Failed to register E1.33 device";
  }
  if (--(*registrations_active) == 0)
    ss->Terminate();
}
Esempio n. 4
0
/**
 * Called when data arrives on our UDP socket. We check that this data matches
 * the expected OSC packet
 */
void OSCNodeTest::UDPSocketReady() {
  uint8_t data[500];  // 500 bytes is more than enough
  ssize_t data_read = sizeof(data);
  // Read the received packet into 'data'.
  OLA_ASSERT_TRUE(m_udp_socket.RecvFrom(data, &data_read));
  // Verify it matches the expected packet
  ASSERT_DATA_EQUALS(__LINE__, OSC_BLOB_DATA,
                     sizeof(OSC_BLOB_DATA), data, data_read);
  // Stop the SelectServer
  m_ss.Terminate();
}
/**
 * Handle a RDM message.
 */
void SimpleE133Controller::HandlePacket(
    const ola::e133::E133RDMMessage &rdm_message) {
  OLA_INFO << "RDM callback executed with code: " <<
    ola::rdm::ResponseCodeToString(rdm_message.response_code);

  m_ss.Terminate();

  if (rdm_message.response_code != ola::rdm::RDM_COMPLETED_OK)
    return;

  switch (rdm_message.response->ResponseType()) {
    case ola::rdm::RDM_NACK_REASON:
      HandleNack(rdm_message.response);
      return;
    default:
      break;
  }

  const RDMResponse *response = rdm_message.response;

  const ola::rdm::PidDescriptor *pid_descriptor = m_pid_helper->GetDescriptor(
      response->ParamId(),
      response->SourceUID().ManufacturerId());
  const ola::messaging::Descriptor *descriptor = NULL;

  if (pid_descriptor) {
    switch (response->CommandClass()) {
      case ola::rdm::RDMCommand::GET_COMMAND_RESPONSE:
        descriptor = pid_descriptor->GetResponse();
        break;
      case ola::rdm::RDMCommand::SET_COMMAND_RESPONSE:
        descriptor = pid_descriptor->SetResponse();
        break;
      default:
        OLA_WARN << "Unknown command class " << response->CommandClass();
    }
  }

  auto_ptr<const ola::messaging::Message> message;
  if (descriptor)
    message.reset(m_pid_helper->DeserializeMessage(descriptor,
                                                   response->ParamData(),
                                                   response->ParamDataSize()));

  if (message.get())
    cout << m_pid_helper->PrettyPrintMessage(
        response->SourceUID().ManufacturerId(),
        response->CommandClass() == ola::rdm::RDMCommand::SET_COMMAND_RESPONSE,
        response->ParamId(),
        message.get());
  else
    m_command_printer.DisplayResponse(response, true);
}
Esempio n. 6
0
/**
 * Called when there is data on stdin.
 */
void SimpleE133Node::Input() {
  switch (getchar()) {
    case 'c':
      m_e133_device.CloseTCPConnection();
      break;
    case 'q':
      m_ss.Terminate();
      break;
    case 's':
      SendUnsolicited();
      break;
    case 't':
      DumpTCPStats();
      break;
    default:
      break;
  }
}
/**
 * Called when SLP discovery completes.
 */
void SimpleE133Controller::DiscoveryCallback(bool ok, const URLEntries &urls) {
  if (ok) {
    URLEntries::const_iterator iter;
    UID uid(0, 0);
    IPV4Address ip;
    for (iter = urls.begin(); iter != urls.end(); ++iter) {
      OLA_INFO << "Located " << *iter;
      if (!ola::e133::ParseE133URL(iter->url(), &uid, &ip))
        continue;

      if (uid.IsBroadcast()) {
        OLA_WARN << "UID " << uid << "@" << ip << " is broadcast";
        continue;
      }
      AddUID(uid, ip);
    }
  }
  m_uid_list_updated = true;
  m_ss.Terminate();
}
Esempio n. 8
0
void RootSenderTest::Stop() {
  if (m_ss)
    m_ss->Terminate();
}
Esempio n. 9
0
/*
 * Terminate cleanly on interrupt.
 */
static void InteruptSignal(int signo) {
  ss.Terminate();
  (void) signo;
}
Esempio n. 10
0
/**
 * Called when we receive DMX data via OSC. We check this matches what we
 * expect, and then stop the SelectServer.
 */
void OSCNodeTest::DMXHandler(const DmxBuffer &dmx) {
  m_received_data = dmx;
  m_ss.Terminate();
}
Esempio n. 11
0
/**
 * Called when a de-registration request completes.
 */
void SimpleE133Node::DeRegisterCallback(bool ok) {
  OLA_INFO << "in deregister callback, state is " << ok;
  m_ss.Terminate();
}
Esempio n. 12
0
void UDPTransportTest::Stop() {
  if (m_ss)
    m_ss->Terminate();
}
Esempio n. 13
0
 void CaptureData(uint8_t command, const uint8_t *data, unsigned int length) {
   m_received_data.Set(data, length);
   m_command = command;
   m_ss.Terminate();
 }