import time import ctypes import dds from subjugator import qos d = dds.Participant() l = dds.Library('libdds_c.so') log_topic = d.get_topic('WorkerLog', l.WorkerLogMessage, qos.topic(d, qos.DEEP_PERSISTENT)) ws = dds.WaitSet() ws.attach(log_topic) while True: ws.wait(5) while True: try: msg = log_topic.take() print "received %r" % msg except dds.Error, e: if e.message == 'no data': break else: raise time.sleep(1)
from twisted.internet import reactor import dds import twistedds class TestProtocol(object): def connectionMade(self): print 'connection made!' def messageReceived(self, msg): print 'message received:', msg def connectionLost(self, reason): print 'connection lost! reason:', reason twistedds.connectDDS( dds.DDS().get_topic( 't2', dds.Library('./libddsmessages_c.so').HydrophoneMessage), TestProtocol()) reactor.run()
import sys import time import traceback import random import os import dds d = dds.Participant() l = dds.Library('libddsmessages_c.so') imu_topic = d.get_topic('IMU', l.IMUMessage) dvl_topic = d.get_topic('DVL', l.DVLMessage) depth_topic = d.get_topic('Depth', l.DepthMessage) while True: msg = dict( timestamp=int(time.time() * 1e9), flags=0, temp=25, supply=12, acceleration=[0, 0, 1], angular_rate=[0, 0, 0], mag_field=[0, 0, 0], ) print "Sending %r on IMU" % (msg, ) imu_topic.send(msg) msg = dict( timestamp=int(time.time() * 1e9), velocity=[0, 0, 0],
) parser.add_argument( metavar='TOPIC', nargs='*', help='record last message on this topic when triggered', dest='other_topics', ) args = parser.parse_args() if not args.trigger_topics: parser.error('need at least one trigger topic!') d = dds.Participant() message_lib = dds.Library( os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), '..', '..', 'build', 'Legacy', 'DDS', 'libddsmessages_c.so')) last_messages = {} last_header = None for name in args.trigger_topics: def callback(msg, _name=name): global last_header # erk last_messages[_name] = msg res = {} for topic, contents in last_messages.iteritems(): for member, value in contents.iteritems():