问题
Is there an easy way to take what I write to the write window and log it to a file? Or do I need to separately create an array of chars manually and open a file to write the char[] to? I would love to be able to write to file using regular expressions at the very least but I'm not finding much helpful info from the docs.
回答1:
Looks like writeToLogEx(char format[], ...) can do what I want but it outputs to a Logging Block in the measurement setup. So I'll have some header and footer data that I don't want as well as CAN traffic if I don't put up a channel block.
Vector's Example:
char timeBuffer[64];
getLocalTimeString(timeBuffer);
writeToLogEx("===> %s",timeBuffer);
Regular Expression Options:
"%ld","%d" decimal display
"%lx","%x" hexadecimal display
"%lX","%X" hexadecimal display (upper case)
"%lu","%u" unsigned display
"%lo","%o" octal display
"%s" display a string
"%g","%lf" floating point display
"%c" display a character
"%%" display %-character
"%I64d" decimal display of a 64 bit value
"%I64x" hexadecimal display of a 64 bit value
"%I64X" hexadecimal display of a 64 bit value (upper case)
"%I64u" unsigned display of a 64 bit value
来源:https://stackoverflow.com/questions/25204029/log-write-output-to-file-in-capl