LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

s7 telegram split

Solved!
Go to solution

hello everybody

 

i'm pretty new to labview an i've got a question concerning a datastream i'm getting from an s7 simantic.


the datastream looks like the following

 

#SPSDATA#26|ID=SIMATIC1|DB295.DBB2=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0#SPSDATA#26|

ID=SIMATIC1|DB295.DBB2=0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0#SPSDATA#26|ID=SIMATIC1|

DB295.DBB2=0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

 

since this is a tcp connection i'm getting packages and getting e.g. 30 bytes per iteration, converting them into a string an parsing the string.

 

i wonder what is the best way to be sure to have at least one complete telegram

#SPSDATA#26|ID=SIMATIC1|DB295.DBB2=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

 

because i start from an arbitrary point where i can get

 

,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0#SPSDATA#26|ID=SIMATIC1|DB295.DBB2=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

 

in the first place which mean i've to cut everything before the first valid telegram and then wait for the rest of the ip package or if this is lost

for the next telegram.

 

i tried to use some kind of patternmatching, since the structure is always the same but it didn't work out.

 

once i've to the telegram, the processing is not really problem but i'm not sure which VI would suite best for in this case!

 

maybe someone has a hint how to solve this problem elegant in labview. 

 

thanks andy

 

 

0 Kudos
Message 1 of 5
(3,366 Views)
Solution
Accepted by topic author Andreas-Zeiner

Hi Andreas-Zeiner,

 

  Please go through "MatchPattern" vi and "Match Regular Expression" vi in string pallette .

 

Regards,

Srikrishna.J

Regards,
Srikrishna


Message 2 of 5
(3,354 Views)

thanks for the answer, i also think this might be the best way to do it since i know regex from java & co 😄 thanks!

0 Kudos
Message 3 of 5
(3,349 Views)

Hi Andreas,

 

concatenate the received data snippets in y string.

Then search for "#SPSDATA#26|ID=SIMATIC1|DB295.DBB2=". You get 3 string parts: data before, at, and after match.

- Data before match should be your expected data, atleast after the first full message is received.

- Data after match is taken to concatenate the next received messages…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 5
(3,329 Views)

hoi gerd

 

i've implemented it the way you described, works fantastic!!!

thank for your answer!!!

 

greetings andy

0 Kudos
Message 5 of 5
(3,316 Views)