Octave runs but graph not displayed - octave

num=[1];
den=[1 3 1];
G=tf(num,den);
H=1;
T=feedback(G,H);
step(T);
hold on;
Kp=23;
Ki=0;
Kd=0;
C=pid(Kp,Ki,Kd);
T=feedback(C*G,H);
step(T);
When run this script nothing happen in Octave but works fine in octave-online.net
online octave
Octave Windows

I will put a proper answer here for future users, even though OP has already solved their problem from the comments.
octave-online.net is an excellent cloud service providing an instance of octave on the cloud.
Contrary to a typical installation of octave on linux or windows, the octave-online client autoloads some of the more popular packages, one of which is control.
You can confirm this by typing pkg list in the octave-online console.
In your normal linux / windows installation however, this needs to be loaded explicitly before use, e.g. in the case of the control package, by doing pkg load control.
Your code uses the functions feedback and pid, both of which rely on the control package, therefore in your windows instance, your code failed, because you tried to use these functions without loading the package first.
Presumably there was also an error in your terminal informing you of this fact, that you may have missed.

Related

If I make a sikuli script in Windows, will the same script work in Linux?

I am currently looking for a tool to test a a website and Sikuli seems perfect. However, my company uses both Windows and Linux, and I'd like our scripts to be transferable.
Will it work or are Windows scripts for Windows and Linux scripts for Linux?
It seems like Sikuli can be run from the command line, perhaps I can run the same script on both the Linux and Windows Computers?
There is no technical reason why a Sikuli script won't run under both operating systems (jython has the same syntax on both platforms). The biggest technical issue faced is that the screenshots may not match between Windows and Linux.
This thread discusses how to setup two images pools, one for each OS.
Creating Sikuli scipts directly in java might ease the cross platform issues. But you will still have the images looking slightly different issue. File directories are handled well accros OS in java though.
there are two main points to be concerned of:
Images: Even if the application looks the same in both the systems the ways to launch it are different. In the worst case one needs two complete sets of images.
Paths: In Windows and Linux paths are different. Different slashes, different lengths of the whole paths and components, different set of allowed symbols in the naming. Windows paths are not case sensitive by default.
There are some points to use the same script still with set of OS specific libraries.
- The more common logic in applications the more reusable code.
- The policy "changing something are must for both platforms". is easy to follow.
So the answer for your question is:
Specially prepared script will work on both the platforms

How to detect Flash runtime errors?

I'm developing an AS3 application with the commandline tools from the Flex SDK. My workflow is:
write code
compile with mxmlc
run the SWF file in favorite webbrowser
repeat
The second step catches compile-time errors, but what about run-time errors and warnings? And trace() output? How can I see that?
I'm not using any IDE with debugging capabilities.
Get the debug version of the Flash player and Firebug for Firefox, then you can see the traces and errors in the console.
When a run-time error occurs that isn't caught by an exception handler you will get a popup telling you about the error.
Why not get http://www.flashdevelop.org/? It's free and it has debugging, profiling and all other goodies you can expect from an IDE.
Although the Flash debugger is a pretty good choice. I would personally suggest Monster Debugger. It is a great debugger with a very intuitive user interface and it has a plethora of features that make debugging extremely easy.
Flash player debugger writes the output of trace() to the flashlog.txt file. Its location is hardcoded and is different on different systems. On Linux it is in ~/.macromedia/Flash_Player/Logs/flashlog.txt. In order to have The debugger to actually write into that file, you need yet another file, mm.cfg, it's location and name are again hardcoded. It should be in ~/mm.cfg. It may contain many different options, but the one you are interested in is ErrorReportingEnable=1.
You may then $ tail -f ~/.macromedia/Flash_Player/Logs/flashlog.txt to see the progress as the file is been written to.
Note that the directory and the file must be writable by the user running the player. Flash player will not issue any warnings if that is not the case, and will fail silently.
Also note that if you are happened to be on Linux, then there isn't a 64-bit version of a debugger player... However, the player runs fairly well under Wine, the Windows version that is.
You may debug using commandline debugger found in SDK. it's called fdb (fdb.exe or in Apache Flex fdb.bat on Windows). It has similar to gdb interface, can do breakpoints, some runtime code evaluation, disassemble functions, look up stack frames and their variables and most of the other stuff you'd expect a debugger to do. I'm usually running it from Emacs, but I would imagine that running it from Vi[m] or whatever editor you are using shouldn't be a problem...
If you were using Emacs, it is actually possible to hook up Flymake to a part of the SDK that does syntax checking while you type. You can find more info on how to do that here: http://www.flashdevelop.org/community/viewtopic.php?f=13&t=9238 (thanks Philippe).

Using stl in an Android adb shell native program

I'm trying to port a C++ utility program that I want to be run from the Android ADB shell.
For that, I'm using the Android NDK's make-standalone-toolchain.sh script, and compiling my program with it.
Unfortunately, when I try to run it, I get this error:
reloc_library[1315]: 16304 cannot locate '_ZNKSs5c_strEv'...
CANNOT LINK EXECUTABLE
After some research, I saw that this means that the c_str function doesn't exist in libstdc++.so in the NDK. I also couldn't find the symbol in stlport.so either, and actually only found it in the ./sources/cxx-stl/gnu-libstdc++/libs/ version of the C++ libraries. These libraries are not included in the standalone toolchain I made, and I also couldn't find them on the device (the device is running Honeycomb).
The text in the NDK clearly states that there's support for the entire STL when I use stlport. Is this something that is only true in Ice Cream Sandwich? The libstlport.so or in libsupc++.so on the device and in the NDK didn't have any signature like the one that wasn't found.
So my question has two parts:
Is there something I'm missing in the build process/Android setup? Can I set up things differently so that the program will compile without needing the gnu-libstc++, or at least fail with a compilation/link error instead of failing to load on the device?
If linking with gnu-libstc++ is the only way, how can I do that? I think I can manage statically link to it but I'd rather not.
How can I add the gnu-libstdc++ version to my
If someone else is looking for a solution, I ended up adding a dependency using the -l switch on libgnustl_shared.so. You can find it inside the NDK at
sources/cxx-stl/gnu-libstdc++/libs/&ltarchitecture&gt/
I then pushed this .so together with the program to the device, and made a script that adds the current directory to LD_LIBRARY_PATH. It seems similar to what the NDK does when you use the make scripts to create a program that depends on gnustl.

How to preserve build environment during product lifecycle

What are best practices in recording build/test machine(s) setup during the life time of a project? If you need to provide a patch for previous version of your product, you likely need to reload the same compiler and support tools to re-issue the patched release. What and how do you record? The obvious things are:the OS version and patch level, compiler/IDE version and patch level 3rd party tools/libraries.
My first thought is to keep a log file of all the requirements. This log file would go into your VCS.
VMWare Virtualization(or other similar products) are ideal for this type of thing. Build an entire development/build/ or test environment, and leave it setup just for that purpose. You can take the image off-line, back it up to a DVD and simply turn it back on when you need it.
I'm using maven for java with the enforcerer plugin so all of these things are stored in my project object model, even the version of maven itself which is required. As long as I manage to get the proper version from version control I'm home free.
3rd party tools and libraries go in version control along with everything else; we have a libs tree that goes under our VCS trunk right next to our app tree, so it gets included with any branches or tags that we create. The one wrinkle I haven't yet solved is Windows tools and libraries that require their own installers instead of running out of whatever directory VCS gives them.
For OS and compiler, I'd recommend creating a VM for each release if you can't install multiple compiler versions in parallel. Then your project wiki can document which VM and which compiler version to use for a given build. This isn't automatic like your log file would be, but it provides a ready-to-go environment (instead of potentially having to reinstall a machine to match your log file). Some projects check their entire compiler into version control, but this seems overkill to me (and doesn't play well with IDEs and compilers that need their own installers).
We don't track patch levels for the OS and compiler. I realize that it's possible that a patch would break or change something, but the chance seems so low that the cost-benefit ratio just isn't there.

How should I implement an auto-updater?

Many programs include an auto-updater, where the program occasionally looks online for updates, and then downloads and applies any updates that are found. Program bugs are fixed, supporting files are modified, and things are (usually) made better.
Unfortunately no matter how hard I look, I can't find information on this process anywhere. It seems like the auto-updaters that have been implemented have either been proprietary or not considered important.
It seems fairly easy to implement the system that looks for updates on a network and downloads them if they are available. That part of the auto-updater will change significantly from implementation to implementation. The question is what are the different approaches of applying patches. Just downloading files and replacing old ones with new ones, running a migration script that was downloaded, monkey patching parts of the system, etc.? Concepts are preferred, but examples in Java, C, Python, Ruby, Lisp, etc. would be appreciated.
I think that "language agnostic" is going to be a limiting factor here. Applications come in so many shapes and sizes that there is no one-size-fits-all answer. I have implemented several auto-updaters in several languages, and no two were similar.
The most general philosophy is that the application checks with some home location (web address, web query, corporate network location, etc.) to either ask if it's version is current, or ask what the most current version is. If the answer calls for an update, that process will be different for each situation.
A popular alternative is to invite the home location to run a script when the application is initiated. The script can check the version, download updates if necessary, and ask for usage feedback, for example.
We can probably help better if you narrow the parameters.
UPDATE: The approach to "patching" also depends on the nature of the application, and there's a very wide diversity here. If you have a single executable file, for instance, then it's probably most practical to replace the executable. If your application has many files, you should look for ways to minimize the number of files replaced. If your application is highly customized or parameterized, you should strive to minimize the re-tailoring effort. If your application employs interpreted code (such as an Excel VBA application or MS Access MDB application), then you may be able to replace parts of the code. In a Java application you may only need to replace a JAR file, or even a subset of the JAR contents. You'll also need to have a way to recognize the current client version, and update it appropriately. I could go on and on, but I hope you see my point about diversity. This is one of those many times when the best answer usually starts with "Well, it depends ...!" That's why so many answers include "Please narrow the parameters."
Be sure to also consider the security implications of sucking down information about the update, as well as the update binaries themselves.
Do you trust the source of the download? You maybe phoning home to got your update, but what if there is a man in the middle who redirects to a malicious server. An HTTPS or similar secure connection will help, but double checking the bits that you eventually download by using a digital signature check is recommended.
First you need a file on your application home web site with the latest version.
The best way I think to have special SQL table for this task and populate it automatically after publishing new version / nightly build completion.
Your application creates new thread which requests built-in http link with version and compares in with current. In .NET use can use code like this:
Version GetLatestVersion() {
HttpWebRequestrequest = (HttpWebRequest)WebRequest.Create(new Uri(new Uri(http://example.net), "version.txt));
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (request.HaveResponse)
{
StreamReader stream = new StreamReader(response.GetResponseStream(), Encoding.Default);
return new Version(stream.ReadLine());
}
else
{
return null;
}
}
Version latest = GetLatestVersion();
Version current = new Version(Application.ProductVersion);
if (current < latest)
{
// you need an update
}
else
{
// you are up-to-date
}
In this example, version.php in only one plain string like 1.0.1.0.
Another tip I can give - how to download an update.
I like very much next idea: in the resources of your application there is a string of CLR-code which you compile on-the-fly (using CodeDom) to a temporary folder, main application calls it and goes to close. Updater reads arguments, settings or registry and downloads new modules. And calls main application which deletes all temporary files. Done!
(But everything here is about .NET)
The simplest solutions (used by many programs) is running the uninstaller for the previous version and the running the installer for the new one (optionally skipping questions which the user has already answered, like the EULA). The only catch is that the new version must be able to read the configuration options from the old version.
Also, on Windows you can't delete an executable file which is in use, so you probably will want to drop a small executable in Temp folder, which runs the whole process and then delete it at the end from the instance of the new version which got launched (or just register it to be deleted at the next reboot).
Because auto updating is a common scenario, most languages have at least one package available to support this. (Below I list some of the available packages)
One of the really nice idea's is the ClickOnce distribution for .NET, it's an installer which sandboxes your application and installs in the user context, so no administrator rights required. You can configure the ClickOnce in your publish to check for updates each application start.
Java has Java Web Start which offers the same kind of functionality for java applets.
Delphi has numerous articles about auto-updating, Torry has a list of WebUpdate components, for instance GoUpdater seems to have a very wide range of functionality.
They all use a website/network share to check for a new version and than retrieve either a patch or a complete install file and run it. So you should try to find a nice package for your application, to save you the hassle of developing and maintaining your own solution.
The simplest approach would be to have your program query a server (website) to see if there is an update. If there is an update you could display a message to the user that prompts them to download a newer version and provides a link.
An alternative and more complex solution would be to create a small windows service (or unix daemon) that checks periodically to see if there are updates, this service can download the update and launch the installer.
The general architecture is that you have a central server that you control that knows the latest version and where to get it. Then the programs query the server. I am not going to include sample code because it is highly defendant on the server and the format you choose. It is not terrible difficult though.
This is not so much a complete answer, but rather one example of auto-updating mechanism I implemented recently. The situation is a little different from the tradition Firefox-type of user application, since it was an internal tool used at work.
Basically, it's a little script that manages a queue of Subversion branches to be built and packaged in an installer. It reads a little file, where the names of the branches are written, takes the first one, re-writes it at the end of the file, and launches the build process, which involves calling a bunch of scripts. The configuration for each branch to build is written in a .INI file, stored in a Subversion repository along with the tool itself.
Because this tool runs on several computers, I wanted a way to update it automatically on all machines as soon as I made a change either to the tool itself, or to the configuration scripts.
The way I implemented it was simple: when I launch the tool, it becomes an "outer shell". This outer shell does 2 very simple things:
svn update on itself and on the configuration files
launch itself again, this time as the "inner shell", the one that actually handles one configuration (and then exits again).
This very simple update-myself-in-a-loop system has served us very well for a few months now. It's very elegant, because it is self-contained: the auto-updater is the program itself. Because "outer shell" (the auto-updater part) is so simple, it doesn't matter that it does not benefit from the updates as the "inner shell" (which gets executed from the updated source file every time).
One thing that hasn't really been mentioned is that you should seriously consider that the user running your program might not actually have sufficient privileges to upgrade it. This should be pretty common at least for business users, probably less so for home users.
I'm always working with a (self-imposed) limited account for security reasons and it always pisses me off that most auto-updaters simply assume that I'm running as admin and then after downloading just fail and offer no other way of performing the update other than actually closing the program and running it again in an administrative context. Most do not even cache the downloaded update and have to do it all over again.
It'd be much better if the auto-updater would simply prompt for admin credentials when needed and get on with it.
I'm going to assume answer for Windows.
This way seems to work well.
In the installer do:
1. Create a manual-start service that runs as LocalSystem that when started does the update then stops.
2. Change the service permissions so all users can start the service (if all users should be able to update w/o admin rights).
3. Change the main program to check for updates when started using a simple mechanism. If it detects an update, prompt if the user wants to apply it.
4. If user accepts the update, start the service.
If the architecture allows for it, create a way to monitor the update as it is running.
In a Java-Webstart setting you start a JNLP file which then triggers the download of the Jar files needed to run the application. Everytime webstart checks if there are newer versions of the Jars and would download them replacing the locally cached ones. With a tool named jardiff you will create only diffs towards the newer jars and distribute these via the server (e.g. only get an update).
Pros:
always up to date
Cons:
you need an application server (tomcat, JBoss) in order to distribute the files
you need an internet connection in order to get the application
Reading Carl Seleborgs answer gave me some ideas how a generic code-repository could be useful.
svn comes with a tool called svnsync, which sort of behaves like an svn export but keeps track of the actual revision your export is at.
Someone could utilize this system in order to only fetch the changed files from the users actual revision.
In actuality, you will have a repository with the binaries compiled, and running svnsync will only fetch the binaries that has been modified. It might also be able to merge local changes to text-based configuration files with new configuration-options.
The function of installing a patch to a program is basically one of the basic functions of an installer. Installer software is documented in numerous places but usually on a per-installer basis: There the Microsoft Installer (with Install Shield Extensions), Ruby gems, Java .jar files, the various Linux package manager systems (RPM, Apt-get)and others.
These are all complex systems which solve the problem of patching program in general but for slightly different systems. To decide what is best for you, consider which of these system your application most resembles. Rolling your own is fine but looking at these systems is a place to start.
You can write an internal module of your application to do updates. You can write an external mini application to do updates.
Also look at .NET on-the-fly compilation technology, it makes possible to create such mini application on-the-fly on demand. For example, http://fly.sf.net/
You can use my solution (part of the Target Eye project).
http://www.codeproject.com/Articles/310530/Target-Eye-Revealed-part-Target-Eyes-Unique-Auto
If your software is open sourced, and target Linux or developers. It is interesting to install your software as a git repo. And having it pull the stable branch occasionally or everytime when it is launched.
This is particular easy when your application is managed via npm, sbt, mavan, stack, elm-package or alike.
After hours of searching some working solution for this problem I've finally implemented auto update mechanism for python script that works on Linux and Windows.
In short - the script before running actual work checks for update on S3 and if it's available downloads it, unzips, creates or updates the symlink (or junction on Windows) and re-runs the script with already the new version with original arguments.
The full source code and the explanation can be found here.
If you are searching for an cross-platform software update solution, take a look at www.updatenode.com
Some highlights:
free for Open Source projects
cross-platform & Open Source update client tool
localized already for the most important languages
easy to integrate and easy to handle
cloud based management platform to define and manage updates
provides additionally support for displaying messages (inform about new events, products, etc.)
web interface is open (you can create your own client using the service)
many usage statistics, as used operating systems, geo location, version usage, etc.
Android API for mobile App updates
Just try it.
BTW, I am part of the dev team for the open source client. :)