From 50e49287249e7d57889790ee1af8c8b3d2703982 Mon Sep 17 00:00:00 2001 From: Ralph Ronnquist Date: Sun, 2 Jun 2024 18:00:49 +1000 Subject: [PATCH] added usbreset.lsp --- usbreset.lsp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 usbreset.lsp diff --git a/usbreset.lsp b/usbreset.lsp new file mode 100644 index 0000000..975c4fc --- /dev/null +++ b/usbreset.lsp @@ -0,0 +1,24 @@ +#!/usr/bin/newlisp + +# libc6 library +(constant 'LIB "/lib/x86_64-linux-gnu/libc.so.6") + +(import LIB "ioctl" "int" + "int" ; fd + "unsigned long" ; request + "void*" ; data [optional] + ) + +(constant + 'USBDEVFS_RESET 21780 ; _IO('U', 20) + ) + +(define (die) + (write-line 2 (join (map string (args)) " ")) + (exit 0)) + +(unless (setf FD (open (main-args -1) "write")) + (die "cannot open" (main-args -1))) + +(println (ioctl FD USBDEVFS_RESET 0)) +(exit 0) -- 2.39.2