REDHAWK UHD device usage - redhawksdr

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.
Open the component in your editor and navigate to the Implementations tab.
Right click on the implementation you would like to use for this connection (ex. python)
Select New → Uses Device
Generate (or enter) a unique DCE ID for this connection
Enter the type "usesDevice" although I'm not 100% sure if the type matters, I used usesDevice
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.
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
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.
Set the Value to the value you set it to ex XYZ123. Save and deploy the compnent
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>
</connections>
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.

Related

How do I change a variable value in Xilinx SDK debugger using Linux TCF Agent connected to our target?

I am connected to our target over ethernet using the Linux TCF agent to debug an application.
I've used a lot of debuggers over my 25 year career, but this is my first time using Eclipse/Linux/Xilinx environment. I can set break points. I can single step through the code. I can view variables. I can view memory. I can type a new value in the memory location, but the variable value doesn't change. I tried to click or double click the value in the Variables pane. I tried right clicking to see if it would give me an option to modify the value.
I'm not sure what good a debugging tool is if I can't change a variable value to alter the execution path of my software...
In addition to the hacky solution we came up in the comments, which is to get the address of a variable and then modify them through the mr command from the xsct console, the same console provide commands to properly get/set a local variable.
The syntax is the following:
locals [options] [variable-name [variable-value]]
And an example:
locals my_int_var 10
locals my_float_var 1.4

Make one time only activation code to python code, and make updates available?

I'm coding a program to do some action with webdriver and Autoit in python, I want to do two things before I start selling my code:
Add onetime activation code to my software on one PC, like to make the program works only on one pc.
Make my program able to receive updates from the internet once I add to the code some more features or correct some others.
is it possible only with Python? or what is the method statement to do it?
On client side you need use hard-disk serial or/and uuid of partition or Operational System timestamp + something to generate serial code .
On server side , you need a API to store hard disk serial to validate if this is a computer valid . And you client on load check if activaction is valid .
The second question i can't answer .
Regarding the second part of your question:
Create a text file with the latest version of your application and put it on your webserver e.g. http://download.example.com/example-app-version.txt to get and read its value later.
On your python code download and read the text (for Python 3+ use 'import urllib.request' and urllib.request.urlretrieve) when your app runs and compare it against the installed version (if statement).
E.g.
if latestVer > installedVer:
#update
else:
#application continues

PyUSB Barcode Scanner without Button by Honeywell

I have a Honeywell N5600 that I'm trying to use, but I don't get it to scan anything.
The device is recognized as /dev/hidraw1, but as it does not have any button to press, I cannot trigger the scan and thus, when I try to read from it, it just waits forever.
I started creating a python program, that seems to be able to communicate with it (different return values):
VENDOR_LEGO = 0x0c2e
PRODUCT_EV3 = 0x0967
device = usb.core.find(idVendor=VENDOR_LEGO, idProduct=PRODUCT_EV3)
device.detach_kernel_driver(0)
#"TRGMOD8." would - when scanned (which I cannot do, at this point) - activate a permanent scanning mode
device.ctrl_transfer(0x21, 0x9, wValue=0x200, wIndex=0x00, data_or_wLength='TRGMOD8.')
#8 is returned
device.ctrl_transfer(0x21, 0x9, wValue=0x200, wIndex=0x00, data_or_wLength='PAPSPC.')
#7 is returned
Unluckily the link given in this post is not reachable anymore. It seems like it would have solved my problem.
How can I activate the scanning?
The document on Honeywell N5600 is as follows.
N5600 OEM 2D Imager Data Sheet
N56XX Decoded Engine User's Guide
You need a Windows PC that can connect to the Internet, but there is a tool called EZConfig-Scanning that configures and maintains the scanner.
EZConfig Device Management Data Sheet
Perhaps the recognition device /dev/hidraw1 is probably because the scanner is set to USB HID Bar Code Scanner mode.
If you change the setting to USB Keyboard(PC/Mac), it is always readable and the barcode you read will be notified as keyboard input.
By changing the setting to USB Serial, reading start/stop can be controlled by SerialPort command transmission. The barcode read is notified by receiving data from SerialPort.

MAC OS X difference between "open APP.app" and "APP.app/content/MacOs/APP" shell scripts

Somehow I get a problem, if I call an application twice or several times but only one instance should be running (which is desired).
First some (probably necessary) background information:
working on MAC OS X El Capitan (10.11.6)
I've got an Application made by node.js, electron and build by "npm build -m" (let's call it APP.app)
I installed the application App.app into program-folder by opening the built dmg-file and move it into the program-folder
Then I start the application App.app by click on the App.app-icon in program-folder
The application starts with a visible Window and also has an hidden background process running
If I close the visible Window, the App.app-Icon remains in the dock (which is okay, since the background-process is still running)
Now (and this is the difference to the windows build and running in windows), if I click again on the App.app-Icon in the program-folder, I only get a focus on the already running application INSTEAD of opening the window and close the old application (I can see te focus switch/activation by the switching menu name beside the apple-logo on top of the screen; it becomes "App")
the closing of the previous running instance is defined in electron code in the init-method as follows:
var shouldQuit = app.makeSingleInstance(function (commandLine, workingDirectory) {
console.info('starting new instance');
initInternal(commandLine);
// Someone tried to run a second instance, we should focus our window.
var windows = options.closeWindowsOnRestart ? Browser.getAllWindows() : appWindows.slice();
windows.forEach(function (val, index) {
val.close();
});
readyCallback();
});
So, I did some homework and could figure out following:
my App.app-icon-click should look something like open /Applications/App.app
with this, I get the same problem as descriped above if I call it again (it only focusses the already opened window)
Now comes the funny part. If I open the application by calling directly /Applications/App.app/content/MacOS/App.app the old application-instance is closed and new App.app-application is started
I read through open-manual and could figure out, that if I use the -n-flag, the application starts succesful a new instance, too. (open /Applications/App.app -n)
I was wondering WHY? Do you have any clues? What is the difference between open and directly call of the application?
I suggest that the info.pklist in App.app-package is making the open-call different to the direct call of App.app.
BTW:
Unfortunately I already tried to add try-catch-blocks to debug the problem, but open does not give an output to terminal, it just opens the call whereas the direct call does not throw an error and everything works fine.
Anyway, I believe it's more a MAC OS X problem than an App.app-problem.
Hopefully there's somebody with same problems and a solution for me
Don't hesitate to ask for more details, if needed.
Short Version:
open starts the application with the LaunchService (and possible
added launch-parameters in info.plist)
whereas direct call of the
application just starts the application iself without any other
launch-options
*Long Version *
I read through the open manual (man open; Source: https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/open.1.html) and could figure out, that "the default application as determined via LaunchServices is used to open the specified files" if you click on an item.
So I read through the LaunchService-documentation and could figure out following:
"Opening Items by File-System Reference [...] default way:
If the designated item is an application: [...]
If the application is already running, it is activated (brought to the front of the screen) and sent an 'rapp' (“reopen
application”) Apple event."
(Source: https://developer.apple.com/library/content/documentation/Carbon/Conceptual/LaunchServicesConcepts/LSCTasks/LSCTasks.html#//apple_ref/doc/uid/TP30000999-CH203-TP9)
This reflects exactly my watching that if I click on the icon the second time, the app is just focussed/activated.
Thus I need the possibility to tell the application to open a new instance (oapp-event) instead of activating the already opened application (rapp-event)
Further reading lead me to following informations:
"Launch Options When opening an application (whether by itself or to
open one or more documents or URLs), you can specify various launch
options to control the manner in which it is launched or activated.
These can include: [...] Whether to launch a new instance of the
application, even if another instance is already running"
(Source: https://developer.apple.com/library/content/documentation/Carbon/Conceptual/LaunchServicesConcepts/LSCConcepts/LSCConcepts.html#//apple_ref/doc/uid/TP30000999-CH202-BABBJHID)
Thus I only need to add the "launch option" to define, that a new instance should be created instead of activating the existing one. But there's not written what the launch-option for it is and how they will be applied to the application (I suggest it belongs into info.plist-file).
So at least this is the answer to my original question, so I posted it here.
open - starts the application with the Launch-Service (and the defined option-parameters in info.plist)
whereas direct call of the application just starts the application iself without any other launch-options

Simple Component and Waveform Issue

I have created a simple component and waveform. All the component is suppose to do is output a line of text, specifically a value of a simple property (in this case a frequency value as double data type). I have the component placed in the waveform diagram. When I try to run the waveform from the domain I get this error:
Failed to create application: testWaveform_203_101836155 'load' failed for component:
'maxFreq' with component id: 'DCE:f5144a97-0978-4178-a718-
136c72d6cbla:testWaveform_203_101836155_1' with implementation id: 'DCE:afa7ddfd-bc2f-
422b-82e3-6876608dab26'; on device id: 'DCE:5fbc2a7a-3f0e-4d38-adb3-e35ecf19b6b8' in
waveform 'testWaveform_203_101836155_1' error occurred near line:1909 infile:
ApplicaitonFactory_impl.cpp;
IDL:CF/ApplicationFactory/CreateApplicationError:1.0
My Python component is extremely simple, all I did was autogenerate the code and add "print self.maxFreq" in the def process(self) function, where maxFreq is the frequency value of 2.45 GHz. What exactly is going wrong and how do I fix it?
Double check to make sure that your user has write permissions to $SDRROOT.
Then try running the Device Manager from a command line with a higher debug level to get more information on the source of the error:
$ nodeBooter -d /<nodePath>/DeviceManager.dcd.xml -debug 5
A few other questions:
Does this error cause either the Device Manager or the Domain Manager to terminate execution?
What devices are included in your current node?

Resources