How to add value to end of array in Simulink?

7 views (last 30 days)
J.Red
J.Red on 10 May 2016
I have a GPS spitting out one character at a time. I want to, in simulink, add the characters to an array until the end of the line is reached '/r/n'.
Basically, GPS_Char is my one character as read from my RX line;
void loop(){
int i = 0;
if (GPS_Serial.available()){
GPS_Char= GPS_Serial.read();
if (GPS_Char != '/n' && i < 80){ //the size of the longest sentence that i care about
GPS_Sentence[i]=GPS_Char;
i+=1;}
else{
i=0;
//output gps_string to another function}
}}
I tried to make a function that is passed the GPS_Char but I don't know how to keep the GPS_Sentence vector.
For simplicity sake, I'm using a function that outputs 1 character at a time out of a predetermined string. I want to put the string back together by reading only one character at a time! ...the countOut is just fed back into the function (as count) with a unit delay.
function [y,countOut] = fcn(count)
%#codegen
gps = '$GPGGA,111636.932,2447.0949,N,12100.5223,E,1,11,0.8,118.2,M,,,,0000*02';
if count > length(gps)
count = 1;
end
y = uint8(gps(count));
countOut = count + 1;
end

Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!