Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Reading from network socket - partial message

Reading from network socket - partial message 6 years 9 months ago #9037

  • pongraczi
  • pongraczi's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 71
  • Karma: 0
Hi,
I have an issue and I try to figure out, where should be the problem.

Short version: reading from remote tcp device produces partial message, sometimes (~10%).

Long version:

The configuration is the following:

[Proview 5.4, RemoteConfig object, TCP] ---LAN---> [rs485/ethernet gateway] ---RS485---> [serial device]

The length of the message I would like to read, between 6-25 characters.
The serial device start writing the message after it gets a hardware trigger (1-3 sec delay after the hardware trigger). Frequency of the message is about 7-8 seconds between two triggers.

Usually the message arrives and legal, but sometimes it only get the part of it, not the whole message.

I started a tcpdump to check the messages and it seems, the message is arrived (message found in the tcpdump), but in Proview, the message only contains a part of it. It seems there is a "gap" in the message and proview only get the first part (half/less than half) and the second half just gone to the Valhalla.

Example (starting with a hexa 02):
Expected message: \x02%007910816408007523389365276
TCPdump: \x02%007910816408007523389365276
Shown in proview: \x02%0079108

The rest of the string is gone.

Here is the config:
(The plcthread is 100msec on the proview, 9600 bit/sec on the serial device)

Kijells_272.png


Do you have similar experience and any hint, how to solve it?

I still investigating the situation, but at this moment it seems there is no message close character at the end of the message (like special character or hex code; please note, start indicator exists, 0x02)

Thanks,
István
The administrator has disabled public write access.

RemnodeTCP - validate message, end tag? 6 years 9 months ago #9061

  • pongraczi
  • pongraczi's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 71
  • Karma: 0
Hi,

In short:
Is there a way to validate a message, which comes from RemnodeTCP - Remtrans?
I mean, a valid message has a close tag: <cr> (in hexa: 0x0d which is the '\r').
I only want to get a DataValid flag and read the message from the buffer if it has a complete message, not partial message.

So, how can I set Proview (RemnodeTCP, Remtrans, buffer, whatever) to only report received message if it has a closing tag?

At this moment as I wrote in my previous post in this topic, I got DataValid flag even when I only got a partial message (for example some characters from the beginning).


What is the best practice for this kind of situation in general? Reading out buffers if there is a data in it and assembly the message in DArithm using pieces and only process message if I build up one?

Thank you!
István
Last Edit: 6 years 8 months ago by pongraczi. Reason: Set up an icon
The administrator has disabled public write access.

SOLVED - RemnodeTCP - validate message, end tag? 6 years 8 months ago #9085

  • pongraczi
  • pongraczi's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 71
  • Karma: 0
Hi,

Thanks for Claes, the working mechanism deeply explained in the other topic: www.proview.se/v3/index.php/forum/3-help...detcp-remtransobject

In short:
Receiving from remote tcp connection has nothing to do with the message if one not use header. The data will arrive as a stream and user should assembly to his needs, for example find the closing tag etc.
Received data could be any size, depending on the tcp/ip traffic etc. Just like in any other case, for example how to read from a tcp socket using C/C++.
The administrator has disabled public write access.
  • Page:
  • 1
Time to create page: 6.897 seconds