Sending Serial Commands Via Ethernet
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. 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: 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. Pygame easy networking: You can use netcat to pipe data from one program, over the network and into another program. 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). 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: 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. Display posts from previous: Sort.
Sending Serial Commands Via Ethernet
Your Serial.write commands are using pins 1 and 2 of the Arduino to perfrom TTL communication(see the Serial library - it is not related to your Ethernet shield). You'll probably see some gibberish if you open the Arduino serial monitor. The shield will probably not help you.
Ethernet is not the same as RS232. Just because you can get two things plugged into each other through converters doesn't mean they know how to speak to each other, as shown in. You should be able to get a TTL to RS232 connector for pretty cheap, but note that if you use pins 1 and 2 you may not be able to upload new code. Alternatively, you could look into an RS232 shield. DB9 and RJ45 are just connectors.
They can be used for anything, not just serial and ethernet. Wiring an rj45 for serial is pretty common, though there's not really a standard for it.
You could even run Ethernet though a DB9 if you wanted to be silly, it would probably perform poorly since ethernet has more stringent requirements than DB9 connectors tend to be made to. You need to get the pinout for the camera's rj45 port and wire up a DB9 adapter so you can use it with your RS232 shield. Besides the hardware issues others have pointed out, the two loops that send the commands are off by one.
If you have an array with 10 elements (0-9) and your for loop is testing for less than sizeof(array), then you are not sending the last byte. You should be able to stack your ethernet and rs232 shield, although you should remove the rs232 shield while programming to prevent it from holding the RX line. You can make a cable for your camera by clipping one end off and ethernet cable and soldering on the mating DB9. You should only need TX, RX, and ground.
Leave the others disconnected. Do you have the pinout for the RJ45 on your camera?