Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Novice
1,142 Views

Trying to interface with the Galileo board from and ASP.NET button event

Hello,

I am new to IoT and I am able to interface with my Galileo board using PuTTY, but I would like to run the same command or activate the board similarly using an ASP.NET web app. How can I do this?

Thank you very much!

Sincerely,

Matt

13 Replies
Highlighted
Employee
5 Views

Hi Matt,

What is exactly what you want to do?

Do you want to interact with the board using the ASP.NET web app? Using the web app like it was Putty?

You can create a ssh connection to the board like: http://www.codeproject.com/Articles/11966/sharpSsh-A-Secure-Shell-SSH-library-for-NET sharpSsh - A Secure Shell (SSH) library for .NET - CodeProject

Regards,

Charlie

Highlighted
Novice
5 Views

Hello Charlie,

Thank you so much for taking the time.

I am currently firing my code on the board using Putty, so I am more familiar with those commands, but if their is a more "accepted" way to interface using ASP.NET, I would love to learn.

Do you have a suggestion outside of sharpSsh?

Thank you so much, again!

Sincerely,

Matt

0 Kudos
Highlighted
Employee
5 Views

Hi Matt,

If you want to interact with the Terminal Console of the board through your web app, I think the sharpSsh is a good approach or you could create another kind of client in order to receive and send data.

Is this what you want to do? Or do you want to run a specific command in the webapp to receive data? Or do you want to create some kind of interrupt in order to create a flag in your code?

Let us know more about what you are trying to do so we could share more suggestions, also have you though in another approach?

Regards,

Charlie

0 Kudos
Highlighted
Novice
5 Views

Hello Charlie,

So what my board is doing is taking some reads and putting it into a text file and sending to a remote server.

Currently this is initiated using Putty and the following command:

root@galileo:/www/pages# pwd

/www/pages

root@galileo:/www/pages# node main.js

Instead of using Putty to initiate the process, I would like to use a button event in my ASP C# code to fire the process.

Am I making sense?

Thank you so much for your help!!

Matt

 

0 Kudos
Highlighted
Employee
5 Views

Hi Matt,

I found in another forum some alternatives that could be interesting for you:

http://stackoverflow.com/questions/15136952/can-i-communicate-between-c-sharp-application-and-node-j... Can I communicate between Csharp application and NodeJS code

http://stackoverflow.com/questions/5628274/c-sharp-make-program-wait-for-button-to-be-pressed Csharp make program wait for button to be pressed

Also, I think edge.js may be useful for you http://tjanczuk.github.io/edge/ Edge.js.

And another way it could work is by using a system call on the event of the button in order to run node main.js. http://rosettacode.org/wiki/Execute_a_system_command# C Execute a system command -C#

Regards,

Charlie

0 Kudos
Highlighted
Employee
5 Views

Hi Matt,

Have you been able to work on this? I would like to know if you have decided which approach to use on your project and if you have some updates regarding your project.

Regards,

Charlie

Highlighted
Novice
5 Views

Hello Charlie!

Thank you so much for helping me.

I haven't had a chance yet to try your suggestion, but in the upcoming week I will have reserved time.

I will certainly update you.

I am ever grateful for your help.

Sincerely,

Matt

Highlighted
Employee
5 Views

Hi Matt,

Have you had time to run some tests?

I wouild like to know if you have new results.

Regards,

Charlie

0 Kudos
Highlighted
Novice
5 Views

Hello Charlie!

Thank you so much for checking in. Here is where I am: I am still unable to run commands directly on the board from my web app, but I am going another route, for now:

1. I have created a text file on the board: "intermediary.txt"

2. WebApp puts a value (using WinSCP): 1, 1 (meaning ready to read)

3. Board program keeps checking text file and when 1, 1 responds with sensor data

4. WebApp keeps watching text file for sensor data and pulls sensor data

5. repeat process

Obviously this is not efficient. I just wish there was a better way to interface with the board other than using WinSCP. I am trying Edge.js but am having difficulties. I am looking for an example for a simple light sensor read or even and RFID card read.

Anyway, thank you so much for your help!! Really appreciated!

Sincerely,

Matt

0 Kudos
Highlighted
Employee
5 Views

Hi Matt,

Thanks for telling us about the approach you are using for this.

If you are looking for examples on Javascript, I suggest you to look at here:

https://github.com/intel-iot-devkit/upm/tree/master/examples/javascript upm/examples/javascript at master · intel-iot-devkit/upm · GitHub

https://github.com/intel-iot-devkit/mraa/tree/master/examples/javascript mraa/examples/javascript at master · intel-iot-devkit/mraa · GitHub

Regards,

Charlie

0 Kudos
Highlighted
Novice
5 Views

Hello Charlie,

Thanks so much for your help!

I couldn't have done it without you!

I was able to figure out the edge.js assembly and make my calls direct to the board.

I will share my code in a few days, post testing.

Thanks you ever so much for taking time out of your day to help me.

Most sincerely,

Matt

0 Kudos
Highlighted
Employee
5 Views

Hi Matt,

I'm glad to know that you have good updates about this. If you have more questions don't hesitate to ask again.

We will be waiting for your tests.

Regards and have a nice week!

Carlos

0 Kudos
Highlighted
Novice
5 Views

Hello Charlie,

Following our testing, we were running into issues using Edge.js and Node.js as we have Linux on the Galileo board.

That being the case, we used WinSCP (https://winscp.net/eng/download.php WinSCP :: Official Site :: Download) to make a direct connection and just directly run our commands. Here is how we did it:

1. Declare the session:

SessionOptions sessionOptions = new SessionOptions

{

Protocol = Protocol.Scp,

HostName = "[host IP]",

UserName = "[host username]",

Password = "[host password]",

SshHostKeyFingerprint = "[ssh key]"

};

2. Implement the session:

using (Session session = new Session())

{

// Connect

session.Open(sessionOptions);

session.ExecuteCommand("cd").Check();

session.ExecuteCommand("cd /home/root/demo").Check();

//Run direct command

CommandExecutionResult result = session.ExecuteCommand("./read");

}

// return 0;

}

catch (Exception ex)

{

Console.WriteLine("Error: {0}", ex);

return "fail";

}

0 Kudos