For anyone who owns (or is considering buying) one of Saleae’s amazing Logic USB analyzers, I have a special treat for you. I finally broke down last week and bought the 8-channel one, which is absolutely without a doubt worth every penny of the $149 it costs new—though I managed to pick up a pre-owned but basically new one from eBay for $129. I’ve been trying to get more devices into my I2C Device Library project, and part of that effort has required some very low-level troubleshooting (namely the Azoteq IQS158). I have a Bus Pirate and an OpenBench Logic Sniffer, but these both have their shortcomings when it comes to high-speed or long-duration protocol sniffing. They are just a little under-powered, and the UI leaves something to be desired in both cases.
Enter the Saleae Logic analyzer, which has an impressive buffer and a simple, intuitive UI that is a downright pleasure to use. It’s fantastic.
But if you’re reading this, you probably already know that stuff, so I’ll get on with it. Anyway, the one reservation I had about buying the Logic was that it’s a snapshot-based device, like the OpenBench device. That is, you have to connect everything up, then record the logic levels for a predetermined length of time. Click start, do your stuff, then go back and look at the data when you’re done. Don’t get me wrong; this approach is great (and preferable) for many kinds of analysis. But I wanted something more like you can get with the $300 TotalPhase Beagle, a specialized I2C/SPI sniffer. Specifically, I wanted a live I2C capture solution like theirs.
So I wrote one this evening.
Seriously. Saleae has created a really simple low-level SDK which allows for direct device access over USB. Cross-platform, too, though I’ve only done a Windows-based test solution so far. I was amazed at how simple it was to accomplish. I don’t know if it’s a flawless implementation—as far as it goes, which isn’t very far—but initial tests are very, very promising.
Here’s what the test output looks like:
Yes, it’s console-based. Ignore that for the moment (unless you prefer console stuff, in which case, pretend it’s the finished product!).
This little app just sits there reading live data from a connected Logic device and analyzing it in real time. It’s pulling data from the Logic at 8MHz, and while it keeps the CPU really busy, it uses virtually no memory because it trashes each block of analyzed data from the device as soon as it finished the analysis. The only memory it ties up is the analyzed and decoded protocol info. It’s running in the background as I write this, snarfing a whole three megabytes of RAM.
The output is formatted in the way most people care to read I2C communications: device address, register address, read/write, data length, and actual data. All that remains is to give it a prettier interface, allow you to start/stop capture mode, and filter/search live or stored transmissions.
I’d love to connect it to the I2Cdevlib internal device database as well. That would be the ultimate in convenience and utility. Source is available by request only for the moment, since it’s pretty ugly and I’m picky about publishing ugly code. It will end up on GitHub though after I get it a little cleaner. The important part of the code should theoretically be able to be swapped into a Mac or Linux environment as long as you follow their SDK setup instructions. All the live analysis code is in the single main ConsoleDemo.cpp file.