Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWIG Python wrapper for libavrdude #1714

Merged
merged 160 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 134 commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
4f455c6
First tiny little steps towards a SWIG "hello world"
dl8dtl Mar 3, 2024
d4fe955
Merge remote-tracking branch 'upstream/main' into swig_libavrdude
dl8dtl Mar 3, 2024
d48c944
Update build.yml to use Homebrew python
mcuee Mar 6, 2024
a98d215
Update build.yml to add Python/Swig for MSYS2 build
mcuee Mar 6, 2024
9f6bada
Update build.yml to debug macOS Homebrew CI issue
mcuee Mar 6, 2024
02d3e16
One more try to debug macOS build for SWIG
mcuee Mar 6, 2024
9567f96
Update build.yml to revert previous change
mcuee Mar 6, 2024
377d3f3
Turn PM_* #defines into an enum
dl8dtl Mar 7, 2024
334b8c5
Protect AVRMEM* and AVRPART* typemaps agains NULL pointers
dl8dtl Mar 7, 2024
3f94455
Add PM_* names, and signature search functions
dl8dtl Mar 7, 2024
e10730e
Add some heuristics to find out the Windows build directory
dl8dtl Mar 8, 2024
9be5164
Add prog_modes to AVRPART* wrapper
dl8dtl Mar 8, 2024
cfe608a
Update build.yml to use CMAKE_VERBOSE_MAKEFILE to debug Windows build
mcuee Mar 8, 2024
8c4f3b0
Tweak Windows DLL search paths
dl8dtl Mar 8, 2024
3f5c32b
Fix include directories for SWIG build
dl8dtl Mar 8, 2024
e063bf1
Make path to os.add_dll_directory() absolute
dl8dtl Mar 9, 2024
e986f16
Add PYTHON_LIBRARY to swig_libavrdude linking
mcuee Mar 9, 2024
65bf639
Declare avrdude_message*() in library header file
dl8dtl Mar 10, 2024
fd8704d
Implement avrdude_message2() from main.c
dl8dtl Mar 10, 2024
f9b9593
Replace hand-crafted dicts for AVRMEM and AVRPART by SWIG structs
dl8dtl Mar 12, 2024
d34324c
Add a -v option to build.sh
dl8dtl Mar 12, 2024
1968a11
Combine the various cast_* functions with ldata()
dl8dtl Mar 13, 2024
356693d
Add device variants to example printout
dl8dtl Mar 13, 2024
920b964
Add AVRMEM* buffer handling methods
dl8dtl Mar 15, 2024
c9cee81
Add a typemap to represent the AVRPART signature as Python bytes.
dl8dtl Mar 15, 2024
a3475a6
Implement the heart of struct programmer_t
dl8dtl Mar 15, 2024
1e3dc29
Add more docstrings, clean-up warnings
dl8dtl Mar 15, 2024
5782c18
Update swigtest.py
dl8dtl Mar 15, 2024
68d44ea
Implement Python callback for avrdude_message2()
dl8dtl Mar 18, 2024
296883c
Initialize progress reporting in avr_{read,write}_mem
dl8dtl Mar 18, 2024
858c3f6
Add an update_progress implementation
dl8dtl Mar 18, 2024
984eb92
Remove MSVC build for arm64 by now
dl8dtl Mar 18, 2024
5fd5cff
Use correct index into tuple in message_type()
dl8dtl Mar 19, 2024
fa78ea3
Set the progress and message callbacks by default
dl8dtl Mar 19, 2024
cbfaa9f
Add an argout typemap for read_sib
dl8dtl Mar 19, 2024
1de634f
Make the reporting functions a bit more robust
dl8dtl Mar 19, 2024
0e7a76f
Fix typo: False -> false
dl8dtl Mar 20, 2024
a02994d
Always populate setup and teardown methods of struct programmer_t
dl8dtl Mar 20, 2024
73c8a78
Populate many more methods of struct programmer_t
dl8dtl Mar 20, 2024
b65e9d8
Revert "Initialize progress reporting in avr_{read,write}_mem"
dl8dtl Mar 20, 2024
708403b
Initialize progress reporting for avr_{read,write}_mem
dl8dtl Mar 20, 2024
1ae394f
Assign TAG_ALLOCATED in m->put()
dl8dtl Mar 21, 2024
c6c9aae
Fix offset check in m.get and m.put helpers
dl8dtl Mar 21, 2024
3420772
Add a m.clear() method
dl8dtl Mar 21, 2024
571c742
Add various fileio_* functions
dl8dtl Mar 21, 2024
ed8e4ed
Add a comment about fileio usage
dl8dtl Mar 21, 2024
9c0623b
Start a src/python subdir
dl8dtl Mar 21, 2024
fef4311
First skeleton of a very basic GUI
dl8dtl Mar 23, 2024
e6d2d3f
Implement device selection
dl8dtl Mar 23, 2024
77bcf86
Rename "Device Memories" to "Device Info"
dl8dtl Mar 24, 2024
9b6fb3c
Implement the Device Info popup
dl8dtl Mar 24, 2024
fbea1a7
Fine-tune resizing the device info a bit
dl8dtl Mar 24, 2024
d15672d
Add dialog to change log level
dl8dtl Mar 25, 2024
c2bfc9f
Add tooltips to the radio buttons
dl8dtl Mar 25, 2024
b7d6111
Change the GUI from using uic -g python to directly loading the .ui f…
dl8dtl Mar 25, 2024
5022a36
Turn the log viewer into HTML and color-coded message levels
dl8dtl Mar 25, 2024
28e05c6
Implement programmer selection dialog
dl8dtl Mar 25, 2024
c81f6d7
Add programmer port selection, and starting programmer
dl8dtl Mar 25, 2024
a3d482d
Stop programmer when exiting
dl8dtl Mar 25, 2024
72da4a9
Rename View -> Device
dl8dtl Mar 25, 2024
ce3b9f0
Turn device family selection into a QGroupBox
dl8dtl Mar 25, 2024
c7ab10e
Enlarge the button boxes for programmer and device selection.
dl8dtl Mar 25, 2024
09ece37
First device memory operations: read signature
dl8dtl Mar 25, 2024
2b40588
Add field with possible device after reading signature
dl8dtl Mar 26, 2024
cc371f0
Only start programmer if not already started
dl8dtl Mar 26, 2024
1f22763
Implement progress indication
dl8dtl Mar 26, 2024
7b9acec
Fix progress reporting
dl8dtl Mar 27, 2024
6d1f413
Implement flash reading.
dl8dtl Mar 27, 2024
65226cd
Revert "Turn PM_* #defines into an enum"
dl8dtl Mar 27, 2024
8349f88
Replace PM_* constants enum by #define
dl8dtl Mar 27, 2024
457c21a
Handle abnormal termination in progress_callback
dl8dtl Mar 27, 2024
1e78b8c
Add option to save log file
dl8dtl Mar 27, 2024
dff00a3
Improve logging and \v and newline handling
dl8dtl Mar 28, 2024
471ce04
Fix BOL detection for internal logging
dl8dtl Mar 28, 2024
d42da3d
Merge branch 'fix-1726' into swig_libavrdude
dl8dtl Mar 28, 2024
55acef9
Fix HTML logging
dl8dtl Mar 28, 2024
9aaf864
Move cursor to end of logging area
dl8dtl Mar 28, 2024
ad03989
Make the loglevel radiobuttons automatically accept the popup.
dl8dtl Mar 28, 2024
f091a1d
Only allow access to flash and EEPROM tabs after reading signature
dl8dtl Mar 28, 2024
bc8f008
Do not attempt to add <br> if there is no HTML text
dl8dtl Mar 28, 2024
5b64a79
Implement a config file
dl8dtl Mar 28, 2024
89bd5f3
Merge remote-tracking branch 'upstream/main' into swig_libavrdude
dl8dtl Mar 29, 2024
368b9ff
Fix breakage introduced by previous merge
dl8dtl Mar 29, 2024
896785a
Add copyright, add some more "About" text
dl8dtl Mar 29, 2024
cd79957
Fine-tune handling of flash filename given
dl8dtl Mar 29, 2024
8d2f310
Add an AVR Logo image to the memory tab
dl8dtl Mar 29, 2024
4458a3c
Add saving flash contents to file
dl8dtl Mar 29, 2024
b015fc2
Merge remote-tracking branch 'upstream/main' into swig_libavrdude
dl8dtl Mar 30, 2024
76d5480
Re-add MSG2_LEFT_MARGIN into the enum used in this branch
dl8dtl Mar 30, 2024
e332c4c
When saving flash file, ask whether to overwrite existing file
dl8dtl Mar 30, 2024
f61c4d8
Track flash size when reading from device
dl8dtl Mar 30, 2024
7a52571
Implement chip erase
dl8dtl Mar 30, 2024
33100e1
Add tooltips to buttons
dl8dtl Mar 30, 2024
3ccc199
Add flash_load (from file) and flash_write (to device)
dl8dtl Mar 30, 2024
7f09662
Color-code buffer full/empty
dl8dtl Mar 30, 2024
9bef6b2
Clone flash operations into EEPROM operations
dl8dtl Mar 30, 2024
da37f09
Start adding fuses
dl8dtl Mar 31, 2024
8ec3dd5
Provide explicit attach and detach functionality for programmer
dl8dtl Apr 1, 2024
d215bdc
Populate GUI fuse labels
dl8dtl Apr 1, 2024
8abd91b
Implement fuse reading and editing
dl8dtl Apr 1, 2024
1862b19
Implement fuse programming
dl8dtl Apr 1, 2024
fd8b8bb
Skip empty fuse value fields as well
dl8dtl Apr 2, 2024
86de67f
Implement fuse load and save from/to file
dl8dtl Apr 2, 2024
48bbd4b
Ask for which fuse if needed
dl8dtl Apr 2, 2024
07116d9
Provide access to the fuse/lock bit configuration table
dl8dtl Apr 2, 2024
3cedbee
Make the loglevel popup a modal one.
dl8dtl Apr 3, 2024
b86120c
Add some examples how to deal with that configuration list
dl8dtl Apr 3, 2024
35e1ad8
Arrange the loglevel.ui into a layout
dl8dtl Apr 3, 2024
0a45c8a
Add layout to adgui.ui
dl8dtl Apr 3, 2024
2bd7512
Add layouts to memories.ui
dl8dtl Apr 3, 2024
dafff15
Layout the device info popup
dl8dtl Apr 3, 2024
926a776
Add layouts for device and programmer selection
dl8dtl Apr 3, 2024
dd131bb
Add layout to about.ui
dl8dtl Apr 3, 2024
ccaa3dd
Add layout to askfuse.ui
dl8dtl Apr 3, 2024
2efc371
Fix 'invalid escape sequence' warning
dl8dtl Apr 4, 2024
e03820b
Add default_fuse() helper
dl8dtl Apr 4, 2024
74f5ec3
Add a fuse configuration popup
dl8dtl Apr 4, 2024
306d948
No longer need to use CMAKE_VERBOSE_MAKEFILE
mcuee Apr 5, 2024
69672a8
Handle AVRMEM_ALIAS
dl8dtl Apr 5, 2024
c03480a
Initialize self.pgm and self.dev
dl8dtl Apr 6, 2024
5f3dc74
Handle fuse names of avrX devices
dl8dtl Apr 6, 2024
0be9a88
Add help text
dl8dtl Apr 6, 2024
6fb142d
Mention the % pattern in fuse file names.
dl8dtl Apr 7, 2024
b800d16
Make the AVR logo class-internal data
dl8dtl Apr 7, 2024
b39332d
Probe for both, PySide6 as well as PySide2
dl8dtl Apr 7, 2024
9a8d5c1
Replace PYTHONLIBS by PYTHON3 in CMakeLists.txt
dl8dtl Apr 7, 2024
56246e5
Use correct Python3 CMake variables
dl8dtl Apr 7, 2024
01ed017
If the fuse has an alias name, use that as display name
dl8dtl Apr 7, 2024
aab76b9
First attempt of establishing an installation process
dl8dtl Apr 7, 2024
57bab83
Replace deprecated Python distutils by "site" module.
dl8dtl Apr 7, 2024
e39ad2c
Our probe is actually for SWIG + Python3
dl8dtl Apr 7, 2024
058f900
Enlarge the fuses dialog
dl8dtl Apr 7, 2024
89d959b
Workaround for a quite strange UnicodeDecodeError
dl8dtl Apr 8, 2024
5227dbe
Fix message levels in jtag3_print_data()
dl8dtl Apr 8, 2024
4013eed
Remove modality on help window
dl8dtl Apr 13, 2024
4ab7e19
Merge branch 'main' into swig_libavrdude
dl8dtl Apr 13, 2024
22e4b5b
Add some (exemplary) warnings about dangerous fuse values
dl8dtl Apr 14, 2024
6440aa7
Review comments: stylistic changes in libavrdude.h
dl8dtl Apr 14, 2024
24718e2
s/dangerous/difficult/
dl8dtl Apr 14, 2024
61302b3
Shorten and straighten the help message a bit
dl8dtl Apr 14, 2024
6cb1fb0
log() is a method, so prefix it with self.
dl8dtl Apr 14, 2024
2784f73
Improve device selection
dl8dtl Apr 14, 2024
ec3ecc6
Enlarge the device list
dl8dtl Apr 14, 2024
69267f3
Only enable the device selection OK button of validator is OK
dl8dtl Apr 14, 2024
8ebf2ee
Convert help text to HTML
dl8dtl Apr 15, 2024
1b74b0f
Reduce size of dropdown list to 20
dl8dtl Apr 16, 2024
5d7d073
Improve the device selection list
dl8dtl Apr 16, 2024
8662c68
Add a category "bootloaders" in the programmer selection dialog
dl8dtl Apr 17, 2024
0b93a16
Allow editing the programmer selection combobox
dl8dtl Apr 17, 2024
2026142
Silence Qt warning
dl8dtl Apr 17, 2024
76efcb6
Stylistic change: move inline comments to column 32
dl8dtl Apr 19, 2024
fcfe327
Merge remote-tracking branch 'upstream/main' into swig_libavrdude
dl8dtl Apr 28, 2024
a7eaf6f
Merge remote-tracking branch 'upstream/main' into swig_libavrdude
dl8dtl Aug 10, 2024
c17ccf6
Add init_cx()
dl8dtl Aug 10, 2024
8af5816
Re-initialize AVRDUDE context cx on new programmer connection
dl8dtl Aug 11, 2024
3a9857f
Document how to start the GUI demonstrator
dl8dtl Aug 12, 2024
7b7b3d8
Merge branch 'main' into swig_libavrdude
dl8dtl Aug 12, 2024
d55a790
Turn init_cx() into a libavrdude member
dl8dtl Aug 13, 2024
31a6b48
Document prerequisites for the GUI
dl8dtl Aug 13, 2024
3ca1d7f
Merge branch 'main' into swig_libavrdude
dl8dtl Aug 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ jobs:
include:
- { arch: x86, platform: Win32 }
- { arch: x64, platform: x64 }
- { arch: arm64, platform: ARM64 }
# - { arch: arm64, platform: ARM64 }
steps:
- uses: actions/checkout@v3
- name: Install prerequisites
Expand Down Expand Up @@ -315,6 +315,8 @@ jobs:
base-devel
mingw-w64-${{matrix.env}}-gcc
mingw-w64-${{matrix.env}}-cmake
mingw-w64-${{matrix.env}}-python
mingw-w64-${{matrix.env}}-swig
mingw-w64-${{matrix.env}}-libelf
mingw-w64-${{matrix.env}}-libusb
mingw-w64-${{matrix.env}}-libusb-compat-git
Expand Down
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,18 @@ if(HAVE_LINUXGPIO)
endif()
endif()

# -------------------------------------
# Find SWIG
find_package(SWIG 4.0 COMPONENTS python)
if(SWIG_FOUND)
find_package(Python3 COMPONENTS Interpreter Development)
if(PYTHON3_FOUND)
set(HAVE_SWIG 1)
else()
message(STATUS "Found SWIG but no Python3 header/library; cannot use SWIG")
endif()
endif()

# =====================================
# Use external libraries if requested
# =====================================
Expand Down Expand Up @@ -424,4 +436,10 @@ else()
message(STATUS "DISABLED linuxspi")
endif()

if(HAVE_SWIG)
message(STATUS "DO HAVE swig+Python3")
else()
message(STATUS "DON'T HAVE swig+Python3")
endif()

message(STATUS "----------------------")
15 changes: 11 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ usage()
echo "Syntax: build.sh -h -f <flags> -j <num>"
echo "Options"
echo "-h Display this usage information and exit"
echo "-v Verbose build"
echo "-f <flags> Extra build flags to pass to cmake"
echo "-j <num> Run num build jobs in parallel"
echo
Expand All @@ -40,14 +41,19 @@ ostype=$(uname | tr '[A-Z]' '[a-z]')

build_flags=""
cmake_build="cmake --build ."
verbose=""
jopt=""

while getopts :hf:j: OPT; do
while getopts :hf:j:v OPT; do
case "$OPT" in
f)
build_flags="$OPTARG"
f)
build_flags="$OPTARG"
;;
j)
cmake_build="cmake --build . -- -j$OPTARG";
jopt="-- -j$OPTARG"
;;
v)
verbose="-v"
;;
h | *)
usage
Expand All @@ -57,6 +63,7 @@ while getopts :hf:j: OPT; do
done
shift $((OPTIND-1)) # remove parsed options and args from $@ list

cmake_build="$cmake_build $verbose $jopt"

build_type=RelWithDebInfo
# build_type=Release # no debug info
Expand Down
60 changes: 59 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ if(WIN32 OR MINGW)
"${CMAKE_CURRENT_SOURCE_DIR}/windows.rc.in"
"${CMAKE_CURRENT_BINARY_DIR}/windows.rc"
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/python/adgui.bat.in"
"${CMAKE_CURRENT_BINARY_DIR}/avrdude-gui.bat"
)
else()
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/python/adgui.sh.in"
"${CMAKE_CURRENT_BINARY_DIR}/avrdude-gui"
)
endif()

add_custom_command(
Expand All @@ -150,7 +159,7 @@ add_custom_target(conf ALL DEPENDS avrdude.conf)
# Project
# =====================================

add_library(libavrdude
set(SOURCES
${CMAKE_CURRENT_BINARY_DIR}/ac_cfg.h
arduino.h
arduino.c
Expand Down Expand Up @@ -285,6 +294,10 @@ add_library(libavrdude
${EXTRA_WINDOWS_SOURCES}
)

add_library(libavrdude
${SOURCES}
)

set_target_properties(libavrdude PROPERTIES
PREFIX ""
PUBLIC_HEADER "libavrdude.h;libavrdude-avrintel.h"
Expand Down Expand Up @@ -335,6 +348,37 @@ if(MINGW)
target_link_options(avrdude PRIVATE -static)
endif()

if(HAVE_SWIG)
include (UseSWIG)
swig_add_library(swig_avrdude LANGUAGE Python SOURCES libavrdude.i ${SOURCES})
target_include_directories(swig_avrdude
PUBLIC
"${Python3_INCLUDE_DIRS}"
"${PROJECT_SOURCE_DIR}"
"${PROJECT_BINARY_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}"
"${LIBUSB_COMPAT_DIR}"
${EXTRA_WINDOWS_INCLUDES}
)
target_link_libraries(swig_avrdude
PRIVATE
${LIB_MATH}
${LIB_LIBELF}
${LIB_LIBUSB}
${LIB_LIBUSB_1_0}
${LIB_LIBHID}
${LIB_LIBHIDAPI}
${LIB_LIBFTDI}
${LIB_LIBFTDI1}
${LIB_LIBREADLINE}
${LIB_LIBSERIALPORT}
${LIB_NCURSES}
${LIB_LIBGPIOD}
${Python3_LIBRARIES}
${EXTRA_WINDOWS_LIBRARIES}
)
endif()

# =====================================
# Install
# =====================================
Expand All @@ -349,3 +393,17 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/avrdude.conf" TYPE SYSCONF)
install(FILES "avrdude.1"
DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"
)

if(HAVE_SWIG)
execute_process(COMMAND ${Python3_EXECUTABLE} -c "import site; print(site.getsitepackages()[0])"
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
install(TARGETS swig_avrdude DESTINATION ${PYTHON_SITE_PACKAGES})
install(FILES ${CMAKE_BINARY_DIR}/src/swig_avrdude.py DESTINATION ${PYTHON_SITE_PACKAGES})
install(DIRECTORY python/ DESTINATION ${CMAKE_INSTALL_DATADIR}/avrdude FILES_MATCHING PATTERN "*.ui")
install(DIRECTORY python/ DESTINATION ${CMAKE_INSTALL_DATADIR}/avrdude FILES_MATCHING PATTERN "*.py")
if(WIN32 OR MINGW)
install(PROGRAMS ${CMAKE_BINARY_DIR}/src/avrdude-gui.bat TYPE BIN)
else()
install(PROGRAMS ${CMAKE_BINARY_DIR}/src/avrdude-gui TYPE BIN)
endif()
endif()
19 changes: 0 additions & 19 deletions src/avrdude.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,6 @@ extern const char *pgmid; // Programmer -c string

int avrdude_message2(FILE *fp, int lno, const char *file, const char *func, int msgmode, int msglvl, const char *format, ...);

#define MSG_EXT_ERROR (-3) // OS-type error, no -v option, can be suppressed with -qqqqq
#define MSG_ERROR (-2) // Avrdude error, no -v option, can be suppressed with -qqqq
#define MSG_WARNING (-1) // Warning, no -v option, can be suppressed with -qqq
#define MSG_INFO 0 // Commentary, no -v option, can be suppressed with -qq
#define MSG_NOTICE 1 // Displayed with -v
#define MSG_NOTICE2 2 // Displayed with -vv
#define MSG_DEBUG 3 // Displayed with -vvv
#define MSG_TRACE 4 // Displayed with -vvvv, show trace communication
#define MSG_TRACE2 5 // Displayed with -vvvvv

#define MSG2_PROGNAME 1 // Start by printing progname
#define MSG2_FUNCTION 2 // Print calling function (1st arg) after progname if >= notice
#define MSG2_FILELINE 4 // Print source file and line number after function if >= debug
#define MSG2_TYPE 8 // Print message type after function or progname
#define MSG2_INDENT1 16 // Start by printing indentation of progname+1 blanks
#define MSG2_INDENT2 32 // Start by printing indentation of progname+2 blanks
#define MSG2_FLUSH 64 // Flush before and after printing
#define MSG2_LEFT_MARGIN 128 // Print \n unless last character printed was \n

// Shortcuts
#define msg_ext_error(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, 0, MSG_EXT_ERROR, __VA_ARGS__)
#define msg_error(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, 0, MSG_ERROR, __VA_ARGS__)
Expand Down
8 changes: 4 additions & 4 deletions src/jtag3.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,14 @@ static void jtag3_print_data(unsigned char *b, size_t s)
return;

for (i = 0; i < s; i++) {
msg_info("0x%02x", b[i]);
msg_debug("0x%02x", b[i]);
if (i % 16 == 15)
msg_info("\n");
msg_debug("\n");
else
msg_info(" ");
msg_debug(" ");
}
if (i % 16 != 0)
msg_info("\n");
msg_debug("\n");
}

static void jtag3_prmsg(const PROGRAMMER *pgm, unsigned char *data, size_t len) {
Expand Down
29 changes: 29 additions & 0 deletions src/libavrdude.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,35 @@ typedef uint32_t pinmask_t;
#define LIBAVRDUDE_SOFTFAIL (-3) // returned, eg, by avr_signature() if caller
// might proceed with chip erase

/* Message system */
/* These 2 functions are supposed to be supplied by the application */

int avrdude_message(int msglvl, const char *format, ...);
dl8dtl marked this conversation as resolved.
Show resolved Hide resolved
int avrdude_message2(FILE *fp, int lno, const char *file, const char *func, int msgmode, int msglvl, const char *format, ...);

enum msglvl {
MSG_EXT_ERROR = (-3), // OS-type error, no -v option, can be suppressed with -qqqqq
dl8dtl marked this conversation as resolved.
Show resolved Hide resolved
MSG_ERROR = (-2), // Avrdude error, no -v option, can be suppressed with -qqqq
MSG_WARNING = (-1), // Warning, no -v option, can be suppressed with -qqq
MSG_INFO = 0, // Commentary, no -v option, can be suppressed with -qq
MSG_NOTICE = 1, // Displayed with -v
MSG_NOTICE2 = 2, // Displayed with -vv
MSG_DEBUG = 3, // Displayed with -vvv
MSG_TRACE = 4, // Displayed with -vvvv, show trace communication
MSG_TRACE2 = 5, // Displayed with -vvvvv
};

enum msgmode {
MSG2_PROGNAME = 1, // Start by printing progname
MSG2_FUNCTION = 2, // Print calling function (1st arg) after progname if >= notice
MSG2_FILELINE = 4, // Print source file and line number after function if >= debug
MSG2_TYPE = 8, // Print message type after function or progname
MSG2_INDENT1 = 16, // Start by printing indentation of progname+1 blanks
MSG2_INDENT2 = 32, // Start by printing indentation of progname+2 blanks
MSG2_FLUSH = 64, // Flush before and after printing
MSG2_LEFT_MARGIN = 128, // Print \n unless last character printed was \n
};

/* formerly lists.h */

/*----------------------------------------------------------------------
Expand Down
Loading
Loading