Esempio n. 1
0
DDS_DataWriter createDataWriter(DDS_Publisher publisher, DDS_Topic topic)
{
    DDS_DataWriter dataWriter;
    DDS_TopicQos *topicQos = DDS_TopicQos__alloc();
    DDS_DataWriterQos *dataWriterQos = DDS_DataWriterQos__alloc();
    checkHandle(dataWriterQos, "DDS_DataWriterQos__alloc");
    g_status = DDS_Publisher_get_default_datawriter_qos(publisher, dataWriterQos);
    checkStatus(g_status, "DDS_Publisher_get_default_datawriter_qos");
    g_status = DDS_Topic_get_qos(topic, topicQos);
    checkStatus(g_status, "DDS_Topic_get_qos");
    g_status = DDS_Publisher_copy_from_topic_qos(publisher, dataWriterQos, topicQos);
    checkStatus(g_status, "DDS_Publisher_copy_from_topic_qos");
    dataWriterQos->writer_data_lifecycle.autodispose_unregistered_instances = FALSE;
   dataWriter = DDS_Publisher_create_datawriter(publisher, topic, dataWriterQos, NULL, DDS_STATUS_MASK_NONE);
   checkHandle(dataWriter, "DDS_Publisher_create_datawriter");

   return dataWriter;
}
Esempio n. 2
0
void DDSEntityManager::createSubscriber()
{
  int status = participant->get_default_subscriber_qos(sub_qos);
  checkStatus(status, "DDS::DomainParticipant::get_default_subscriber_qos");
  sub_qos.partition.name.length(1);
  sub_qos.partition.name[0] = partition;
  subscriber = participant->create_subscriber(sub_qos, NULL, STATUS_MASK_NONE);
  checkHandle(subscriber.in(), "DDS::DomainParticipant::create_subscriber");
}
Esempio n. 3
0
void createWriter()
{
   // Create a DataWriter for the Topic (using the appropriate QoS).
   g_DataWriterQos = DDS_DataWriterQos__alloc();
   checkHandle(g_DataWriterQos, "DDS_DataWriterQos__alloc");
   g_status = DDS_Publisher_get_default_datawriter_qos(g_Publisher, g_DataWriterQos);
   checkStatus(g_status, "DDS_Publisher_get_default_datawriter_qos");
   g_status = DDS_Publisher_copy_from_topic_qos(g_Publisher, g_DataWriterQos, g_TopicQos);
   checkStatus(g_status, "DDS_Publisher_copy_from_topic_qos");

   // If autodispose_unregistered_instances is true, when the writer is stopped,
   // the instances of the topic will be suppressed from the persistence file;
   // If it is false the data will still be accessible after the Writer has stopped,
   // even if a Reader starts after the Writer's end and then reads the Topic's persistent samples.
   g_DataWriterQos->writer_data_lifecycle.autodispose_unregistered_instances = g_autodispose_unregistered_instances;
   g_DataWriter = DDS_Publisher_create_datawriter(g_Publisher, g_Topic, g_DataWriterQos, NULL, DDS_ANY_STATUS);
   checkHandle(g_DataWriter, "DDS_Publisher_create_datawriter (g_DataWriter)");
}
int OSPL_MAIN (int argc, const char *argv[])
{
   DDS_Publisher message_Publisher;
   DDS_DataWriter message_DataWriter;
   ListenerData_Msg* message_Sample;
   const DDS_char listener [] = "Hello World";
   os_time delay_2s = { 2, 0 };
   DDS_unsigned_long listenerLength = sizeof(listener) - 1;

   printf("\n Starting ListenerPublisher...");

   // Create DDS DomainParticipant
   printf("\n create Participant...");
   createParticipant("Listener example");

   // Register the Topic's type in the DDS Domain.
   g_MessageTypeSupport = ListenerData_MsgTypeSupport__alloc();
   checkHandle(g_MessageTypeSupport, "ListenerData_MsgTypeSupport__alloc");
   registerMessageType(g_MessageTypeSupport);
   // Create the Topic's in the DDS Domain.
   g_MessageTypeName = ListenerData_MsgTypeSupport_get_type_name(g_MessageTypeSupport);
   g_MessageTopic = createTopic("ListenerData_Msg", g_MessageTypeName);
   DDS_free(g_MessageTypeName);
   DDS_free(g_MessageTypeSupport);

   // Create the Publisher's in the DDS Domain.
   message_Publisher = createPublisher();

   // Request a Writer from the the Publisher.
   message_DataWriter = createDataWriter(message_Publisher, g_MessageTopic);

   message_Sample = ListenerData_Msg__alloc();
   message_Sample->userID = 1;
   message_Sample->message = DDS_string_alloc(listenerLength);
   strncpy(message_Sample->message, listener, listenerLength);

   printf("\n=== [ListenerPublisher] writing a message containing :");
   printf("\n    userID  : %d", message_Sample->userID);
   printf("\n    Message : \"%s\"", message_Sample->message);

   g_status = ListenerData_MsgDataWriter_write(message_DataWriter, message_Sample, DDS_HANDLE_NIL);
   checkStatus(g_status, "ListenerData_MsgDataWriter_write");
   os_nanoSleep(delay_2s);
   // Cleanup DDS

   deleteDataWriter(message_Publisher, message_DataWriter);
   deletePublisher(message_Publisher);
   deleteTopic(g_MessageTopic);
   deleteParticipant();

   // Cleanup C allocations
   DDS_free(message_Sample);

   printf("\n=== [ListenerPublisher] Exiting.\n\n");
   return 0;
}
Esempio n. 5
0
void DDSEntityManager::createPublisher()
{
    status = participant->get_default_publisher_qos(pub_qos);
    checkStatus(status, "DDS::DomainParticipant::get_default_publisher_qos");
    pub_qos.partition.name.length(1);
    pub_qos.partition.name[0] = partition;

    publisher = participant->create_publisher(pub_qos, NULL, STATUS_MASK_NONE);
    checkHandle(publisher.in(), "DDS::DomainParticipant::create_publisher");
}
Esempio n. 6
0
 Publisher(std::string topic_name, size_t queue_size,
           DDS::Publisher_var dds_publisher,
           DDS::Topic_var dds_topic,
           DDS::DataWriter_var dds_topic_datawriter)
 : topic_name_(topic_name), queue_size_(queue_size),
   dds_publisher_(dds_publisher), dds_topic_(dds_topic),
   dds_topic_datawriter_(dds_topic_datawriter)
 {
     this->data_writer_ = r::DDSMsgDataWriterType::_narrow(this->dds_topic_datawriter_.in());
     checkHandle(this->data_writer_, "DDSMsgDataWriter_t::_narrow");
 }
Esempio n. 7
0
void
MainWindow::backlightOnOffClicked(bool state)
{
	// Turn on/off the backlight of the entered key in the
	// backlight_number field. Use the Set Flash Freq to
	// control frequency of blink.

	//  Key Index for XK-24 (in decimal):
		//Bank 1
		//Columns-->
		//  0   8   16  24
		//  1   9   17  25
		//  2   10  18  26
		//  3   11  19  27
		//  4   12  20  28
		//  5   13  21  29

		//Bank 2
		//Columns-->
		//  32   40   48  56
		//  33   41   49  57
		//  34   42   50  58
		//  35   43   51  59
		//  36   44   52  60
		//  37   45   53  61

	if (!checkHandle())
		return;

	unsigned int result;
	unsigned char buffer[80];
	memset(buffer, 0, sizeof(buffer));
	buffer[1]=181; //0xb5
	bool ok;
	int key_id = backlight_number->text().toInt(&ok, 10);
	buffer[2] = key_id;

	if (state) {
		if (backlight_flash->isChecked()) {
			buffer[3] = 2; // 2 = flash
		}
		else {
			buffer[3] = 1;
		}
	}
	else
		buffer[3] = 0;

	result = WriteData(handle, buffer);

	if (result != 0) {
		QMessageBox::critical(this, "Write Error", "Unable to write to Device.");
	}
}
Esempio n. 8
0
void createPublisher()
{
   DDS_PublisherQos* publisherQos = DDS_PublisherQos__alloc();
   checkHandle(publisherQos, "DDS_PublisherQos__alloc");
   g_status = DDS_DomainParticipant_get_default_publisher_qos(g_domainParticipant, publisherQos);
   checkStatus(g_status, "DDS_DomainParticipant_get_default_publisher_qos");
   publisherQos->partition.name._length = 1;
   publisherQos->partition.name._maximum = 1;
   publisherQos->partition.name._buffer = DDS_StringSeq_allocbuf(1);
   checkHandle(publisherQos->partition.name._buffer, "DDS_StringSeq_allocbuf");
   publisherQos->partition.name._buffer[0] = DDS_string_alloc(strlen(g_partitionName));
   checkHandle(publisherQos->partition.name._buffer[0], "DDS_string_alloc");
   strcpy(publisherQos->partition.name._buffer[0], g_partitionName);

   /* Create a Publisher for the application. */
   g_Publisher = DDS_DomainParticipant_create_publisher(g_domainParticipant, publisherQos, NULL, DDS_ANY_STATUS);
   checkHandle(g_Publisher, "DDS_DomainParticipant_create_publisher");

   DDS_free(publisherQos);
}
Esempio n. 9
0
DDS_Publisher createPublisher(char* publisherName)
{
   DDS_Publisher publisher;
   DDS_PublisherQos* publisherQos = DDS_PublisherQos__alloc();
   checkHandle(publisherQos, "DDS_PublisherQos__alloc");
   g_status = DDS_DomainParticipant_get_default_publisher_qos(g_domainParticipant, publisherQos);
   checkStatus(g_status, "DDS_DomainParticipant_get_default_publisher_qos");
   publisherQos->partition.name._length = 1;
   publisherQos->partition.name._maximum = 1;
   publisherQos->partition.name._buffer = DDS_StringSeq_allocbuf(1);
   checkHandle(publisherQos->partition.name._buffer, "DDS_StringSeq_allocbuf");
   publisherQos->partition.name._buffer[0] = DDS_string_dup(g_partitionName);
   checkHandle(publisherQos->partition.name._buffer[0], "DDS_string_dup");

   /* Create a Publisher for the application. */
   publisher = DDS_DomainParticipant_create_publisher(g_domainParticipant, publisherQos, NULL, DDS_STATUS_MASK_NONE);
   checkHandle(publisher, "DDS_DomainParticipant_create_publisher");

   DDS_free(publisherQos);
   return publisher;
}
Esempio n. 10
0
void DDSEntityManager::createWriter()
{
    DataWriterQos dw_qos;
    status = publisher->get_default_datawriter_qos(dw_qos);
    checkStatus(status, "DDS::DomainParticipant::get_default_publisher_qos");
    status = publisher->copy_from_topic_qos(dw_qos, reliable_topic_qos);
    checkStatus(status, "DDS::Publisher::copy_from_topic_qos");
    dw_qos.writer_data_lifecycle.autodispose_unregistered_instances = true;
  writer = publisher->create_datawriter(topic.in(),
    dw_qos, NULL, STATUS_MASK_NONE);
  checkHandle(writer, "DDS::Publisher::create_datawriter");
}
Esempio n. 11
0
void createSubscriber()
{
   // Adapt the default SubscriberQos to read from the Partition with the given name.
   DDS_SubscriberQos* subscriberQos = DDS_SubscriberQos__alloc();
   checkHandle(subscriberQos, "DDS_SubscriberQos__alloc");
   g_status = DDS_DomainParticipant_get_default_subscriber_qos(g_domainParticipant, subscriberQos);
   checkStatus(g_status, "DDS_DomainParticipant_get_default_subscriber_qos");
   subscriberQos->partition.name._length = 1;
   subscriberQos->partition.name._maximum = 1;
   subscriberQos->partition.name._buffer = DDS_StringSeq_allocbuf(1);
   checkHandle(subscriberQos->partition.name._buffer, "DDS_StringSeq_allocbuf");
   subscriberQos->partition.name._buffer[0] = DDS_string_alloc(strlen(g_partitionName));
   checkHandle(subscriberQos->partition.name._buffer[0], "DDS_string_alloc");
   strcpy(subscriberQos->partition.name._buffer[0], g_partitionName);

   // Create a Subscriber for the MsgBoard application.
   g_Subscriber = DDS_DomainParticipant_create_subscriber(g_domainParticipant, subscriberQos, NULL, DDS_ANY_STATUS);
   checkHandle(g_Subscriber, "DDS_DomainParticipant_create_subscriber");

   DDS_free(subscriberQos);
}
Esempio n. 12
0
void DDSEntityManager::createReader()
{
  status = subscriber->get_default_datareader_qos(dr_qos);
  checkStatus(status, "DDS::Subscriber::get_default_datareader_qos");
  status = subscriber->copy_from_topic_qos(dr_qos, reliable_topic_qos);
  checkStatus(status, "DDS::Subscriber::copy_from_topic_qos");
  // DeadlineQoSPolicy : period used to trigger
  // dr_qos.deadline.period.nanosec = 0;
  // dr_qos.deadline.period.sec = 1;
  reader = subscriber->create_datareader(topic.in(),
  dr_qos, NULL, STATUS_MASK_NONE);
  checkHandle(reader, "DDS::Subscriber::create_datareader ()");
}
Esempio n. 13
0
void
MainWindow::joystickReflectorClicked()
{
	if (!checkHandle())
		return;

	joystick = !joystick;
	if (joystick)
		joystick_label->setText("Joystick On");
	else
		joystick_label->setText("Joystick Off");
	
}
Esempio n. 14
0
DDS_Subscriber createSubscriber()
{
   DDS_Subscriber subscriber;
   // Adapt the default SubscriberQos to read from the Partition with the given name.
   DDS_SubscriberQos* subscriberQos = DDS_SubscriberQos__alloc();
   checkHandle(subscriberQos, "DDS_SubscriberQos__alloc");
   g_status = DDS_DomainParticipant_get_default_subscriber_qos(g_domainParticipant, subscriberQos);
   checkStatus(g_status, "DDS_DomainParticipant_get_default_subscriber_qos");
   subscriberQos->partition.name._length = 1;
   subscriberQos->partition.name._maximum = 1;
   subscriberQos->partition.name._buffer = DDS_StringSeq_allocbuf(1);
   checkHandle(subscriberQos->partition.name._buffer, "DDS_StringSeq_allocbuf");
   subscriberQos->partition.name._buffer[0] = DDS_string_dup(g_partitionName);
   checkHandle(subscriberQos->partition.name._buffer[0], "DDS_string_dup");

   // Create a Subscriber for the MessageBoard application.
   subscriber = DDS_DomainParticipant_create_subscriber(g_domainParticipant, subscriberQos, NULL, DDS_STATUS_MASK_NONE);
   checkHandle(subscriber, "DDS_DomainParticipant_create_subscriber");

   DDS_free(subscriberQos);

   return subscriber;
}
Esempio n. 15
0
void DDSEntityManager::createWriter(bool autodispose_unregistered_instances)
{
  status = publisher->get_default_datawriter_qos(dw_qos);
  checkStatus(status, "DDS::DomainParticipant::get_default_publisher_qos");
  status = publisher->copy_from_topic_qos(dw_qos, reliable_topic_qos);
  checkStatus(status, "DDS::Publisher::copy_from_topic_qos");
  // Set autodispose to false so that you can start
  // the subscriber after the publisher
  dw_qos.writer_data_lifecycle.autodispose_unregistered_instances =
    autodispose_unregistered_instances;
  writer = publisher->create_datawriter(topic.in(), dw_qos, NULL,
    STATUS_MASK_NONE);
  checkHandle(writer, "DDS::Publisher::create_datawriter");
}
Esempio n. 16
0
DDS_Topic createTopic(const char *topicName, const char *typeName)
{
   DDS_Topic topic;
   const char* messageFirstPart;
   char* message;
   size_t messageFirstPartLength, topicNameLength;
   DDS_TopicQos* topicQos = DDS_TopicQos__alloc();
   checkHandle(topicQos, "DDS_TopicQos__alloc");
   g_status = DDS_DomainParticipant_get_default_topic_qos(g_domainParticipant, topicQos);
   checkStatus(g_status, "DDS_DomainParticipant_get_default_topic_qos");
   topicQos->reliability.kind = DDS_RELIABLE_RELIABILITY_QOS;
   topicQos->durability.kind = DDS_TRANSIENT_DURABILITY_QOS;

   // DeadlineQoSPolicy : period used to trigger the listener
   // (on_requested_deadline_missed)
   topicQos->deadline.period.nanosec = 0;
   topicQos->deadline.period.sec = 1;

   /* Use the changed policy when defining the Ownership topic */
   topic = DDS_DomainParticipant_create_topic(g_domainParticipant, topicName, typeName, topicQos, NULL, DDS_STATUS_MASK_NONE);
   checkHandle(topic, "DDS::DomainParticipant::create_topic ()");

   //Format error message
   messageFirstPart = "DDS_DomainParticipant_create_topic";
   messageFirstPartLength = strlen(messageFirstPart);
   topicNameLength = strlen(topicName);
   message = (char*) malloc(messageFirstPartLength + topicNameLength + 2);

   snprintf(message, messageFirstPartLength + topicNameLength + 1, "%s %s", messageFirstPart, topicName);
   checkHandle(topic, message);

   free(message);
   DDS_free(topicQos);

   return topic;
}
Esempio n. 17
0
void DDSEntityManager::createWriter()
{
    status = publisher->get_default_datawriter_qos(dw_qos);
    checkStatus(status, "DDS::DomainParticipant::get_default_publisher_qos");
    status = publisher->copy_from_topic_qos(dw_qos, topic_qos);
    checkStatus(status, "DDS::Publisher::copy_from_topic_qos");
    // Set autodispose to false otherwise the instances of the
    // topic will be suppressed from the persistence file when
    // the writer is stopped
    dw_qos.writer_data_lifecycle.autodispose_unregistered_instances =
        m_autodispose_unregistered_instances;
    writer = publisher->create_datawriter(topic.in(), dw_qos, NULL,
                                          STATUS_MASK_NONE);
    checkHandle(writer, "DDS::Publisher::create_datawriter");
}
Esempio n. 18
0
void DDSEntityManager::createTopic(char *topicName)
{
  status = participant->get_default_topic_qos(reliable_topic_qos);
  checkStatus(status, "DDS::DomainParticipant::get_default_topic_qos");
  reliable_topic_qos.reliability.kind = RELIABLE_RELIABILITY_QOS;
  reliable_topic_qos.durability.kind = TRANSIENT_DURABILITY_QOS;
  reliable_topic_qos.destination_order.kind = BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS;

  /* Make the tailored QoS the new default. */
  status = participant->set_default_topic_qos(reliable_topic_qos);
  checkStatus(status, "DDS::DomainParticipant::set_default_topic_qos");

  topic = participant->create_topic(topicName, typeName, reliable_topic_qos,
    NULL, STATUS_MASK_NONE);
  checkHandle(topic.in(), "DDS::DomainParticipant::create_topic ()");
}
Esempio n. 19
0
void DDSEntityManager::createTopic(char *topicName)
{
  status = participant->get_default_topic_qos(reliable_topic_qos);
  checkStatus(status, "DDS::DomainParticipant::get_default_topic_qos");
  reliable_topic_qos.reliability.kind = RELIABLE_RELIABILITY_QOS;
  reliable_topic_qos.durability.kind = TRANSIENT_DURABILITY_QOS;

  /* Make the tailored QoS the new default. */
  status = participant->set_default_topic_qos(reliable_topic_qos);
  checkStatus(status, "DDS::DomainParticipant::set_default_topic_qos");

  /* Use the changed policy when defining the HelloWorld topic */
  topic = participant->create_topic(topicName, typeName, reliable_topic_qos,
    NULL, STATUS_MASK_NONE);
  checkHandle(topic.in(), "DDS::DomainParticipant::create_topic ()");
}
Esempio n. 20
0
void DDSEntityManager::createReader()
{
    status = subscriber->get_default_datareader_qos(dr_qos);
    checkStatus(status, "DDS::Subscriber::get_default_datareader_qos");
    status = subscriber->copy_from_topic_qos(dr_qos, topic_qos);
    checkStatus(status, "DDS::Subscriber::copy_from_topic_qos");
    reader = subscriber->create_datareader(topic.in(), dr_qos, NULL,
                                           STATUS_MASK_NONE);
    checkHandle(reader, "DDS::Subscriber::create_datareader ()");
    // If the logic of your application requires it
    // wait (block) until all historical data are received or
    // until the timeout has elapsed
    DDS::Duration_t a_timeout;
    a_timeout.sec = 2;
    a_timeout.nanosec = 10000000;
    status = reader->wait_for_historical_data(a_timeout);
}
Esempio n. 21
0
void
MainWindow::mouseReflectorClicked()
{
	if (!checkHandle())
		return;

	// After turning mouseon=true, pressing 1st key will behave as left
	// mouse button only available in PID #1.
	if (!mouseon) {
		mouseon = true;
		mouse_label->setText("Mouse On");
	}
	else {
		mouseon = false;
		mouse_label->setText("Mouse Off");
	}
}
Esempio n. 22
0
void DDSEntityManager::createTopic(char *topicName)
{
    status = participant->get_default_topic_qos(topic_qos);
    checkStatus(status, "DDS::DomainParticipant::get_default_topic_qos");
    topic_qos.reliability.kind = RELIABLE_RELIABILITY_QOS;
    if (m_durability_kind.compare("transient") == 0)
        topic_qos.durability.kind = TRANSIENT_DURABILITY_QOS;
    else if (m_durability_kind.compare("persistent") == 0)
        topic_qos.durability.kind = PERSISTENT_DURABILITY_QOS;

    /* Make the tailored QoS the new default. */
    status = participant->set_default_topic_qos(topic_qos);
    checkStatus(status, "DDS::DomainParticipant::set_default_topic_qos");

    /* Use the changed policy when defining the topic */
    topic = participant->create_topic(topicName, typeName, topic_qos, NULL,
                                      STATUS_MASK_NONE);
    checkHandle(topic.in(), "DDS::DomainParticipant::create_topic ()");
}
Esempio n. 23
0
void
MainWindow::setLED(int number, int mode/*0=off,1=on,2=blink*/)
{
	if (!checkHandle())
		return;

	unsigned int result;
	unsigned char buffer[80];
	memset(buffer, 0, sizeof(buffer));
	buffer[1]=179; // 0xb3
	buffer[2]=number;  // 6 for green, 7 for red
	buffer[3]= mode; // 0=off, 1=on, 2=flash
	
	result = WriteData(handle, buffer);

	if (result != 0) {
		QMessageBox::critical(this, "Write Error", "Unable to write to Device.");
	}
}
Esempio n. 24
0
void
MainWindow::convertPID1Clicked()
{
	if (!checkHandle())
		return;

	unsigned int result;
	unsigned char buffer[80];
	memset(buffer, 0, sizeof(buffer));

	buffer[0]=0;
	buffer[1]=204;
	buffer[2]=2; //0=PID #2, 2=PID #1

	result = WriteData(handle, buffer);

	if (result != 0) {
		QMessageBox::critical(this, "Write Error", "Unable to write to Device.");
	}
}
Esempio n. 25
0
void
MainWindow::backlightToggle()
{
	if (!checkHandle())
		return;

	unsigned int result;
	unsigned char buffer[80];
	memset(buffer, 0, sizeof(buffer));

	//Toggle the backlights
	buffer[0]=0;
	buffer[1]=184;

	result = WriteData(handle, buffer);

	if (result != 0) {
		QMessageBox::critical(this, "Write Error", "Unable to write to Device.");
	}
}
Esempio n. 26
0
void DDSEntityManager::createTopic(char *topicName)
{
  status = participant->get_default_topic_qos(reliable_topic_qos);
  checkStatus(status, "DDS::DomainParticipant::get_default_topic_qos");
  reliable_topic_qos.reliability.kind = RELIABLE_RELIABILITY_QOS;
  reliable_topic_qos.durability.kind = TRANSIENT_DURABILITY_QOS;

  // DeadlineQoSPolicy : period used to trigger the listener
  // (on_requested_deadline_missed)
  reliable_topic_qos.deadline.period.nanosec = 0;
  reliable_topic_qos.deadline.period.sec = 1;

  /* Make the tailored QoS the new default. */
  status = participant->set_default_topic_qos(reliable_topic_qos);
  checkStatus(status, "DDS::DomainParticipant::set_default_topic_qos");

  /* Use the changed policy when defining the ListenerData topic */
  topic = participant->create_topic(topicName, typeName, reliable_topic_qos,
    NULL, STATUS_MASK_NONE);
  checkHandle(topic.in(), "DDS::DomainParticipant::create_topic ()");
}
Esempio n. 27
0
void
MainWindow::flashFrequencyChanged(const QString &str)
{
	if (!checkHandle())
		return;

	unsigned int result;
	bool ok;
	int freq = str.toInt(&ok, 10);
	
	if (ok) {
		//Set the frequency of the flashing, same one for LEDs and backlights
		unsigned char buffer[80];
		memset(buffer, 0, sizeof(buffer));
		buffer[1]= 180;
		buffer[2]= (char) freq;
		result = WriteData(handle, buffer);

		if (result != 0) {
			QMessageBox::critical(this, "Write Error", "Unable to write to Device.");
		}
	}
}
Esempio n. 28
0
void
MainWindow::backlightSetIntensity()
{
	// Sets the green and red backlighting intensity,
	// one value for all greens or reds

	if (!checkHandle())
		return;

	unsigned int result;
	unsigned char buffer[80];
	memset(buffer, 0, sizeof(buffer));

	buffer[0]=0;
	buffer[1]=187;
	buffer[2]=127; // 0-255 blue intensity
	buffer[3]=64;  // 0-255 red intensity
	
	result = WriteData(handle, buffer);

	if (result != 0) {
		QMessageBox::critical(this, "Write Error", "Unable to write to Device.");
	}
}
Esempio n. 29
0
void
MainWindow::backlightBank1AllClicked(bool)
{
	if (!checkHandle())
		return;

	unsigned int result;
	unsigned char buffer[80];
	memset(buffer, 0, sizeof(buffer));

	buffer[0]=0;
	buffer[1]=182;
	buffer[2]=0; //0 for blue, 1 for red
	if (backlight_bank1_all->isChecked())
		buffer[3] = 255;
	else
		buffer[3] = 0;

	result = WriteData(handle, buffer);

	if (result != 0) {
		QMessageBox::critical(this, "Write Error", "Unable to write to Device.");
	}
}
Esempio n. 30
0
void
MainWindow::backlightSave()
{
	// Write current state of backlighting to EEPROM.  
	// NOTE: Is it not recommended to do this frequently as there are a finite number of writes to the EEPROM allowed

	if (!checkHandle())
		return;

	unsigned int result;
	unsigned char buffer[80];
	memset(buffer, 0, sizeof(buffer));

	buffer[0]=0;
	buffer[1]=199;
	buffer[2]=1; // Anything other than 0 will save the Backlight
	             // state to eeprom, default is 0

	result = WriteData(handle, buffer);

	if (result != 0) {
		QMessageBox::critical(this, "Write Error", "Unable to write to Device.");
	}
}