Data lost reading two ports at the same time

Discussion to talk about software related topics only.
Spilba
Posts: 5
Joined: Thu Mar 08, 2018 11:14 am

Data lost reading two ports at the same time

Post by Spilba »

Hi!

We are using SBL2e Dual Serial-to-Ethernet. The module has the configuration default except the ip and port. We use static ip and we changed the port 23-24 to 81-82.

We put hexa data into both serial port (Port 0 and Port 1) and we start reading the TCP stream with a terminal (RealTerm). When we establish the connection with one TCP port, we receive the same data we put in the serial port. But, when we establish the connection with both TCP port, we lost some bytes in both.

What could be the problem?
User avatar
TomNB
Posts: 538
Joined: Tue May 10, 2016 8:22 am

Re: Data lost reading two ports at the same time

Post by TomNB »

What baud rate are you running at? Are you running two instances of realterm? I am not familiar with it. Does it somehow try to handle two data streams in a single instance?

Are you familiar with telnet? What happens if you run one telnet session from the command prompt for each of the serial streams?

What type of pc and os are you using?

Are you using virtual comm port software?

Do you have native serial ports on your pc, or are they usb to serial?

Can you provide details on the source of your serial data?
Spilba
Posts: 5
Joined: Thu Mar 08, 2018 11:14 am

Re: Data lost reading two ports at the same time

Post by Spilba »

What baud rate are you running at?
We tried both in 115200, both in 57600, one 115200 and the other in 57600. We always lost data.

Are you running two instances of realterm? I am not familiar with it. Does it somehow try to handle two data streams in a single instance?
Yes, we open two realterm instances to read tcp data. We also devoloped a software that opens all tcp ports and read data simultaneously, to avoid the realterm, with same results.

Are you familiar with telnet? What happens if you run one telnet session from the command prompt for each of the serial streams?
Yes, we are familiar with telnet. But we don't read the data with telnet. We read the stream as raw data.

What type of pc and os are you using?
We use different kinds of PCs. All of them in windows 10.

Are you using virtual comm port software? Do you have native serial ports on your pc, or are they usb to serial? Can you provide details on the source of your serial data?
Serial data comes from an embedded system which is not related to any PC. It is directly connected from a microncontroller UART.
Spilba
Posts: 5
Joined: Thu Mar 08, 2018 11:14 am

Re: Data lost reading two ports at the same time

Post by Spilba »

It is important to enphasize that the problem occurs when both channels are use at the same time simultaneously.
User avatar
TomNB
Posts: 538
Joined: Tue May 10, 2016 8:22 am

Re: Data lost reading two ports at the same time

Post by TomNB »

There are a couple of possibilities. The SBL2e product line is a single chip solution, and it has a total of 32k of RAM (a product like the SB800EX has 64MB of RAM). The serial to Ethernet application allocates 1500 bytes for each serial channel. If the TCP end of things is fast enough, meaning there are no re-transmits, then it should work without flow control. If there are any network delays, then you will need to use the flow control rts/cts or software flow control on the serial ports. If you are running both channels at 115,200, odds are you will need to use serial flow control because the network end can have ack delays or re-transmits.
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Data lost reading two ports at the same time

Post by pbreed »

On a local network we can run both channels at 115K baud without loosing a single byte,

Is this a local network, or is a router involved?
What is the ping time from the pc to the device?
We have seen lots of problems with multilple USB serial ports running on one PC....

Also confirming you are running in TCP not UDP mode?
Spilba
Posts: 5
Joined: Thu Mar 08, 2018 11:14 am

Re: Data lost reading two ports at the same time

Post by Spilba »

TomNB: We checked the rts/cts lines with an oscilloscope and they never change, so, that is not the problem. Also we put both channels at 57600, with same results.

pbreed: We connected the module directly a PC (and we did the test with different PCs), so there are not any router/switch/etc. The ping time is <1ms. And we are using TCP (and we use a terminal and an own app to do these tests).

However, we continued with our test. We observed that the module made packets with 1-3 bytes while it receives bytes from UARTs. After that, we enable custom packetization to:
Number of characters to accumulate: 50.
Number of milliseconds to wait: 100.
Slush TCP/UDP frame: NA.

We made the same tests and it seems the problem have disappeared. We continue testing to verify that. Is this possible? We need to understand the module behavior to certify that we will not lose any bytes in any case.
User avatar
TomNB
Posts: 538
Joined: Tue May 10, 2016 8:22 am

Re: Data lost reading two ports at the same time

Post by TomNB »

In order for rts/cts to work, it must be supported on both sides of the serial connection. For the SBL2e, you can enable it on the serial port configuration page. Can you verify you have the physical rts/cts connections wired correct from your embedded processor and cable? It might be good for us to verify all the connections. So you should have 5: rx, tx, gnd, rts and cts. How are those wired between your embedded processor and the SBL2e?

Would also like to verify your firmware on your embedded processor supports rts/cts

Thanks
Spilba
Posts: 5
Joined: Thu Mar 08, 2018 11:14 am

Re: Data lost reading two ports at the same time

Post by Spilba »

I verified rts/cts connections were correct. I had enabled both on the configuration page. The microcontroller has rts/cts. The SBL2e has two UART but only in one rts/cts lines, so I cannot control both. However, I think that is not the problem.

I’m using TCP and all default configuration. One module at 57600, and the other in 115200. I disable custom packetization -> I lost bytes. I enable custom packetization in 50bytes/packet -> I don’t lost bytes. WHY?! What it could be the problem?
User avatar
TomNB
Posts: 538
Joined: Tue May 10, 2016 8:22 am

Re: Data lost reading two ports at the same time

Post by TomNB »

Hello,

We are looking into this further and will let you know as soon as we have some results. Here is where we are at so far. On a LAN we can run both channels without loss at 115200 with no hardware handshaking. If we introduce any latency on the network we start to lose data, dropping down to 57600 on each port starts to work again. TCP communication is flow controlled, so if there is any delay in processing or loss of packets causing re-transmits, data can be lost if the serial port buffers overflow. The only way to guarantee no loss is to have flow control on each serial connection. This will be true on any serial to Ethernet device, not just the SBL2e. Due to its limited number of pins, the SBL2e has rts/cts on only one serial port. Packetization makes things better because there are significantly fewer packets/transactions to process on the network side of things. We're examining the code to see if there can be any improvements, but wanted to point out that the second serial port will always be at risk for losing data if the network end of things get flow controlled off.
Post Reply