CLI tool for USB only

By the way, I know it's not that simple, but have you thought about developing a command-line version of IO Ninja for just USB?

I'd absolutely love to have a simple command line tool to which I can give parameters or have it read from a file to send USB packets to a device or read from it, pipe its output to other scripts or pipe output into it from other scripts, etc.

Basically, again a wrapper around libusb.

I don't need a TUI or anything like that. Cli would be enough for me.

So something like: usbninja --vid=1532 --pid=007b --transaction-type=control --data=xxxxxxxxxxxxxxxx

Actually, that would be quite simple to implement, but in my opinion, there's not much point in that. You could achieve the same -- and more! -- by using any scripting language of your choice (Python, Perl, JS, Ruby, etc.) All modern scripting languages have bindings to libusb. By having such a script you:

  1. Wouldn't need to open/close USB device, interface, and endpoint in every command;
  2. Will have a much richer programming environment to organize the logic, control flow, analysis of incoming data, debug-printing, etc. (as compared to shell scripts).

And here we come to an interesting point. The next question you might ask would be -- OK, then what is the advantage of IO Ninja as compared to Python/Ruby/JS/... scripts? And this would be exactly the reason behind creating IO Ninja in the first place! Because many years ago we ourselves started with such testing scripts/programs but then quickly realized that we need a convenient UI for:

  1. Configuring and managing the connection (e.g. choosing from a list of devices, or connecting on a button click);
  2. Generating a log; then browsing and searching through it (in live mode, as it grows);
  3. Preparing outbound packets with a hex-editor (or transmitting raw files).

So essentially, when you have a simple testing program and then start adding those features to it, you start developing your own IO Ninja!

Just to clarify: When I say CLI, I don't mean I want it in Bash or any other Shell script. In-fact I want it in C, but by CLI I just meant command line interface, or in other words, that I don't want a TUI/terminal user interface like an ncurses application/application using ncurses, I want to pass commands to it.

Right, but you would use such a program from a bash script, correct?

Instead, I suggest using a scripting language like Python or JS and talking to a USB device via libusb directly, without calling a dedicated CLI program that provides a CLI-style API to do the same.

Reason 1 -- bash is much less expressive than most other general-purpose scripting languages.
Reason 2 -- having a CLI-style API means that in every call we need to open the device, interface, and endpoint, then do the USB transfer, then close everything. Then re-open everything on the next CLI API call, and so on.
Reason 3 -- we would basically be reinventing the wheel by providing a CLI-style API over an already established libusb API
Reason 4 -- CLI API is not very suitable for passing binary blocks back and forth

Hope all this makes sense. Is there any reason why not using a general-purpose scripting language for such a task?

I would actually use it directly most of the time, not that your points aren't valid. I guess a middle ground can be a TUI. If done well/enough Vim-like it would be even better.

As for the scripting languages, while I do plan to utilize them at a further point in time, I have been a PHP developer most of the time and any libusb wrappers there are, don't work with the latest version or fail during compilation. I am currently learning C, but don't know it well enough to use libusb directly. Perl and Python are a bit further down on my list for languages to learn.

Also, not that there aren't any other viable (maybe even better) alternatives than CLI for libusb. My reason for requesting a clip USB application in particular is mostly because I just want to do it via the terminal 😄 I requested cli as opposed to TUI as it is more versatile and depending on how the TUI is done, it may not be to everyone's taste. Not that I'd mind having either one or both 😄

If you were programming in PHP then try Node JS. A familiar C-family syntax, a reliable and fast scripting engine from Google, established module/package infrastructure, and huge community (you can basically program by copy-pasting from Stack Overflow). There are (of course) libusb bindings (npm install usb), and even a specialized module for HID (npm install node-hid)

const usb = require("usb");

const list = usb.getDeviceList();
console.log("attached USB devices:", list);

Also, a good point re TUI. A terminal version of IO Ninja (a TUI via ncurses) is actually something we plan to do at one point, but it's not going to happen in the near future 😞