From: Ralph Ronnquist Date: Sun, 2 Jun 2024 08:00:49 +0000 (+1000) Subject: added usbreset.lsp X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;ds=inline;p=rrq%2Fnewlisp-ftw.git added 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)