How to pass node script into processing

I have a node script which sends a value to Samsung Artik Cloud.

Also have an Arduino project which send data through the serial port into processing, which I am able to store as an int variable.

Question is how can I pass this int value into the node script I created ?

P.S : tested the node script using command line and able to get the value in Artik cloud. I need a method to call command line inside processing.


Thanks and Regards
Sujith S A

1 Like

Thanks for the info. But could you help me with a specific command where I can invoke the command line. I tried something like this, but doesn’t seem to work :
import java.io.IOException;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.ExecuteException;

public class TestScript {

int iExitValue;
String sCommandString;

public void runScript(String command){
    sCommandString = command;
    CommandLine oCmdLine = CommandLine.parse(sCommandString);
    DefaultExecutor oDefaultExecutor = new DefaultExecutor();
    oDefaultExecutor.setExitValue(0);
    try {
        iExitValue = oDefaultExecutor.execute(oCmdLine);
    } catch (ExecuteException e) {
        System.err.println("Execution failed.");
        e.printStackTrace();
    } catch (IOException e) {
        System.err.println("permission denied.");
        e.printStackTrace();
    }
}

public void initScript(){
    TestScript testScript = new TestScript();
    testScript.runScript("node  myscript.js");
}

}

How often are you calling your nose script? I do not have experience but I can suggest you try using exec(). You could try searching previous entries in the old forum to see hot to get it going. Another suggestion is to send to loading command directly from Processing, that is, to interact with your cloud directly instead of using node. You could post more code & provide more details to get better answers.

Kf