[Scilab-users] Regex problem

Gerhard Kreuzer gerhard.kreuzer at liftoff.at
Fri Aug 26 13:11:30 CEST 2016


Hi Samuel,

thanks for that, will try it.

I just want to read the meta data, which were strings and find the Point
where the binary data starts. Than I start reading the binary data using
mgeti ... From the meta data I know the amount of binary data, so I know
where binary data Ends and next meta data starts.

[dataStart,dataEnd,dataMatch,data]=regexp(strData,'/#data#/')
// Analyze meta data
[adcStart,adcEnd,adcMatch,adcInstructions]=regexp(instructions,'/adc\s*(?P<start>\d+)
(?P<smplCnt>\d+)/')
adcStartingPoints = evstr(adcInstructions(:, 1))
adcSampleCounts   = evstr(adcInstructions(:, 2))
mseek(dataEnd, fdRawData, 'set');                       // Set pointer to
start of binary data block

i = 1
j = 1 
                                                        // Read the block,
into a matrix
for k = 1:size(adcInstructions, 'r')
    sampleCount = adcSampleCounts(k,1); 
    i = 1  
    while i <= sampleCount do                         
        vals(j, 1) = adcStartingPoints(k, 1)* 1e-3 + (i-1)/sampleRate;
                                                            // Use column 1
for timestamp
        vals(j, 2:8) = mgeti(7,'il',fdRawData);             // Use column 2
to 8 for state and data
        i = i + 1;
        j = j + 1;
    end
    // Is there more?
    pos = mtell(fdRawData)
    //strData = mgetstr(5, fdRawData);
    //[dataStart,dataEnd,dataMatch,data]=regexp(strData,'/#EOC#/')
    //mseek(pos + dataEnd, fdRawData, 'set');
    mseek(pos + 5, fdRawData, 'set');
end

This way, regexp dosn't have to deal with binary data at all.

With best regards

Gerhard



--
View this message in context: http://mailinglists.scilab.org/Scilab-users-Regex-problem-tp4034446p4034499.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.



More information about the users mailing list