Archive for category PD Software

Making Pythons sqlite3 import easy as 1 2 3

Lurking within the normal Python 2.x distribution is the sqlite3 import, which is an amazingly powerful, mostly SQL compatible database engine that can be used in any project without restriction.

That’s the up side. The down side is, as a fairly complete database, there are many options and varied ways it can be used, and managing actual database transactions isn’t all that simple — to do it right, even a single query takes about sixteen lines of code. And yes, if you want maximum flexibility and the ability to use every feature in sqlite3, that’s how you should do it.

But. Most database operations are very straightforward. You want to issue a single command to the database, or a query. Perhaps you want to write a bunch of data and then commit it all at once so that the database doesn’t contain part of the data from a more complex transaction. Those are by far the most common use cases for me, and I suspect that’s true for others as well.
Read the rest of this entry »

Tags: , , , , , ,

Catching ALL exceptions in Python

When working with Python, sometimes, more than anything else, you need to know what went wrong. Quite aside from all the debate about what you should do in response, and particularly when developing, you need more than just a vague idea that your CGI bailed and that there might (or might not) be some usable indication of this in the system web logs.

Even when working in a pure command line context, you may need to catch anything and everything. If you do, the following gives you a basic model of just how to do it.

import sys try: a = 5 / 0 except Exception,e: # the Exception class provides messages print 'Exception caught, message: '+str(e) raise SystemExit # bail out (optional) except: # other exceptions e = sys.exc_info() # so we mine sys library info instead print 'Non-Exception class Exception caught, message: '+str(e) raise SystemExit # bail out (optional) else: # and, well, sometimes things work out. print 'it worked, no exception!' # whoo hoo... finally: # always happens print 'Glad THAT ordeal is over -- one way or another.' print 'And here we are. Aren't we?' # you only get here if things worked out

Try out the above with code you know will work, like a=1 immediately subordinate to the try: clause, and then with code you know won’t work, like a=5/0 and see what it does.

Hope someone finds that useful. Took me a while to dig through it all and wrap my head around even the basic idea that sometimes, you just need to know!

Tags: , , , , ,

New OSX and Windows version of SdrDx – 2.08

SdrDx 2.08 supercedes the UDP interface in 2.07 (UDP still present in case you’ve coded for it) with a TCP server interface that is capable of supporting multiple clients. It turns out there’s a rather serious bug in OSX that prevents UDP connections from being opened with more than one client, so TCP is better for now.

As with the UDP interface, I’ve included a basic TCP client example written in Python.

In addition, beginning with SdrDx 2.08, the program will let you know if and when upgrades are available to you in the program’s title bar, as long as you have an Internet connection when you start it.

The TCP interface now has many additional commands as compared to the previous version’s UDP command set, and so far we’ve got an alpha version of an iPad client that displays waterfall, spectrum, demod envelope, allows tuning and other control, and plays back audio — all using the new TCP interface. In addition, during the beta period, tuning control for a screwdriver antenna was implemented using the TCP interface and Python.

I have a multi-VFO (26 of them, A-Z) application I’ve made available (OSX only so far) that works with the new TCP interface as well, giving you copious radio-like VFO control over SdrDx. Each VFO remembers frequency and all related display settings, so you can frequency hop like a little radio bunny. (cough) Sorry. :)

SdrDx 2.08 provides for frequency offset, which in turn allows it to be used more easily with up-converters such as those that might be part of a FUNcube installation.

There are various other changes, mostly small tweaks and bugfixes. Enjoy!

Screen shot:

Tags: , , , , , , , , , , , ,

Online Docs for SdrDx

I am pleased to introduce online documentation for SdrDx. This marks a sea change, where we move from a text file, buried in the distribution, to a system where everyone is looking at the same document, one that is easier to read, to look at and in general to deal with. It includes a table of contents, an index, visual cues for user interface elements and so on.

The link is on the SdrDx page, and the next release of SdrDx will take you there directly.

Comments and corrections are welcome, of course.

Tags: , , , , ,

New version of SdrDx – 2.00

Please see this post for details on SdrDx 2.00.

Tags: , , , , ,

New Version of SdrDx (Mac / OS X version of CuteSDR)

Please see this post for the latest details on v1.07.

Tags: , , , ,

SdrDx –OS X and Windows SDR Software

SdrDx2.13gI’ve been working on developing OSX/Mac and Windows versions of SdrDx. At this time, SdrDx for OSX and Windows supports RFSPACE, FunCube Pro, Andrus MK1.5, AFEDRI, FunCube Pro Plus, Peaberry, and Softrock SDR receivers.

In addition, SdrDx can be made to support any SDR with a sound card interface, including I/Q input via your native or auxiliary sound card, with a little scripting work; the Peaberry and Softrock support demonstrate this mechanism using Python.

SdrDx (running on the Mac) is shown to the right. SdrDx is a closed-source, free application.

SdrDx, in combination with your SDR, is an extremely powerful receiver. Reception, recording, playback, analysis, processing — it’s all there, and it’s all been made as easy to use as possible. Extensive documentation covers every aspect of operating the software, as well as providing numerous examples and images to help you along. If you’re an expert radio user, you’re sure to settle right in. If you’re still learning, you can look forward to software that lets your capabilities grow with your knowledge.

SDR-IQ users only: You can download the executable application(s) appropriate to your OS (OSX or Windows) and the SDR-IQ TCP server for your OS (if you have an SDR-IQ and don’t already have a server) below. Remember, you MUST have a network server application installed to support the SDR-IQ. These are available in the list of downloads below. Other SDR types do not require a server application.

The main application zip file will un-compress to a folder, inside which you will find the SdrDx application, and some other files. Please read the documentation carefully. Use the extensive index. If you can’t find something in there, please let me know. I try very hard to keep the documentation up to date. It’s no trouble at all to add index entries, and generally speaking, I’m willing to expand the docs if you find something I have not covered yet.

The VFO Suite application is an accessory for SdrDx that provides many independent VFOs that each track frequency, mode, waterfall and spectrum state, and more. Each VFO may optionally be limited so that it will not track outside a band, so you can, for instance, set up a VFO that lets you tune the 20m amateur band, but not outside it. VFO Suite connects to SdrDx via TCP, so it can run on any machine with a TCP connection to the machine running SdrDx, including, of course, on the same machine.

Note to PC users: Run SdrDx and VFO Suite out of the folders I supply them in. Don’t stick the executables somewhere else. That way lies madness. MaDnEsS!

Current Version and related downloads


Please refer to this page for the release version documentation.

System Requirements

SdrDx for the Mac requires an Intel CPU, running Leopard 10.5.8 or later.

So far, I have numerous third-party reports of SdrDx working under 10.5, 10.6, 10.7, 10.8, and 10.9.

There are two tricks required for 10.9, first, you need to turn the “App Nap” feature off or when SdrDx is not the front window, OSX will put it to sleep, which will break it. Right click on the SdrDx app, select “info”, turn off App Nap, and close the info window. If you’ve got an SDR-IQ where the server runs under 10.9, you’ll need to do the same thing to the server application. Note: I suggest the very first thing you do with any application you install is turn off App Nap — it’s one of Apple’s worst ideas ever. That’s all there is to that.

Also under 10.9 for users of the SDR-IQ, Apple thoroughly broke the USB driver. In order to use the USB driver in the server application instead (so the USB to Net server will work), you need to enter the following in a shell right after you boot your machine…

sudo kextunload -b

…it’s not sticky, so you’ll have to do this any time you reboot your Mac.

I suspect that the above tips apply under 10.10, though I have no feedback on that as yet (November 22nd, 2014)

And of course SdrDx requires an SDR as well if you want to receive live, although it can play back pre-recorded files without an SDR; in the specific case of the SDR-IQ, you’ll need a server application that puts the SDR-IQ on the network. SdrDx’s support of RFSPACE SDRs is only via network connections, it does not directly interface with the USB connection of the SDR-IQ.

For the Mac, I am presently designing and testing and compiling under OS X 10.6.8 (Snow Leopard.)

SdrDx Beta for the PC requires an Intel CPU, running Windows XP or (possibly) a later version of the OS. It requires an RFSPACE SDR, AFEDRI, Andrus MK1.5, FUNcube Dongle, Soundcard-based SDR, or pre-recorded RF files as well; in the specific case of the SDR-IQ, you’ll need a server application that puts the SDR-IQ on the network. SdrDx handles the RFSPACE SDRs via the network, it does not directly interface with them via USB.

For Windows, I am presently designing, testing, and compiling under Windows XP (in a VM.)

Tags: , , , , , , , ,

Python, TkInter, OSX (OS X) and making it all behave

I use Python a lot. Python 2.5.1 to be specific. And inside Python is TkInter, which, with a little work, will give you a handy way to put a GUI together. But there are problems. To say that TkInter is poorly supported and poorly documented under OSX is to understate the case rather dramatically. So you’re left to Google for answers, and mostly, they aren’t to be found — or if they are, they aren’t obvious or easily found. So I’m going to provide some answers here that have taken me quite some time to collect, and hopefully keyword and title them so that a Google search will actually get you to the solution you need sooner rather than as much later as it did me!
Read the rest of this entry »

Tags: , , , , , , , , , , , , , , , , , , , ,