eqooo
Posts: 19
Joined: Tue May 21, 2013 6:59 am

Serial Communication with Ethernet

Fri Jun 28, 2013 2:25 pm

Hi everyone,
I want to use ethernet communication on my desktop with my pi. I want to learn how to do "ethernet to ethernet communication" . How can I send a data from pc to RPi ? I'm using Debian for RPi.
Thanks.

User avatar
joan
Posts: 14936
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Serial Communication with Ethernet

Fri Jun 28, 2013 2:30 pm

In what sense do you want to send data?

You can use ftp from the command line.

You can use sockets from C.

eqooo
Posts: 19
Joined: Tue May 21, 2013 6:59 am

Re: Serial Communication with Ethernet

Sat Jun 29, 2013 7:07 am

I want to create GUI with C# on PC. For example; LED ON and LED OFF butons are on GUI. I want to control leds with GUI applications so I want to try ethernet cable to communicate.

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Serial Communication with Ethernet

Sat Jun 29, 2013 7:15 am

Use Internet Connection Sharing or Bridging under Windows.
On Ubuntu , this only three clicks and works perfectly without
changing anything on the Pi.
After that , you can use HTTP or whatever comes to your mind
over the direct connection.
I do so myself , mostly SSH and telnet though.

ghans
• 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 site:raspberrypi.org

PiGraham
Posts: 3939
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Serial Communication with Ethernet

Sat Jun 29, 2013 8:38 am

eqooo wrote:Hi everyone,
I want to use ethernet communication on my desktop with my pi. I want to learn how to do "ethernet to ethernet communication" . How can I send a data from pc to RPi ? I'm using Debian for RPi.
Thanks.
Lots of ways to approach this. One is to sens small packets of information using UDP sockets.
UDP is good for small messages and fast delivery, but bad for large transfers and reliable delivery on busy networks.
UDP is more like a serial port connection than STREAM sockets, which are more reliable, are better for large transfers.

This link shows some of the basics in Python, but you could use almost any language :
http://paul.sydfamily.net/index.php?tit ... ython_code

There are lots of programming libraries that have features to support network communication.
UDP and STREAM socket programming is low level. For tasks more complicated than simple messages you will probably be better of using a library.

E.g. Pygame easy networking:
http://pygame-network.readthedocs.org/e ... index.html

You can use netcat to pipe data from one program, over the network and into another program.
http://en.wikipedia.org/wiki/Netcat#Mak ... s_a_server

eqooo
Posts: 19
Joined: Tue May 21, 2013 6:59 am

Re: Serial Communication with Ethernet

Mon Jul 01, 2013 7:10 am

Thanks so much your answers.
if I connect to internet , I need to socket programming with TCP/IP or UDP or others.
But I want to say there is no internet. so I want to connect Pc to RPi direct connection wit Ethernet cable.
How can I do?

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Serial Communication with Ethernet

Mon Jul 01, 2013 7:43 am

See my first answer.


ghans
• 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 site:raspberrypi.org

User avatar
joan
Posts: 14936
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Serial Communication with Ethernet

Mon Jul 01, 2013 7:53 am

eqooo wrote:Thanks so much your answers.
if I connect to internet , I need to socket programming with TCP/IP or UDP or others.
But I want to say there is no internet. so I want to connect Pc to RPi direct connection wit Ethernet cable.
How can I do?
Connect your Pi and PC via an ethernet cable.

Find your PC's IP address (something like 192.168.x.y). Go to your raspberry Pi and enter the command

sudo ifconfig eth0 192.168.x.z

where z is a number 1 greater than y.

You should then be able to ping between the machines and use ftp etc. From a programming language you should be able to open a socket on the Pi from your PC (and vice versa).

User avatar
topguy
Posts: 6491
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Serial Communication with Ethernet

Mon Jul 01, 2013 8:48 am

eqooo wrote: if I connect to internet , I need to socket programming with TCP/IP or UDP or others.
But I want to say there is no internet. so I want to connect Pc to RPi direct connection wit Ethernet cable.
How can I do?
TCP/IP is the protocol to use over internet, it doesnt mean that you NEED the internet to use TCP/IP.

You can send raw ethernet packets to the Pi if you know the MAC address. Example:
https://gist.github.com/austinmarton/1922600

But its more work, so its basicly safer and easier to use TCP/IP and you have so many libraries and guides on the net to help you in any language.

Return to “C/C++”