Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I would like to filter captured data

Status
Not open for further replies.

clacasse

Programmer
Aug 22, 2003
7
US
I think what I'd like to do should be relatively simple but I have been unsuccessful so far. I'd like to capture data from com1 (serial connection) and write it to a text file. I have been successful in doing that. However I'd like it only to capture relevant data. For example, capture only lines that have more than 24 characters. All other lines are irrelevant and not needed. Should I use ASPECT to do this, or is there some other filtering option available. Thanks!!
 
What you could do is use the rget command to retreive the data as it comes in (this will cause the data to not appear on screen). Then, use the strlen command to get the length of the received string and see if it is 24 characters in length or greater.


aspect@aspectscripting.com
 
Thanks for your help! Could you give me a small example of how that would look? I've taken a look at the samples included on the CD and am going to use the 24 hour capture sample to capture my data. I'm not sure where to place the rget statement and where I'd test it for the 24 character minimum using strlen. This syntax is completely new to me.
 
If you use rget, none of the information will appear on the screen or in the capture file. I would use a simpler script than the 24 hour capture sample, although you could take the filename creation from that and put it in this example:

proc main
string sLine
integer iLen

if fopen 0 "filename" CREATE TEXT
while 1
sLine = ""
rget sLine 80 FOREVER
strreplace sLine "`r" ""
strreplace sLine "`n" ""
strlen sLine iLen
if i0 == 22
fputs 0 sLine
endif
endwhile
endif
endproc

The script will open the specified file (replace filename with your file in the fopen command), then wait for a line of data forever. I put in the value of 80 characters since some value has to be present when the forever keyword is used, but this command will also terminate when a carriage return is received. I strip out the carriage return and linefeeds in the string, then if the result is 22 characters in length, it is output to the file we opened.


aspect@aspectscripting.com
 
Thanks for the sample. I tried it and it didnt put anything on the screen like you said but it also didnt put anything in the capture file. Then I reread your post and noticed you said if I use Rget it will not appear in the capture file either. Is this right?
 
Correct, the data will not appear in the capture file either. The data should appear in the filename you specify in the fopen command (if you just put a filename with no path, it will be in your ASPECT directory).


aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top