When using an Arduino, at least once you’ve made it past blinking LEDs, you might start making use of the serial connection to send and receive information from the microcontroller. Communicating with the board while it’s interacting with its environment is a crucial way to get information in real-time. Usually, that’s as far as it goes, but [Pieter] wanted to take it a step farther than that with his command line interpreter (CLI) for the Arduino.
The CLI allows the user to run Unix-like commands directly on the Arduino. This means control of GPIO and the rest of the features of the microcontroller via command line. The CLI communicates between the microcontroller and the ANSI/VT100 terminal emulator of your choosing on your computer, enabling a wealth of new methods of interacting with an Arduino.
The CLI requires a hex file to be loaded onto the Arduino that you can find at a separate site, also maintained by [Pieter]. Once that’s running, you can get all of that sweet command line goodness out of your Arduino. [Pieter] also has some examples on his project page, as well as the complete how-to to get this all set up and running. There’s a lot going on in the command line world, in Linux as well as windows. So there’s plenty to explore there as well.
This is really cool – turn the Arduino into a regular Swiss Army Knife! GPIO, ADC, I2C and SPI. Much easier than writing a one-off application to do something.
I wondered for a minute what would be the use of this, but yes it‘d probably helpful for „low,level“ testing i2c/spi devices, among other things.
Really nice. Any chance it would work for other Arduino boards though? Some of the newer ATSAMD51 boards would really benefit from something like this.
You just reinvented the Bus Pirate. :)
Yes, that’s a what I was thinking; it’s just like a bus pirate, but without having to buy a separate bus pirate board…. and without having to keep the manual open in another window to decipher the UI.
Altogether, probably a lot better than a bus pirate.
Wasn’t there TUI w/ Firmata?
Yes. I don’t know what this tool offers that hadn’t exist before
Needless to say, this would be even cooler for an ESP* to offer network testing and Spiffs access :-)
It is open source, so maybe you should fork it and create that, if it is something that you want.
I thought about it, but the programming style is so much better than mine I’d have to put in a lot of refucktoring work to make the code compatible with my Arduino-C++ gibberish. ;-)
Might be worth the effort, then, just to help you clean up your style. Just sayin’.
I was not entirely serious. But the code is quite well written. Still, porting it to run on ESP* boards would be a lot of work and I have enough projects lying around half finished, so…
I mean, this may end up as a part of the diagnostic code for the esp8266 based IoT sensors my work uses…
It just so happens that I’m doing exactly that, except I’m using a language called Squirrel. I don’t have UNIX style commands, but I have a REPL for things like pinMode(HIGH); I tried to keep close to the Arduino API as much as is practical in Squirrel. I’ve got SPIFFS working, I have multithreading support, an API to add new commands, and to accept callbacks(In a way that either the Squirrel or the Arduino code can cancel a callback), and I even have some M5Stack LCD routines.
Now I’m working on python code to let you include Squirrel code as a home automation script on a server that gets automatically loaded, with shared variables and Pysquirrel messaging, as part of the Kaithem for Devices project.
https://github.com/EternityForest/Acorns
The ESP does have a command line interface using linenoise and arg3table library provided within the esp-idf framework. https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/console.html
Here is a sample line from an ESP32 project f mine that allows me to test latency by the ping interface:
ESP32 test console>ping -n 8.8.8.8 -c 10 -t 1 -d 1
Run ICMP ping test
-n 8.8.8.8 specify ipV4 ip address in dot notation
-c 10 specify ping count per analysis
-t 1 specify timeout in seconds as an integer
-d 1 specify delay in seconds as an integer
Isn’t this just a subset of the buspirate funtionality?
I was thinking exactly that. And then pondering isn’t there 512 bytes of eeprom in the Arduino Uno ?
2k eprom, 2k ram, 32k flash
The current official Arduino Uno Rev 3 has 1K of EEPROM, I must have been thinking of an older revision – https://www.arduino.cc/en/products.compare
Which Atmel AVR has 2K of EEPROM ?
I wish somebody would make an interactive command line interface for the FT232H, which offers a lot of the same functionality as this.
Yeah yeah yeah I should do it myself I know.
Adafruit Python GPIO library
To make using the FT232H simpler, Adafruit’s Python GPIO library has been updated to include a simple interface for accessing GPIO, SPI, and I2C on the FT232H with the Python programming language. Using this library you can control the GPIO pins and send or received SPI & I2C commands much like programming those interfaces on a Raspberry Pi or BeagleBone Black. This library is built on top of the libFTDI library and supports Windows, Mac OSX, and Linux platforms.
https://learn.adafruit.com/adafruit-ft232h-breakout/mpsse-setup
Well, there’s also micropython. It needs a beefier micro, but runs at least on an Arduino Due.
And on ESP8266/32, of course.
Last time I looked they hadn’t got bluetooth working on the ESP32 with micropython. If they get that working, I might be tempted.
> Unix-like commands
Why not DOSlike?
Is every CLI seen as UNIXlike today?
And tagging this with “unix” is a huge overkill!
Why DOS(1981), why not CP/M(1974) ?
The reason is that the CLI is strongly associated with UNIX(1973).
Actually UNIX probably started back in 1969 internally in Bell.
Such a bizarre question. I mean, perhaps your personal experience to a CLI is limited to DOS, but it was not the first CLI and nowhere near the most popular/common. So why would anyone call it “DOS-Like”?
Though I’ll admit a Unix tag on this particular post is not really appropriate.
I think the point was that every command line is instantly branded “unix like” even though it got nothing to do with it … there were command line interpeters before unix, and after, unless its doing “unix like” functions its just a command line
Yes! The Unix tag doesn’t make sense here, but I came here because it. I have commented about NuttX that is in fact a sort of Unix/Linux for MCU and way smaller than uClinux and even RetroBSD.
MS-DOS was written by people who kinda’ sorta’ wanted to implement something like a Unix command interface.
And same goes for CP/M.
MS-DOS was based on a CP/M clone called 86-DOS. CP/M was patterned on TOPS-10 and earlier DEC operating systems.
Does indeed look like a bus pirate spinoff. Also a similar project I stumbled upon a long time ago for the usb capable AVR chips is the bus ninja: https://github.com/tobyjaffey/bus-ninja
I really liked the idea but haven’t gotten around actually using it .
I expect there’s more people out there with Arduinos in their desk drawers than Bus Pirates, so this project would seem pretty attractive. It looks like a great way to understand and troubleshoot interfaces before incorporating a new device into a project.
Bus-Ninja. You beat me, that’s what I cam to say. So.. I’ll second that.
It’s always great too see innovative development tools but I prefer Forth for its endlessly versatile real time debugging. Here is a screen-pic of my Forth STM32F development system displaying a nicely formatted and labeled view of the RCC_AHBENR register bit values. I can view a similar default (without the unique register names) picture of any of the thousands of registers via a cmsis-svd to Forth parser for Mecrisp-Stellaris Forth I wrote a few years ago.
http://www.hightechdoc.net/misc/forth-stm32-rcc.jpg
Share please?
man… if only i could read from my stm32f chips. that would be a dream come true
Why not uLisp?
There is a real Unix-like RTOS for Arduino (Mega or better) and many other STM32 boards, Kinetis Boards, SAM3/4 and SAMV7 boards, Particle Photon board and initial port to ESP32 without WiFi, it is called NuttX RTOS.
It has something similar i2ctools from Linux, then you search for I2C devices on bus, read/write devices, etc.
Recently Greg Nutt ported the SPIFFS to it, but I still using SmartFS because I think it has better wear-leveling support. It is worth trying if you are a Unix / Linux Guy.
I wrote CLI source code generator for cases like this. It could be useful for custom commands:
http://e.pavlin.si/2016/06/20/source-code-generator-for-command-line-interpreter-cli/
interesting.. I wished something like this some years ago and created a helper library to accept commands
“`
…
if (MyCommander.is(“surrender”) && MyCommander.confirm(F(“Are you sure?”)) {
// do something
}
…
“`
https://github.com/cristianszwarc/SerialCommander
Just use Atmel studio with Atmel ICE and you get an advanced editor and full debugging control.
A clusterfuck of bloated framework and random crashes included free of charge.
Hahah, try STMs free Eclipse Java based Atollic TrueStudio with Cube MX. I hear it will run on a low end 24 core Xeon with only 3TB of ram, with system reboots now down to only one a day!
Disclaimer, I’m a utterly loyal and addicted STM32F fan.
Lots of these out there, mine from almost 7 years ago. Worked well in dumping flash from dongles. ;-)
https://github.com/CrashSerious/dump-ninja
I should also add, “mine” is loose. I forget the changes I made, but it was a bus-ninja close when I started with it.
To everyone, thanks for all the kind words! This open source project has been a work of love for more than a decade and it is great motivational fuel when people indicate that they like it and that it matters. Who says there’s no such thing as “free energy” :)
For the record, the CLI was inspired by u-boot and OpenOCD. I started to create it after needing a way to probe and debug a test fixture (a.k.a. a “bed-of-nails”). I needed an easy way to set a GPIO pin and probe the result on the DUT (Device Under Test) to locate the fault, without trying to debug someone else’s firmware or software too.
Hi Pieter,
Now you have assimilated the required knowledge, your project could grow into anything :)
The beauty of Open Source tools like OPenOCD!
I’m using a ‘tethered Forth’ named Mecrisp-Across (designed by Matthias Koch) atm which controls a virgin MSP430 mcu over a 3 wire JTAG umbilical. The Forth is hosted on a TM4C1294 Tiva Connected Launchpad which cross-compiles on the fly for the MSP430. To me it looks like my terminal is connected to the MSP430 target as the target response has no lag.
I must say that back in the early 80’s we had nothing like these tools, and a simple cross compiler for the Motorola HC11 cost me around $150USD, ran on DOS and you didn’t get the source.
Back in the early 70’s we had TTL, and in the early 60’s ? … valves and germanium semis that cost a arm and a leg.
I know, I was there.
Cheers,
Terry
Terry
Nice!!
The code quality in the repo has to be seen to be believed. CS graduate school in a link …
Cool GIF animation )