Community
cancel
Showing results for 
Search instead for 
Did you mean: 
SArbo
New Contributor I
1,892 Views

How can i use the intel galileo gen 2 ethernet port using eclipse c/c++?

Hi, i´m starting with intel galileo gen 2 and i've already run many exercises with the arduino IDE, in fact i found that the ethernet library has many bugs since it cut communication with no reason, i found it too inestable. So i decided to learn how to develop sketches with c/c++ in eclipse. I already understand the MRAA library. However, i don't know how can i establish an ethernet communication, like a server socket or a client.

It would be nice if someone could give a heads up or a little clue to start working with the ethernet port.

Thank you in advance.

Tags (1)
8 Replies
SArbo
New Contributor I
105 Views

I´ve already tried something and it works, it's just a start. Here's the client and the server code. I hope someone has comments and suggestions to make it better.

BBOUC2
New Contributor II
105 Views

Hello Sebaz,

there is no difference between Arduino IDE or Eclipse if you want to access the integrated Ethernet port. In both case, you just need to use the BSD socket library. I am doing this everyday, and it works like a charm.

By the way, I think you are mixing two different things. The Ethernet library is designed to run with the Wiznet W5100 shield, which is completely useless with a Galileo. The BSD communication library within Linux is known to be rock stable (this is one of the main foundation of Linux ) so I can't really understand that you see it as unstable.

Benoit

SArbo
New Contributor I
105 Views

Thank you, i didn't know that, so the ethernet library is for a specific shield. But can you show me an example use to create a server socket using BSD socket library.

I need to create a server that listen in a specific port, but i want it like the ethernet library does it. While the listener waits for data from the client, the sketch can still run doing other processes and read the data from the client later.

Diego_V_Intel
Employee
105 Views

Hello sebaz_143,

I've just found a couple of interesting links that you might want to check. The following sites talk about the BSD sockets:

On the other hand, the following sites discuss some examples that might be useful for you:

I haven't tested those examples, but I hope they are what you are looking for. Anyhow, let's wait for BenKissBox. He might give you another useful suggestion.

Regards,

Diego.

idata
Community Manager
105 Views

Although you're using C/C++, I've found using Python to be the most useful language to experiment with the galileo. If I could, I would've built a Python IDE similar to Arduino's (turns out, you have rsync in AlexT's repos so why not use that?) or open an sftp session and program in Python. C/C++ should be the next step IMHO...

BBOUC2
New Contributor II
105 Views

I've just found a couple of interesting links that you might want to check. The following sites talk about the BSD sockets:

On the other hand, the following sites discuss some examples that might be useful for you:

That's exactly what I meant. Just follow those examples (there are hundreds of others) and you will get access to the network socket of the Galileo (and believe me, it's much, much more powerful than what you can do with the Ethernet shields based on the Wiznet chip)

I have two more recommendations :

- if you have a Windows machine, I recommend you to download the Hercules utility. This is a very nice (and free!) tool which allows you to create TCP and UDP sockets, and send/receive test data (you can use hexa or decimal or ASCII data). I use this software all the time when I test sockets on embedded devices like the Galileo

- do not forget that the Galileo is using DHCP by default. Sometimes it's a pain to find which address it has taken on your network. So I recommend to add this line in your sketch :

system("ifconfig eth0 inet 192.168.0.150 netmask 255.255.255.0 up");

This will give a static IP address to the integrated Ethernet card. The fun is that you can give as many addresses as you want (as long they are not in the same subnet). Thank you Linux

This line is also very useful when you deal with tools like SSH by the way (for remote access to the Galileo)

If you want to make the Galileo fully static, you will need to edit /etc/network/interfaces. To take care however when you change something in this file, since it changes the Linux configuration. You may end up with something invalid which will make the Galileo unreachable from the network (then you will need to use the serial console to edit back the file. Don't worry, the Galileo will not die for that, but it's good to be warned before )

Benoit

BBOUC2
New Contributor II
105 Views

"what is the best langugage for the Galileo" is typically the kind of discussion which never ends once it's started

I think it's personal taste before all (for experimentation at least). Python is very nice language to learn programming, but I do not like it. Probably because I belong to the old school, which learned with C/C++ (and yes... I have to admit it... I also come from the time where there was a language called BASIC )

idata
Community Manager
105 Views

IMO, for newcomers Python is a language that encourages neat code (properly indented and readable) without the hassles of dependency management. C++ direly needs a package/source management system like nuget (.NET), pip (Python) and npm (node). This will make things so much easier.

I also started from GW-BASIC

Best,

Taimoor

Reply