Ethernet module in beagle bone black

178 views
Skip to first unread message

Megha Bhirade

unread,
Jul 24, 2019, 12:14:21 AM7/24/19
to BeagleBoard
Hi,

I am using beagle bone black board in Linux ubuntu 16.04LTS, i need to work on Ethernet .

requirement is like enabling Ethernet  between the Board and PC and i need to send the data from PC and need to receive the data on beagle bone black using Ethernet communication and once data collected that data i need to pass to the other PC using Uart..

Uart enabling and transmitting the data i understood...

please tell me how to configure Ethernet and C program to receive the data from Ethernet....

please suggest me any related link for this....

gra...@flex-radio.com

unread,
Jul 24, 2019, 9:11:00 AM7/24/19
to BeagleBoard

Robert Heller

unread,
Jul 24, 2019, 11:53:57 AM7/24/19
to beagl...@googlegroups.com, BeagleBoard, Robert Heller
Well... You probably don't want to delve into raw Ethernet. What you want to
do is implement some sort of Tcp/Ip data transfer and let the kernel(s) sweat
the details.

Tcp/Ip uses a client / server model: one side is the "server" and the other is
the "client". The server is a little more complicated than the client.

To implement a "server" process, you need to creating a socket, bind it to a
port [number] and then listen on it and when someone connects to the port (the
client), you then start communicating.

In C you would use these functions:

socket() -- create a socket
bind() -- bind it to an address & port
listen() -- listen for connections
accept() -- accept a connection to the client
Then:
read() and write() to actually transfer data, then close() when done.

Minimial C program would look something like this:

#include <stdio.h>
#include <errno.h>

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <stdlib.h>
#include <string.h>
#include <sys/poll.h>

#define ERRORCHECK(funcall,message) \
if ((funcall) < 0) { \
int err = errno; \
perror(message); \
exit(err); \
}

#define PORT 10000 /* Port we will be listening on. */

int do_dataTransfer(int connection,struct sockaddr_in *fromAddress);

int main(int argc, char *argv[])
{
int listenSock, connectSock, pstatus;
struct sockaddr_in my_addr, peer_addr;
socklen_t peer_addr_size;
struct pollfd ufd;

/* Create a socket */
listenSock = socket(AF_INET, SOCK_STREAM|SOCK_NONBLOCK,0);
ERRORCHECK(listenSock,"Failed to create socket")

memset(&my_addr,0,sizeof(my_addr)); /* clear out the address */
my_addr.sin_addr.s_addr = htonl(INADDR_ANY); /* listen on all addresses */
my_addr.sin_port = htons(PORT);
my_addr.sin_family = AF_INET;
/* Bind the address to a port */
ERRORCHECK(bind(listenSock,(const struct sockaddr*)&my_addr,sizeof(my_addr)))
/* Listen for clients */
ERRORCHECK(listen(listenSock,1) /* backlog of one: only one client at a time */
/* Check to see if anyone wants to talk to us */
while (1) {
ufd.fd = listenSock;
ufd.events = POLLIN;
pstatus = poll(&ufd,1,10);
ERRORCHECK(pstatus,"Poll failed");
if (pstatus > 0) {
/* Someone wants to talk, connect to his socket */
connectSock = accept(listenSock,(struct sockaddr*)&peer_addr,&peer_addr_size);
ERRORCHECK(connectSock,"Accept failed");
if (connectSock > 0) {
/* We are connected. Now we can talk to each other. */
do_dataTransfer(connectSock,&peer_addr);
}
}
usleep(50000); /* sleep 50 ms */
}
}

The client program would use socket() to create the socket, then connect() to
connect it to a server. And then read() and write() to transfer data and
finally close() to close the connection.

On most Linux machines, there are man pages for all of these functions (in
section 2). There are probably zillions of example programs out on the
Internet as well.

--
Robert Heller -- 978-544-6933
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
hel...@deepsoft.com -- Webhosting Services

Adrian Godwin

unread,
Jul 24, 2019, 12:32:15 PM7/24/19
to beagl...@googlegroups.com
You might not need to write any code. The parts of a linux system are sufficiently generic that you can often link them with existing utilities. There are a number of ways to connect a serial port to a network connection so that it can be used over ethernet.

For example, read the answers here : https://stackoverflow.com/questions/22624653/create-a-virtual-serial-port-connection-over-tcp

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/20190724155315.EF5FD26C0168%40sharky3.deepsoft.com.

Dennis Lee Bieber

unread,
Jul 24, 2019, 4:35:08 PM7/24/19
to beagl...@googlegroups.com
On Tue, 23 Jul 2019 21:14:21 -0700 (PDT), Megha Bhirade
<meghsb...@gmail.com> declaimed the
following:

>
>requirement is like enabling Ethernet between the Board and PC and i need
>to send the data from PC and need to receive the data on beagle bone black
>using Ethernet communication and once data collected that data i need to
>pass to the other PC using Uart..
>

What type of data? If it is, say, something that is collected in files
at the source machine, then one could use something like (s)FTP to transfer
the file itself, or if you can make a directory sharable via NFS (or maybe
Samba) you'd have direct access to the files in that directory and can use
command line tools.

If it is some sort of real-time monitoring/logging system, then you may
need to define a protocol so that both ends agree on what a transfer
consists of, and can tell when it succeeds. TCP is a stream protocol, and
what is sent in a write may not be completely seen by a read (meaning
another read may be needed to gather the rest) or multiple writes may be
seen by one read. You either have to send a "length" at the start of the
data, or use some delimiter (newline if text) at the end of the data so the
other side knows it has received a complete item.

>Uart enabling and transmitting the data i understood...
>
>please tell me how to configure Ethernet and C program to receive the data
>from Ethernet....
>
Does it /have/ to be done in C?

Python has many libraries that encapsulate the more common protocols
(http, pop, nntp, smtp, ftp...):

Low level/raw: https://docs.python.org/3/library/ipc.html (most applicable
-- socket and ssl)
High level: https://docs.python.org/3/library/internet.html (most
applicable -- ftplib, socketserver, maybe telnetlib)

Note that socketserver is generic -- you still have to define the
high-level protocol to manage "what is a message"; socketserver just
handles the bind/listen/accept stuff behind the scenes.





--
Wulfraed Dennis Lee Bieber AF6VN
wlf...@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

Mark Lazarewicz

unread,
Jul 24, 2019, 10:12:37 PM7/24/19
to beagl...@googlegroups.com
Greetings Smegha

Who gave you requirement?


Is this a college assignment and you want us to write the code? Have you considered the professor is watching this group? Are the schools really that poor over there or is this some embedded Boot camp where assignments are handed out so you can get a job at Boeing for $9 an hour and cause people to get killed on our next airplane.
Nobody's this green
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.

Megha Bhirade

unread,
Jul 25, 2019, 12:13:44 AM7/25/19
to BeagleBoard

Hi  lazarman,

I am working as embedded firmware developer in company , earlier 1 year i worked on Arm cortex M7 and M4 controller in product development section...

recently i shifted to this BBB, so now i am learning and implementing in product development.
if anything support needed means i should contact to BBB group only....

Megha Bhirade

unread,
Jul 25, 2019, 12:19:16 AM7/25/19
to BeagleBoard
Hi robert,

Thanks for your reply, i learnt socket programing long back, so i can recollect it..

my question is , for  communication of both Ubuntu PC(server) and BBB(client) IP address and port number for both server and client should be same???

clear about IP address??

                                 

AKHIL VR

unread,
Jul 25, 2019, 2:45:36 AM7/25/19
to beagl...@googlegroups.com

Robert Heller

unread,
Jul 25, 2019, 7:24:32 AM7/25/19
to beagl...@googlegroups.com, BeagleBoard, Robert Heller
Each machine has its own *unique* IP address. The port number should be the
same. The server binds to host 0.0.0.0 (INADDR_ANY), and the client connects
to whatever the server's IP address is. I don't know how your Ubuntu PC is
getting its IP address. Usually, there is a DHCP server somewhere on your LAN
that is giving out IP addresses.

Charles Steinkuehler

unread,
Jul 25, 2019, 8:55:12 AM7/25/19
to beagl...@googlegroups.com
You might want to take a look at the netcat utility:

https://en.wikipedia.org/wiki/Netcat

You can use it to send or receive data via Etherenet as easily as
using the cat command (hence the name).
--
Charles Steinkuehler
cha...@steinkuehler.net

Indiaaditya Networks

unread,
Jul 25, 2019, 2:02:50 PM7/25/19
to beagl...@googlegroups.com
@Mark understand your emotions. My specific response to Boeing and $9 issue is this: Sole responsibility lies with Boeing. Blaming the engineer cannot be the solution. They had the software with them. It was they who were supposed to test it. They are responsible for the lives of numerous passengers and for the employment of 1000's of workers there. If you went to a shop and asked for soap and got manure instead, it is your job to return it to the shopkeeper and not go home and apply it all over your body.
@Megha you should have done some background research before posting on this group. Many people have genuinely helped you by taking out their valuable time. But don't take their goodwill for granted. Not only does it reflect badly on you but also sheds bad light on a particular section.
Do some homework and even after it you are not getting an answer request on the group. 

On Thu, Jul 25, 2019 at 7:42 AM 'Mark Lazarewicz' via BeagleBoard <beagl...@googlegroups.com> wrote:


--
Indiaaditya Networks.... Embedded System development
For industries customised needs

Megha Bhirade

unread,
Jul 30, 2019, 5:27:04 AM7/30/19
to BeagleBoard
Hi,

thanks for reply it is working fine
                                                 
Reply all
Reply to author
Forward
0 new messages