aBoomest 0 October 12, 2022 Posted October 12, 2022 · Report post Добрый день. Начал сегодня знакомиться с макросами C-SPY IAR. Нужно сохранить некие данные из памяти МК в файл. В принципе практически на 90% представляю что и как нужно, с т.з. написания макроса расстановки брейкпоинтов и т.п. Вопрс принципиальный в том, что у меня даные в основной программе - это строка длиной 100. (char[100]) В принципе надо просто ее "слить" в файл. Как макрос "увидит" переменную основного проекта? Как осуществить доступ макросу к этой переменной? Вот это не доконца понимаю. С уважением. Quote Share this post Link to post Share on other sites More sharing options...
k155la3 27 October 12, 2022 Posted October 12, 2022 · Report post s C-SPY macros to save and restore memory and registers Additional macros There is an additional example with macros where you can specify the name of the file, i.e. no need to update the macro source. Example of a command to enter in the QuickWatch command line to dump the contents of a variable in a binary format: DumpMem("dumpmem.bin", &trace_buffer, sizeof(trace_buffer)) Example of a command to enter in the QuickWatch command line to dump the contents of ARM registers in a readable format: DumpReg("dumpreg.txt") https://www.iar.com/knowledge/support/technical-notes/debugger/c-spy-macros-to-save--restore-memory-and-registers/ попробуйте так, вообще эти макросы для IAR платформо-отладчиково-зависимы Спойлер // Example of command to enter in QuickWatch command line: // DumpInt16("dumpint16.txt", &trace_buffer, sizeof(trace_buffer)) DumpInt16(aFileName, aAddress, aSize) { __var fileHandle; __var memoryByte; __message "--- macro DumpMem(file: ", aFileName, ", address: 0x", aAddress:%X, ", size: ", aSize:%d, ")"; fileHandle = __openFile(aFileName, "wb"); if (fileHandle) { while ((int)aSize > 0) { memoryByte = __readMemory16((int)aAddress, "Memory"); __fmessage fileHandle, " ", memoryByte, "\n"; aAddress = (int)aAddress + 2; aSize = (int)aSize - 2; } } else { __message "*** Could not open file '", aFileName, "'\n"; } __message "--- macro Done"; } Quote Share this post Link to post Share on other sites More sharing options...
aBoomest 0 October 24, 2022 Posted October 24, 2022 · Report post Добрый день. Есть строка char s[100]. 100 - максимальный размер. Нужных символов может быть меньше. Если их меньше, то после нужных даных в конце у нее символы CR LF и далее все \0 до размера 100. В памяти именно так. делаю __var MStr; MStr = __toString(str,100); __fmessage FileHandle,MStr; где FileHandle - файл (результат операции __openFile() ) В результате в принципе все нормально, "читабельно", но появляется везде в конце лишний символ. В итоге имеем в файле не CR LF, как было изначально, а CR CR LF. 1. Можно ли как-то отлаживать макросы? 2. какая из двух функций добавляет символ в строчку? Quote Share this post Link to post Share on other sites More sharing options...