0
votes

(Sorry for my poor english).

Today, I would like to redirect all data from a port to another port. (Like socat or netcat, but I can't use these tools because of their licence).

My data are undefined (so are not start or stop bit) and have different length.

  • From ethernet port to an ethernet port it's easy(there are the ethernet header).
  • From ethernet port to an serial port it's also easy (there are the ethernet header to know the begin and the end of the frame and so after cut the data to send data to the serial port).

But my problem is from serial port to Ethernet port. How do I know when I received my full frame from serial port if I have not header? Because before redirect the data in Ethernet port, I need to receive all data and only after convert in a ethernet frame, we agree?

I thought about this solution: I can define an inter-frame delay, if the time between two serial data bytes is less than inter-frame delay, the data are in the same frame, and I wait the next data before convert the frame in a Ethernet frame.

1
If there is no header, no protocol on the serial input data, what you want is not possible in any reliable way. Time-interval protocols do not work. You cannot transfer 'messages' larger than one byte over a serial link octet stream - you need a protocol on top.Martin James
Yes I agree. A serial link transfers only consecutives bytes. But with an Time-interval I could know if the received byte and the next byte is contained within the same frame no ?Morgan
Modbus is a serial link protocol that supposedly uses dead time on the link to delimit packets. But I've never used it, so I can't comment on how well it works. Inter-frame delays do reduce throughput. Hardware support may be required to reliably measure/detect short intervals; I've seen a receiver timeout interrupt on some USARTs for this purpose.sawdust

1 Answers

0
votes

If you use Ethernet encoding over the serial port, including the headers, you should have an easier time figuring out packet boundaries.

Also look at existing tools for tihs such as good old SLIP.