Controlling RBPi from windows PC

9 posts
by Veristeron » Sat Nov 03, 2012 10:13 am
And i don't mean putty nor RDP. I want to write a windows program that'll alow me to do something on RBPi by simply clicking on buttons in that program.

Sth like: Click on "Restart" -> RBPi reboots, Click on "Print" with choosing file to send -> RBPi send task to writer with this file, etc. etc.

I think it'll be easy, but i've never program sth like that, and as for now have no idea how to do that. Searching on google gives tons of Putty and XMing combinations, nothing about programming. Have anybody write sth like that, and could describe how he send commands to RBPi at specific IP in owned subnet?
Posts: 2
Joined: Sat Nov 03, 2012 10:08 am
by ghans » Sat Nov 03, 2012 10:39 am
Err ,
perhaps write a server for the Pi and the client for Windows ?
Else you could still use SSH commands in the background , by using
a free SSH library for Windows and assigning one command to each button.

TIP: Python is also available for Windows.

• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere
Posts: 3917
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany
by Burngate » Sat Nov 03, 2012 11:42 am
I've never tried Windows - Linux, but I did something similar between several RISC OS machines over a network. Similar principles could be used again.

Server machines each had a Ramdisc shared. Client machine dumped one or more files into appropriate server Ramdisc, including one small one containing just date/time
Server monitored date/time file on Ramdisc. If the date/time is new, action the other files.
Files could also be kept on client if more than one server needs the same file, but when the network dies (or the client crashes) the servers wouldn't have access

The server has to boot up with a default set of files assuming the client doesn't yet exist. The default set can be updated so that a reboot causes it to start up where it left off without client intervention

On the client, if a server Ramdisc can't be found, that one's crashed so try another. If none can be found, flash lights / sound sirens / otherwise complain bitterly
User avatar
Posts: 2337
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK
by MrBunsy » Sat Nov 03, 2012 11:49 am
Java or Python (or anything else platform independent) and sockets would do what you want fairly easily. Simple client-server socket, write your own protocol and then make your server side of the application do whatever you want.
User avatar
Posts: 179
Joined: Mon Feb 20, 2012 1:48 pm
Location: Southampton, UK
by Joe Schmoe » Sat Nov 03, 2012 12:51 pm
(As others have noted...) The usual method is to setup a server on the server (I.e., Pi) end which waits for requests from a client. When I do this sort of thing, the server (Unix) is usually written in either GAWK (which has TCPIP hooks now) or C and the client (WIndows) is written in WinBatch.

But, it is also true that a lot can be done by leveraging ssh, without writing any new code.

P.S. And using "plink" (the command line version of PUtty) on the Windows side.
Never answer the question you are asked. Rather, answer the question you wish you had been asked.

- Robert S. McNamara - quoted in "Fog of War" -
Posts: 2257
Joined: Sun Jan 15, 2012 1:11 pm
by BlackJack » Sat Nov 03, 2012 3:45 pm
Instead of using raw sockets and inventing an own protocol I would use JSON-RPC or XML-RPC. Maybe even without a dedicated client for Windows but a web application running on the Raspi.

I would not bother to implement something for printing. Setting up CUPS is more flexible and you can use the printer from any Windows application then.
Code: Select all
while not self.asleep():
    sheep += 1
Posts: 288
Joined: Sat Aug 04, 2012 8:28 am
by croston » Sat Nov 03, 2012 3:52 pm
Python has XMLRPC built into the standard library.
User avatar
Posts: 420
Joined: Sat Nov 26, 2011 12:33 pm
Location: Blackpool
by Veristeron » Sat Nov 03, 2012 7:00 pm
I've analyzed whole thing, and i'm thinking about setting apache which has sudo rights and write simple api in PHP to catch command from adress. Then as body of site returning answer from terminal.

Then, no matter if i would decide to controll it from site, or sth compiled it would be as easy as changing adresses. What do you think about this way?

PS. I don't know why, but i'm kinda afraid of python. As for java, I think apache will take less memory - if not apache it can be sth even smaller. SSH Libraries won't go, as I want one of the controll apps be windows 8 new interface app. There are still no .NET Core SSH libraries.
Posts: 2
Joined: Sat Nov 03, 2012 10:08 am
by kimwatson » Mon Nov 12, 2012 3:42 pm
Another option (off the top of my head). Setup Node.js on the RP and Windows. It's a simple process, and if you are familiar with Javascript - you'll be set to make the most of it. There's heaps of good libraries. WS / / Binary.js ... things like this (all on github).

You can then use websockets to communicate. It's straight forward. You could even use a webpage instead of native application to drive your needs.

Depends where your developmental strengths lay.

Otherwise, there's / (using) boost (asio). For a straight forward C++ websocket crossplatform approach. Both work with the RP from my understanding.
Posts: 4
Joined: Fri Aug 17, 2012 3:27 pm
Location: Bordeaux, France