CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Thu Aug 22, 2019 4:44 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 1 post ] 
Author Message
PostPosted: Thu Aug 08, 2019 9:01 am 
Offline

Joined: Thu Nov 01, 2018 2:41 pm
Posts: 4
Hallo zusammen,

ein Raspberry bekommt über TCP einen STRING mit Daten, die duch ein ',' getrennt sind. Die Werte würde ich gern in einem ARRAY ablegen.
Bsp.:
$GPGSA,M,3,21,16,29,25,26,31,,,,,,,1.7,1.0,1.4*32
#BESTPOSA,ICOM1,0,70.5,FINESTEERING,2065,372265.500,00000000,b1f6,14392;SOL_COMPUTED,SINGLE,00.00,0.0,000.000,00.6000,WGS84,1.9100,1.7786,4.3825,"",0.000,0.000,12,12,12,12,00,06,00,33*ca5f2368


Folgendes hab ich mir im Internet "zusammengesucht":
Zuerst such ich nach 'GPGSA'
Code:
FUNCTION_BLOCK Message
VAR_INPUT
   sRxData: STRING(255);
   sFind: STRING(255);
END_VAR
VAR_OUTPUT
   sMessage: STRING(255);
END_VAR
VAR
   iCurPos: INT;
   iPosEnd: INT;
   sTemp: STRING(255);
END_VAR
------------------------------------------------------------------
iCurPos := FIND(sRxData, sFind);

IF iCurPos = 2 THEN
   sTemp := sRxData;
   iPosEnd := FIND(sTemp, '$L');
   sMessage := MID(sTemp, iPosEnd, 1);
END_IF




als nächstes die Werte in dem zuvor ermittelten STRING in ein ARRAY ablegen:
Code:
FUNCTION_BLOCK DATA
VAR_INPUT
   sInput: STRING(255);
END_VAR
VAR_OUTPUT
   DATA: ARRAY [1..50] OF STRING;
END_VAR
VAR
   i: INT;
   sTemp: STRING(255);
   iPos: INT;
   iLenght: INT;      
END_VAR
------------------------------------------------------------------
sTemp := sInput;

FOR i:= 1 TO 45 DO
   iPos := FIND(sTemp, ',');
   DATA[i] := LEFT(sTemp, iPos -1);
   IF (iPos = 0) THEN
      DATA[i] := sTemp;
      sTemp := '';
   END_IF
   sTemp := RIGHT(sTemp, LEN(sTemp) -iPos);
END_FOR


Bei GPGSA funktionier es, bei BESTPOSA bekomm ich immer einen Ausnahmefehler, dass die CPU Load über 95% ist..
Was mach ich falsch? Gibt es eine bessere Möglichkeit?

Vielen Dank vorab!


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 1 post ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited