added usbreset.lsp master
authorRalph Ronnquist <rrq@rrq.au>
Sun, 2 Jun 2024 08:00:49 +0000 (18:00 +1000)
committerRalph Ronnquist <rrq@rrq.au>
Sun, 2 Jun 2024 08:00:49 +0000 (18:00 +1000)
usbreset.lsp [new file with mode: 0644]

diff --git a/usbreset.lsp b/usbreset.lsp
new file mode 100644 (file)
index 0000000..975c4fc
--- /dev/null
@@ -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)