I have successfully installed the UHD device along side REDHAWK version 1.8.3. It isn't obvious to me how to connect a component in a waveform to a device being managed by a device manager. I am also unclear on the interplay between the IDL interfaces and the data ports on the USRP device.
I was unable to find a trivial example to send and receive waveform that utilizes the USRP device (e.g. a signal generator component sending a sine wave to the USRP). Does anyone have experience with this or any suggestions?
One way to connect a Component to a Device in a running environment is through the REDHAWK python module. It is able to attach to a running domain, query any launched Applications and connect Ports from Components to Devices. The following is an example python script (Note the ports must both be the same type in order for the connection to succeed):
from ossie.utils import redhawk
from ossie.cf import CF
# Connect to the running domain
domain = redhawk.attach("REDHAWK_DEV")
# Gets a reference to the running application
for app in domain.apps:
# Find desired application
if app.name == 'desired_name':
application = app
# Gets the component from the application
for comp in application.comps:
# Find desired component
if comp.name == 'desired_name':
component = comp
# Gets the device to connect
for devMgr in domain.devMgrs:
for dev in devMgr.devs:
# Find desired device
if dev.name = 'desired_name':
device = dev
# Gets the references to the input and output ports
comp_port = component.getPort('port_name')._narrow(CF.Port)
dev_port = device.getPort('port_name')
# Makes the actual connection
comp_port.connectPort(dev_port, 'ConnectionID')
# Make sure device is started
device.start()
# Start application
application.start()
# To disconnect:
# Stop device and application
application.stop()
device.stop()
comp_port.disconnectPort('ConnectionID')
There are multiple ways to accomplish this depending on your situations. Here are a few:
A.) Problem: You are debugging an issue in the IDE and quickly want to connect a device port to a component port
Solution: With the component and device both running in either domain or in the sandbox, expand the component and device in your SCA Explorer view to expose the ports. Click on the output port then ctrl+click the input port you would like to connect to. With both ports highlighted you can now right click and select Connect.
B.) Problem: You need a generic way of connecting a components input port, regardless of implementation language, to a particular type of devices output port, regardless of language implementation.
Solution: This is a multi-step process and is not that intuitive at first. I recommend you look at the SCA spec page D-43 for additional detail for step 10 and beyond below.
1.) Open the component in your editor and navigate to the Implementations tab.
2.) Right click on the implementation you would like to use for this connection (ex. python)
3.) Select New->Uses Device
4.) Generate (or enter) a unique DCE ID for this connection
5.) Enter the type "usesDevice" although I'm not 100% sure if the type matters, I used usesDevice
6.) Right click on the Uses Device select new Property Ref. You will not be directly connecting component X to device Y. Instead you are connecting component X to a device which meets the property restrictions set here. ie. model, type, etc.
7.) In your device, in the properties tab, set a property like device_kind or device_model's Name field to something you want to match to. We'll say XYZ123 for an example. Save and deploy this to the SDR ROOT
8.) Back in the component where we were setting the property Ref, select browse and select the property on the device you just set as your matching property.
9.) Set the Value to the value you set it to ex XYZ123. Save and deploy the compnent
10.) Now in your waveform, you'll need to hand edit the SAD file and add something like this, where [[TEXT]] indicates something for you to change:
<connections>
<connectinterface id="[[Connection_Name]]">
<usesport>
<usesidentifier>[[Output Port Name]]</usesidentifier>
<deviceusedbythiscomponentref refid="[[DCE matching the componentinstantiationID]]" usesrefid="[[DCE matching the generated ID from step 4]]"/>
</usesport>
<providesport>
<providesidentifier>[[Input Port Name]]</providesidentifier>
<componentinstantiationref refid="[[DCE matching the componentinstantiationID]]"/>
</providesport>
</connectinterface>
I recommend you add a dummy component to your SAD editor and connect dummy component to the real compnent just so your SAD file is populated with the connectinterface block and you can see an example of a connection.
After making those changes, the IDE may tell you that an error exists in your SAD file, save anyway, close the SAD editor and reopen. If no error is displayed then your syntax is fine. Deploy the waveform and launch as usual.
C.) Problem: You want to connect to a device via a python script outside of REDHAWK, a python service within REDHAWK, or through a python component in your waveform.
Solution: See Adam's solution.
来源:https://stackoverflow.com/questions/16570767/redhawk-uhd-device-usage