NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Using string functions to parse GNSS sentences

Solved!
Go to solution

Can someone help with TS string functions?

 

My goal is to extract the first line starting with "$GPGGA", and then separate it into an array separating at the commas.

 

Sample input:

$GPGGA,211332.000,4202.4046,N,08802.0322,W,1,8,0.98,274.2,M,-34.1,M,,*6C
$PGTOP,3,AXN_3.20,8175,007-21-2014,GNSS_EXTRF_9600,007-05-2014,211333*03
$GPGGA,211333.000,4202.4046,N,08802.0322,W,1,8,0.98,274.2,M,-34.1,M,,*6D
$GPGGA,211334.000,4202.4046,N,08802.0322,W,1,8,0.98,274.2,M,-34.1,M,,*6A
$GNGSA,A,3,19,28,25,10,,,,,,,,,1.54,0.98,1.19*10

Is the "$" character special in TestStand?

 

FWIW in python I'd do

s.split('$GPGGA')[1].strip().split(',')
0 Kudos
Message 1 of 3
(2,816 Views)
Solution
Accepted by topic author stephenb2

Hi Stephen,

 

Have you seen this?

Parsing a String Using Functions from the TestStand Expression Browser

http://www.ni.com/example/26308/en/

 

This seems to be similar to your goal. 

Chase
NI Technical Support Engineer
0 Kudos
Message 2 of 3
(2,780 Views)

Thanks, that was very helpful. Especially the combination of "Find" and "Replace".

 

1. search for position

Locals.position = Find( Locals.my_string, Locals.search_string )

2. Remove everything before find by replacing with empty string

Replace( Locals.my_string, 0, Locals.position, "" )

3. Repeat as needed

0 Kudos
Message 3 of 3
(2,776 Views)