mercredi 1 avril 2015

How to Launch Serproxy/Tinkeproxy correctly from an Air App?

I have an Adobe Air application that I have created to interface with a microcontroller (MSP430) and am using serproxy/tinkerproxy to facilitate communication between the two, much like the Arduino.


I was searching for a way to be able to launch serproxy on application start up. I came across this thread:


Launch EXE (Serproxy) with Adobe AIR


I've tried the solution found by Benjammin' and indead it only works on my machine. (ie creating a link with the cmd.exe and such appended to the beginning of the path). I've also tried creating a link with a relative path, and the link works when I click on it, but when it is launched from Flash or the full compiled app, the command window says that serproxy cannot be found. I noticed that when the link is activated in this way, cmd.exe launched from the Flash install directory. Same result if I were to use a batch file:



@START "" "serproxy.exe"


I skimmed through the code provided by TheDarkIn1978. Since I already have serproxy coded to my needs in AS3; this code is more than I need (also I'm only targeting Windows). None the less I've whittled down the code to what I think is neccessary to launch serproxy:



var windowsProxyFile:String = "tinkerproxy-2_0/serproxy.lnk";
var tinkerProxyApplication:File;
var tinkerProxyConfigurationFile:File;
var writeConfigStream:FileStream;
var tinkerProxyProcess:NativeProcess;

tinkerProxyApplication = File.applicationDirectory.resolvePath(windowsProxyFile);
tinkerProxyConfigurationFile = File.applicationStorageDirectory.resolvePath(windowsProxyFile.substring(0, windowsProxyFile.lastIndexOf(".exe")) + ".cfg");

//Start Tinker Proxy Application As Native Process
var tinkerProxyProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
tinkerProxyProcessStartupInfo.executable = tinkerProxyApplication;

var processArguments:Vector.<String> = new Vector.<String>();
processArguments[0] = tinkerProxyConfigurationFile.nativePath;
tinkerProxyProcessStartupInfo.arguments = processArguments;

tinkerProxyProcess = new NativeProcess();
tinkerProxyProcess.start(tinkerProxyProcessStartupInfo);


But I am back to square 1; code compiles and runs, but it seems that seproxy runs and then closes. TheDarkIn1978 made said serproxy would run in the background but I don't get that result.


So long story, short, what would be a solution to properly launch tinkerproxy? or how can I create a link with a proper relative path? Benjammin' suggested that AS3 could be used to create a link; how could this be accomplished?


Aucun commentaire:

Enregistrer un commentaire