Skip to content

Instantly share code, notes, and snippets.

@sandorkan
Created November 7, 2012 09:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandorkan/4030299 to your computer and use it in GitHub Desktop.
Save sandorkan/4030299 to your computer and use it in GitHub Desktop.
Writing Data with DataWriter from HelloPublisher
System.out.println("Ready to write data.");
System.out.println("When the subscriber is ready, you can start writing.");
System.out.print("Press CTRL+C to terminate or enter an empty line to do a clean shutdown.\n\n");
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try
{
while (true) {
System.out.print("Please type a message> ");
String toWrite = reader.readLine();
dataWriter.write(toWrite, InstanceHandle_t.HANDLE_NIL);
if (toWrite.equals("")) break;
}
}
catch (IOException e)
{
e.printStackTrace();
} catch (RETCODE_ERROR e) {
// This exception can be thrown from DDS write operation
e.printStackTrace();
}
System.out.println("Exiting...");
// Deleting entities of DomainParticipant and DomainParticipant
participant.delete_contained_entities();
DomainParticipantFactory.get_instance().delete_participant(participant);
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment