News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: How do you send commands to a raspberry pi via windows forms program?  (Read 2629 times)

konarktriv7

  • Newbie
  • *
  • Posts: 1
    • View Profile
I do not want to just remotely control a pi through vnc, I would like to have a windows forms program open up on my pc that will send commands over my wifi network to the gpio pins. Does anyone know how to do this?

FAST6191

  • Hero Member
  • *****
  • Posts: 2864
    • View Profile
I don't think that something most people are familiar with around here, certainly have never seen anybody to my knowledge so much as mention windows forms.

Anyway looks like a search for "Windows forms telnet" has something useful it seems so it looks like you don't have to do a whole network stack. Hopefully it will also dodge any issues with modern windows' network options being awful for any kind of exotic network use.

On the pi side it looks like there are several nice ports of netcat (if you are not familiar with it then it is an ultra basic way to send and receive data from a network, often used with embedded devices or things that don't need robust network protocols) even if you didn't want to set up a telnet server on the pi. Chaining that to something which will tickle the IO pins (there is probably even something you can do with python) should not be too hard.
https://learn.adafruit.com/raspipe-a-raspberry-pi-pipeline-viewer-part-2/networked-pipes-with-netcat
https://www.raspberrypi.org/documentation/usage/gpio/python/README.md

Valendian

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
I did this before years ago. The WiFi connection required a shield for the PI. On the PC I just used a browser. I had a web server on the PI that served back plain old html. Just a lightweight DIY server written in pure C that used the berkley socket API. I toggled the GPIO's using something like this from the server
Code: [Select]
system("echo 1 > /sys/class/gpio/gpio18/value");


It's relatively straightforward to communicate over UART if that's an option. The PC will see a UART connection (COMX on windows). You can open the COM port from C# using the SerialPort class inside the System.IO.Ports namespace. On the RaspberyPI it will show up as /dev/ttyS0 or /dev/serial0.