📜 ⬆️ ⬇️

Budget Serial to Ethernet adapter in one evening

Sometimes there is a need to monitor devices on the serial port, and it is not always convenient to locate a computer near the device, and sometimes it is simply not possible. And here comes to the rescue various Serial to Ethernet adapters , which are good for everyone except the price. Let's see what can be done cheaper and easier.



Hardware


I had such a handkerchief on hand at the ENC28J60 controller.
')

Controller based on ENC28J60. Ebay price $ 6.50

As MK we will use Arduinka.


Scheme of work.


Wiring diagram


Ready device.

Firmware


A full TCP stack on such components cannot be done. But you can catch the package, deploy it in the opposite direction, score data, send and break the connection. The memory for this operation in the case of using ATMEGA328 is only 2Kb, but it is necessary to allocate a buffer for the received packet and expand the buffer for receiving characters from the serial port. Thus, to establish a full exchange at full speed will not work, but to control the device and receive debug information this is enough.

The library for the ENC28J60 controller and the Arduino script can be found on the google code .

Software


Theoretically, you can write a full-fledged driver for the COM port, but this task is not for one night, it requires accuracy and careful debugging, it is much easier to make a client application that will manage the remote serial port.
I got this:



oneStart sending requests to the adapter
2Stop sending requests to the adapter
3Clear protocol
fourSave the protocol
fiveEnable automatic scrolling to the last message
6Automatically save log to file
7Packet count
eightDebug info
9Serial port speed
tenOpen remote serial port
elevenClose remote serial port
12Send Arduino team
13Command to send
14Send data to remote serial port
15Protocol text

The installation package and source code of the client application can be found on google code .

findings


The device turned out inexpensive, flexible and expandable. It is easy to add, for example, the ability of RESETa to be managed by a command. Unfortunately, due to the small size of the input buffer, the device will not be able to be used for work with a significant port load. The lack of full-fledged COM port emulation does not allow the use of standard terminal programs, but a special client application provides the minimum required functionality. Thus, the resulting scheme can be recommended for the organization of exchange over a serial port through a TCP network, if you do not need to transfer large amounts of data.

Topics without Kote look unfinished.

Source: https://habr.com/ru/post/137974/


All Articles