Skip to content

Tentative implementation using golang and CGO bindings #13

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

Merged
merged 12 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ compile.sh
dfu-util-*/*
dfu-discovery
*.o
dfu-util_*.c
14 changes: 6 additions & 8 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ then
else
echo "Downloading $DFU_UTIL..."
curl https://dfu-util.sourceforge.net/releases/$DFU_UTIL.tar.gz -s | tar xz
fi

DEFINES="-DHAVE_UNISTD_H -DHAVE_NANOSLEEP"
INCLUDES="-I. -Idfu-util-0.11/src -I/usr/include/libusb-1.0"
gcc -c dfu-util-0.11/src/dfuse_mem.c $INCLUDES $DEFINES
gcc -c dfu-util-0.11/src/dfu_util.c $INCLUDES $DEFINES
gcc -c dfu-util-0.11/src/quirks.c $INCLUDES $DEFINES
g++ -c main.cpp $INCLUDES $DEFINES
g++ dfu_util.o quirks.o dfuse_mem.o main.o -lusb-1.0 -o dfu-discovery
cp dfu-util-0.11/src/dfuse_mem.c dfu-util_dfuse_mem.c
cp dfu-util-0.11/src/dfu_util.c dfu-util_dfu_util.c
cp dfu-util-0.11/src/quirks.c dfu-util_quirks.c
# for some reason quirks.c has the exec flag set
chmod -x dfu-util_quirks.c
fi
20 changes: 20 additions & 0 deletions err.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

/*
// The original macros are defined as follows:
# define warnx(...) do {\
fprintf(stderr, __VA_ARGS__);\
fprintf(stderr, "\n");\ } while (0)
# define warn(...) do {\
fprintf(stderr, "%s: ", strerror(errno));\
warnx(__VA_ARGS__); } while (0)
*/
// No-OP: do not report any warning
# define warnx(...) do { } while(0)
# define warn(...) do { } while(0)

# define errx(eval, ...) do {\
warnx(__VA_ARGS__);\
exit(eval); } while (0)
# define err(eval, ...) do {\
warn(__VA_ARGS__);\
exit(eval); } while (0)
13 changes: 13 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module github.com/arduino/dfu-discovery

go 1.19

require (
github.com/arduino/go-properties-orderedmap v1.7.1
github.com/arduino/pluggable-discovery-protocol-handler/v2 v2.1.1
)

require (
github.com/arduino/go-paths-helper v1.8.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
)
680 changes: 680 additions & 0 deletions go.sum

Large diffs are not rendered by default.

Loading