Sending HEX Values via Ethernet from BeagleBone Black

Hey guys,

I would like to have my BeagleBone Black output certain hex values over
Ethernet (either UDP or TCP) to another offline system. Is there a simple
way to go about doing this? If so, are there any specific examples of this?
Thanks!

  First: Define what you mean by "hex values"...
  Second: Study any textbook on network I/O (covering TCP/UDP) over
sockets. Related: What language do you intend to use?

  Hexadecimal is a /display/ (text) encoding for binary data. If you
really mean "hex", then you just need to convert the binary data to a
string, and send the string.

hxstr = "%8.8X" % 123987456
hxstr

'0763E600'

print(hxstr)

0763E600

{gets uglier for floating point -- one needs to use struct module to pack
the float into a bytestring, then unpack the bytestring as an integer}

  If you mean arbitrary binary values, you need to pack them into a byte
array and send the byte array -- though this does introduce the next
factor...

... TCP is a stream protocol -- it ensures that you will receive the sent
data, but does not guarantee that you will receive the same number of
packets as sent. It can split packets into multiple receive calls, or join
multiple send packets into a single packet. It is up to YOU to define the
high-level protocol that allows you to know if you have received all of a
transmission (for example -- you send a count of how many bytes are to
follow... Many of the text protocols use a line that contains just a ".").

... UDP, on the other hand, does not split/combine packets -- what you
receive IS what was sent. However, it does not guarantee delivery! Any
individual packet can be lost/undelivered. It is up to YOU to define a
protocol that lets you detect lost packets (unless your application can
live with missed packets).

a quick google search found...

https://wiki.python.org/moin/TcpCommunication

Regards,

Forgive me, but -- that's a rather dated page for Python (it's Python
2.x, for one thing, and any new work should be done with Python 3.x). I'd
suggest the OP peruse the following...

  The basic example at
https://docs.python.org/3/library/socketserver.html
is more up-to-date...

  Also, Python has added a lot of standard library modules for network
access... cf:

https://docs.python.org/3/library/socketserver.html

along with

https://docs.python.org/3/howto/sockets.html#socket-howto

  For creating binary packets to send/receive

https://docs.python.org/3.8/library/struct.html

  And a caveat: In Python 3.x, "strings" are Unicode data, not "bytes" --
they may need to be encoded/decoded using a specified encoding into a byte
structure.

Hi,

If you would like to do it in C (and you are running any Unix variant on your BBB) the book “UNIX Network Programming volume 1” might be something for you.
I’m not very experienced on the subject, but just putting it out there.

Good luck,
Robert