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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capture File Manipulation with Date and time stamps

Status
Not open for further replies.

FredAfc

Programmer
Feb 11, 2002
1
US
Tek-Tip Group,

I have started a new job at a company that uses procomm
scripts to collect data, simulate conditions, and gather
run-time data on embedded systems. I am attempting to
write a script that will capture all the data from one of the embedded cards, and store it to a file. I would like to know if it is possible to capture a line of text from the
serial port, do a string compare (if compare is same) print
the string to the file along with a time stamp?
Would I do the file I/O with the capture Icon, or would
I use the capture provided in the Aspect command language?
A list of commands would be helpful, if it is possible to
do this:


Here is an examle of what I would like to do:

from the serial port of the embedded device:

register 0x0100 = 0x45
register 0x0101 = 0x9C
register 0x0100 = 0xFF
register 0x0101 = 0x8A

the data stored to the file

register 0x0100 = 0x45 February 11, 2002 10:14:23AM
register 0x0101 = 0x9C
register 0x0100 = 0xFF February 11, 2002 10:44:03AM
register 0x0101 = 0x8A



Thanks for any help
 
This should be fairly simple to do. If you want the date and time appended after the string, then you will want to use an ASPECT script as the file capture functionality only grabs what comes across the data port (it doesn't have the ability to timestamp the data).

You would use the capture on command to start the capture. You will also want to look at some of the set capture commands to see if any of those will make your life easier (chances are they will). You can use the capturestr command to insert text into a capture file. However, it does not appear that the capturestr command can insert text on a line that already has data. During the quick testing I did, the inserted text was placed on its own line. If the inserted text must go on the same line as the referenced data, then I would consider not using a capture file, but "rolling your own" capture methodology.

Here's how to do that. You would first need to open a file using the fopen command. You would then use the rget command inside a while 1 loop (make sure you have some sort of way to break out of the loop, maybe a control in a dialog). The rget command should use the FOREVER parameter so that it is always waiting for input. When the rget command receives some data (you can check this by testing for success right after the rget command), you would compare it to your comparison string using the strcmp command. If you look at the discussion of the ltimestrs command in the ASPECT help file, there is an example that shows how to get the current date and time into two strings. You would then use the strcat command (twice, actually) to append the date and time to your string. The fputs command will place the current string you are working with into your file, and fclose is used to close the file when you are done.

If you take a look at the different commands in the ASPECT help file, most of them will contain examples that should give you a good idea how to use the command. If you have any questions, just shout.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top