Redirect output from any command to file
-
Starting with firmware 3.4 the output from an echo command can be redirected to a file.
Is it possible to redirect output from any command to file or get last output from object model?E.g. I write code to get state of TMC registers and want to save result to file.
var driver_number=0 ; Driver number var register_start=0 ; Start (0 ... 127) var register_end=127 ; Finish (0 ... 127 G4 S3 if (var.register_end<=127) & (var.register_start>=0) & (var.register_end>=var.register_start) var counter=var.register_start while var.counter<=var.register_end M569.2 P{var.driver_number} R{var.counter} set var.counter=var.counter+1 G4 P200
-
Assuming you can get the info from the object model..,
You can useecho >"myFile.txt"
to create the file and then
echo >>"myFile.txt" "Register",iterations, "=", myVariable
To append to it.
Put the former before your loop and the latter inside it -
@demonlibra
If you can't get the data from the object model, perhaps try loggingM929 P"testfile.txt" S3 while iterations < 10 M913 M929 S0
-
@owend Loging work fine. Thank you.
var counter=var.register_start M929 P"tmcregisters.txt" S3 while var.counter<=var.register_end M569.2 P{var.driver_number} R{var.counter} set var.counter=var.counter+1 G4 P200 M929 S0
2022-06-12 10:00:12 [info] Event logging started at level debug 2022-06-12 10:00:12 [info] Running: Duet 3 Mini5plus WiFi: 3.4.1rc1 (2022-05-03 09:34:52) 2022-06-12 10:00:12 [debug] Register 0x00 value 0x000001c0 2022-06-12 10:00:12 [debug] Register 0x01 value 0x00000001 2022-06-12 10:00:13 [debug] Register 0x02 value 0x0000000a 2022-06-12 10:00:13 [debug] Register 0x03 value 0x00000000 2022-06-12 10:00:13 [debug] Register 0x04 value 0x00000000 2022-06-12 10:00:14 [debug] Register 0x05 value 0x0000000e 2022-06-12 10:00:14 [debug] Register 0x06 value 0x21000040 2022-06-12 10:00:14 [debug] Register 0x07 value 0x0000000e 2022-06-12 10:00:15 [debug] Register 0x08 value 0x00000000 2022-06-12 10:00:15 [debug] Register 0x09 value 0x00000000 2022-06-12 10:00:15 [debug] Register 0x0a value 0x00000000 2022-06-12 10:00:15 [info] Event logging stopped