Wednesday, August 28, 2013

bladeRF board talks back (more or less) to a python program

I installed libusb0 (libusb-win32). With inf-wizard I managed to make the bladeRF board visible to Windows. When I connect the device I have a libusb-board called bladeRF!




The problem is, however, that libusb0.sys is a libusb 0.1 implementation.

Well, let's see if can find this device with a Python-program:
I found this snippet on the big Internet. Wish I saved the URL to give credit to the programmer!

#!/usr/bin/env python

import usb

for bus in usb.busses():
  for dev in bus.devices:
    print "Bus %s Device %s: ID %04x:%04x %s" % (bus.dirname,dev.filename,dev.idVendor,dev.idProduct,dev.open().getString(1,30))

The output:

Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>> 
Bus  Device : ID 1d50:6066 Nuand
>>> 

This is encouraging!

From a USB-tutorial I copied:

# import usb.backend
# import usb.legacy
import usb.core
# import usb.util
# import usb.control


# find our device
dev = usb.core.find(idVendor=0x1D50, idProduct=0x6066)

# was it found?
if dev is None:
    raise ValueError('Device not found')
else:
    print ('Device found')

    print 'len =', dev.bLength
    print 'bNumConfigurations =', dev.bNumConfigurations
    print 'bDeviceClass =', dev.bDeviceClass
    num = dev.idVendor
    num = "%#x"%(num)
    print 'idVendor = ', num
    #print 'idVendor = ', dev.idVendor
    num = dev.idProduct
    num = "%#x"%(num)
    print 'idProduct = ', num
    #print 'idProduct = ', dev.idProduct
    print 'bcdUSB = ', dev.bcdUSB
    print 'bcdDevice = ', dev.bcdDevice
    print 'iManufacturer = ', dev.iManufacturer
    
# set the active configuration. With no arguments, the first
# configuration will be the active one
dev.set_configuration()
#dev.set_configuration(0)

And the output:

>>> 
Device found
len = 18
bNumConfigurations = 1
bDeviceClass = 0
idVendor =  0x1d50
idProduct =  0x6066
bcdUSB =  768
bcdDevice =  0
iManufacturer =  1

Traceback (most recent call last):
  File "C:\Users\lonneke\python\bladeRF01.py", line 34, in <module>
    dev.set_configuration()
  File "C:\Python27\lib\site-packages\usb\core.py", line 547, in set_configuration
    self._ctx.managed_set_configuration(self, configuration)
  File "C:\Python27\lib\site-packages\usb\core.py", line 92, in managed_set_configuration
    self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
  File "C:\Python27\lib\site-packages\usb\backend\libusb01.py", line 437, in set_configuration
    _check(_lib.usb_set_configuration(dev_handle, config_value))
  File "C:\Python27\lib\site-packages\usb\backend\libusb01.py", line 384, in _check
    raise USBError(errmsg, ret)
USBError: [Errno None] libusb0-dll:err [set_configuration] could not set config 1: win error: De parameter is onjuist.


>>> 

The problem seems to be that dev.set_configuration() needs an argument.

I think I have a version problem. I have libusb 0.1 on my Windows system.

I googled a lot and found a lot. The right search-arguments are: "libusb pyusb winusb".
In fact WinUSB is what I was looking for.

Then I found zadig:


I experimented with their zadig.exe
I hope I did not do something very stupid!
You can install WinUSB and also libusbK with that program.

My little python-program did not see the bladeRF board anymore. Luckily I could reinstall the old driver and try again.

This libusb 0.1 1.0 issue is very confusing. There is also a libusbK.
I just want to use PyUSB with my bladeRF board and probably need libusb1.0 for that?
I read something about legacy, backend, etc. A lot to study, I am afraid.

Perhaps now is the time to formulate a question in the bladerf forum...


In VilaCha, Portugal, there is a marvelous small pub
where you can drink and eat typical Portuguese food.
We have been there in February, 2013 and surely will return.
If you drive along, you can't miss this pirate!





Sunday, August 25, 2013

BladeRF board finally visible somehow, but I will go for python, libusb, Windows

If you want to connect a USB-device in VMWare to a program running in the OS under VMWare you have to tell VMWare what you want!

So, plug-in your USB-device and window will recognize your USB-plugged-in device. Windows will try to find a driver. The USB-device shows up finally in the list of connected hardware devices, with or without an error-message (a yellowish exclamation point)

Now comes the trick:

Start VMWare with your favorite OS, linux-Ubuntu in my case. Then, in VMWare find the settings for your virtual OS. You will find a list, click USB-devices. There you will see your USB-device. In my case BladeRF. The device is connected to the host. Just say YOU want the device and it will be connected to linux!!! Click again and it will be reconnected to the host!

In my case linux is not aware of the device. It does not show up in /dev, and bladerf-cli does not see the device, not in probe, neither in print. It is still possible that this is simply a linux-problem that I might be able solve with the help of the community.

Now for the bad news:

Of course I searched the internet for this problem and I found out that VMWare has problems with USB3.0 devices!

I found:

"
Now in order to get Intel USB 3.0 Passthrough working with VMware Workstation 9 in Windows 7, make sure that you are running·         VMware Workstation Version 9.0.1 with Build Number 894247 OR HIGHER·         Intel USB 3.0 xHCI Drivers – version 1.0.6.245 OR HIGHERAlso make sure that you have installed Intel USB 3.0 Controller and USB 3.0 Root Hub Drivers using “Device Manager” GUI and NOT USING the installable Binary Package version 1.0.6.245 (SETUP.exe).
"
I did plug the bladeRF-board in a USB 2.0 port and also tried to disable USB3.0 support. I just tried about everything I could think of. But I want genuine USB3-support, not crippled USB2.
Connect bladeRF into a USB3.0 port. In VMWare Player -> removable decices ->  OpenMoko bladeRF -> Connect (disconnect from host)
After a few seconds I see an error message in a box lower-right “The connection for the USB device “OpenMoko bladeRF” was unsuccessful”. Driver error.
I don’t know if this is a message from Ubuntu or VMWare????

Well, the last few days I went for a 'quick' way to play with my bladeRF board. So, I diverted to linux under VMWare. But, I am afraid that is the wrong way.

 If you need a machine to make holes in a wall you need an electric drill. I you want to turn screws in the wall you might buy an electric screwdriver. But DO NOT buy a universal solution because that is always a compromise. Anyway that is what my daddy taught me.

 So now I have to make a choice. Either go for genuine linux (perhaps multiboot or boot from a USB-stick or CD) or go for genuine Windows. I have a spare laptop, I could install genuine linux on that laptop but then I have to take with me (a lot of travelling abroad)  two laptops (one Windows (my wife, you know) and one linux). No, too much hassle. I will go for Windows.


  1. I am used to Windows, my Sony VAIO is powerful enough to run Windows 7 prof.
  2. I still have a lot of space on my harddisk.
  3. Quartos runs perfectly.
  4. The python implementation works flawlessly.
  5. Gnuradio works (almost) perfectly (a problem with OPENGL that I will solve later)
  6. Windows can handle the USB3-port that will be used for the bladeRF
  7. I have some experience with an SDRboarSDR4000 from DSPTools, this board has a very big FPGA that is not supported by the free ISE-WEBPACK-software from Xilinx. I accessed this board with a java-program but my Xilinx-license expired ;>((
  8. Because I am retired, the Mathwork is not longer interested in me, so I cannot use MATLAB anymore (OK, 100 euro I am willing to pay for software for my hobby, but $2000, noway!)
  9. I started to fall in love with Python.
Conclusion:
  1. From now on I will use Python whenever possible (but I will use C, java or whatever is necessary)
  2. I will go for libusb
  3. I will stick to Windows for developing my GPS-sofware for the bladeRF board
  4. I will always have the bladeRF board with me in my laptop-case   ;>)))



This is not me, by the way, but it demonstrates my
feelings about the sofware problems I encounter...





Friday, August 23, 2013

Installing Gnuradio for bladeRF

Tonight I finished the installation of the software.

I managed to get gnuradio installed without any problems.

And it worked, I managed to run my helloworld-gnuradio-program

This program consists of a source (a noise-generator), a throttle and a sink.

I tried to use audio as a sink but that did not work, not any noise.
I tried an FFT and it displayed my noise-source.
I changed the noise source for two signal generators.
One generator with a sine at 400 Hz , the other a sine at 1000 Hz.
I added the two signals into an FFT-display. (yes, with a throttle in between)

That worked fine!!

I got a real-time FFT-display.

If I do exactly the same on Windows ( I installed gnuradio a few weeks before on Windows)
I have a problem with the display. Errors about a circular buffer. If I disable OPENGL it works but not all functions behave normally. The FFT is OK, but histograms does not work.

So, linux (Ubuntu) under VMWare is able to correctly run gnuradio.
My Windows implimentation of gnuradio is not functioning correctly.

WORST OF ALL:

Somehow my precious, expensive, bladeRF-board (a 115-type!) is not seen by linux/VMWare/Windows.

Any way bladeRF-cli does not see any bladeRFnn
Any way Windows DOES mention a bladeRF-device that does not start up.

I am afraid I have a VMWare-USB-Windows problem!

What to do now????

1. Investigate the USB-VMware-problem
2. Give up and boot my laptop from a live linux-CD/DVD or install multiboot???

I don't know what is the best strategy to be able to play with my bladeRF-115-toy!

COMMENTS ARE MORE THAN WELCOME, IE helpful suggestions please!


Time to show myself and my dog, Boris, in Caminha, Portugal,
 at the end of 2012. My wife takes this picture, I guess...


Thursday, August 22, 2013

Install remaining software for BladeRF

Another evening stumbling upon/through/over linux.

Warning: I copied/pasted a lot of info from my diary. Not at all to impress you, but to show what I did and had to do to get my BladeRF-board working. I can tell you, I did not succeed this evening. I am afraid many more evenings will come...

I took the marvelous installation guide from the bladeRF - forum,
kb3gtn's bladeRF setup guide at
 http://forums.nuand.com/forums/viewtopic.php?f=9&t=2804

Painfully I followed the instructions.

The problem is, however, that I am regaining old linux knowledge that was almost gone. Old forgotten braincells suddenly awaken and try to help me.

I had to experiment with well known linux commands. Ok, dir, sudo, cp, mkdir, rmdir, rmd, whatever, a lot of commands I understand. I managed to switch between my terminal-session, my diary in Word in windows and Chrome, or Fox for internet-access. All in different windows. And, Ubuntu is running in VMWare.

I re-learned ~ is your home-directory. Trivial perhaps for experienced linux-users.


About libusb, there seem to be two flavors: libusb-dev, the developers lib and libusb, the underlying lib.

I read something about aptitude. DO I have that installed in Ubuntu? Just ask the system and you get:

The program 'aptitude' is currently not installed.  You can install it by typing:
sudo apt-get install aptitude

So I did

OK, so now I can use aptitude or apt-get to semi-automagically install packages...

ecokees@ubuntu:/mnt/hgfs/bladeRF/linux/lib$ sudo apt-get update
ecokees@ubuntu:/mnt/hgfs/bladeRF/linux/lib$ sudo apt-get install libusb
ecokees@ubuntu:/mnt/hgfs/bladeRF/linux/lib$ sudo apt-get install libusb-1.0.0
ecokees@ubuntu:/mnt/hgfs/bladeRF/linux/apps$ make

Do I use the wrong libusb?? I use 1.0.0 but there is also a quite different 0.1.0
Which one do I need?

In directory C:\Users\lonneke\Documents\GitHub\bladeRF-1\linux\lib
is a makefile that reads
# Enable libusb (>= 1.0) support by defining ENABLE_BACKEND_LIBUSB


ecokees@ubuntu:/mnt/hgfs/bladeRF/linux/lib$ sudo apt-get install libtecla1 libtecla1-dev
ecokees@ubuntu:/mnt/hgfs/bladeRF/linux/apps$ make
I get a lot of undefined reference to


NOPE…

Now I am gonna try the exact procedure at http://forums.nuand.com/forums/viewtopic.php?f=9&t=2804

ecokees@ubuntu:~$ sudo apt-get install git
 ecokees@ubuntu:~$ sudo apt-get install git-core


The program 'gitk' is currently not installed.  You can install it by typing:

sudo apt-get install gitk
ecokees@ubuntu:~/myProject$ sudo apt-get install git-gui


How to see hidden files in the file-browser?  Ctrl-H or edit preferences
Now I can see all hidden files that start with a . (dot)

ecokees@ubuntu:~/bladeRF$ git clone https://github.com/Nuand/bladeRF.git

this is the URL for help about git:  http://git-scm.com/book/en/Git-Basics

ecokees@ubuntu:~/bladeRF/bladeRF/linux/kernel$ make
ecokees@ubuntu:~/bladeRF/bladeRF/linux/kernel$ sudo insmod bladeRF.ko
ecokees@ubuntu:~/bladeRF/bladeRF/linux/lib$ make all
ecokees@ubuntu:~/bladeRF/bladeRF/linux/apps$ make

ecokees@ubuntu:~/bladeRF/bladeRF/linux/apps$ dir bin
bladeRF-cli
ecokees@ubuntu:~/bladeRF/bladeRF/linux/apps$

OK: now I have my bladeRF-cli  !!!!!!!!!!!!!!!!

The setup guide starts with a remark:

This procedure builds the nuand code / FX3 firmware / builds gnuradio-3.7 (from git) / and gr-osmosdr (from git)
It is assumed you have installed build-essential / linux-headers-`uname -r` and have a general idea of figuring out other missing (apt-getable) depends.
In this example install procedure we will be installing everything into a /opt/[bladeRF]|[cypress]|[gnuradio-3.7.1git]
Because of the custom location, it does require us to update libarary search paths / and pythonpath enviroments / and optionally exec path. (covered here)
This procedure is tailored to ubuntu systems, but could be adapted to other distros like Centos / Gentoo etc...

So, there we go again:


ecokees@ubuntu:~/bladeRF/bladeRF/linux/apps/bin$ sudo apt-get update
ecokees@ubuntu:~/bladeRF/bladeRF/linux/apps/bin$ sudo apt-get install gcc
ecokees@ubuntu:~/bladeRF/bladeRF/linux/apps/bin$ sudo apt-get install g++
ecokees@ubuntu:~/bladeRF/bladeRF/linux/apps/bin$ sudo apt-get install libc6-dev

and finally:

ecokees@ubuntu:~/bladeRF/bladeRF/linux/apps/bin$ sudo apt-get install build-essential

What is linux-headers??

Kernel *headers* are the header files used to compile the kernel - and other
applications which depend on the symbols / structures defined in these
header files, like kernel modules. An example can be graphic card drivers;
if the driver does not have a binary matching the running kernel and needs
to be compiled.

ecokees@ubuntu:~/bladeRF/bladeRF/linux/apps/bin$ sudo apt-get install linux-headers-generic

ecokees@ubuntu:~/sandbox$ git clone https://github.com/Nuand/bladeRF.git

Yep: I have a bladeRF directory                                NOTE: it is bladeRF, not bladeRf!!

OK, again:

ecokees@ubuntu:~/sandbox/bladeRF/linux/kernel$ make

A lot of warnings, hope that is no problem later on

ecokees@ubuntu:~/sandbox/bladeRF/linux/kernel$ sudo mkdir -p /lib/modules/'uname -r'/kernel/extras/bladeRF/

-p, --parents
no error if existing, make parent directories as needed

ecokees@ubuntu:~/sandbox/bladeRF/linux/kernel$ sudo depmod

The depmod and modprobe utilities are intended to make a Linux modular kernel manageable for all users, administrators and distribution maintainers.
Depmod creates a "Makefile"-like dependency file, based on the symbols it finds in the set of modules mentioned on the command line or from the directories specified in the configuration file. This dependency file is later used by modprobe to automatically load the correct module or stack of modules.

DESCRIPTION
Linux kernel modules can provide services (called "symbols") for other modules to use (using EXPORT_SYMBOL in the code). If a second module uses this symbol, that second module clearly depends on the first module. These dependencies can get quite complex.

depmod creates a list of module dependencies, by reading each module under /lib/modules/version and determining what symbols it exports, and what symbols it needs. By default this list is written to modules.dep in the same directory. If filenames are given on the command line, only those modules are examined (which is rarely useful, unless all modules are listed).

If a version is provided, then that kernel version’s module directory is used, rather than the current kernel version (as returned by "uname -r").

depmod will also generate various map files in this directory, for use by the hotplug infrastructure.


 Do you understand this all?

ecokees@ubuntu:~/sandbox/bladeRF/linux/kernel$ sudo modprobe bladeRF
FATAL: Module bladeRF not found.
ecokees@ubuntu:~/sandbox/bladeRF/linux/kernel$

For some reason the mkdir command did not make the right directory and the cp command also did not what it had to do

This is interesting:

ecokees@ubuntu:/lib/modules$ cd $(uname -r)
ecokees@ubuntu:/lib/modules/3.2.0-51-generic-pae$ cd kernel

playing with root

ecokees@ubuntu:~/sandbox/bladeRF/linux/kernel$ sudo -s
root@ubuntu:~/sandbox/bladeRF/linux/kernel# echo "bladeRF" >> /etc/modules
root@ubuntu:~/sandbox/bladeRF/linux/kernel# exit
exit
ecokees@ubuntu:~/sandbox/bladeRF/linux/kernel$

ecokees@ubuntu:~/sandbox/bladeRF/linux/lib$ make DEBUG=y
ecokees@ubuntu:~/sandbox/bladeRF/linux/lib$ sudo apt-get install libtecla1 libtecla1-dev
ecokees@ubuntu:~/sandbox/bladeRF/linux/apps$ make
ecokees@ubuntu:~/sandbox/bladeRF/linux/lib$ sudo apt-get install libtecla1 libtecla1-dev
ecokees@ubuntu:~/sandbox/bladeRF/linux/apps$ make
ecokees@ubuntu:~/sandbox/bladeRF/linux/apps$ sudo mkdir -p /opt/bladeRF/fpga
ecokees@ubuntu:~/sandbox/bladeRF/linux/apps$ sudo mkdir /opt/bladeRF/firmware
ecokees@ubuntu:~/sandbox/bladeRF/linux/apps$ sudo mkdir /opt/bladeRF/bin
ecokees@ubuntu:~/sandbox/bladeRF/linux/apps$
ecokees@ubuntu:~/sandbox/bladeRF/linux/apps$ sudo cp bin/bladeRF-cli /opt/bladeRF/bin
ecokees@ubuntu:~/sandbox/bladeRF/linux/apps$

WAUW!!!

ecokees@ubuntu:~/sandbox/bladeRF/linux/apps/bin$ ./bladeRF-cli --help
Usage: ./bladeRF-cli [options]
bladeRF command line interface and test utility (0.2.0)

Options:
  -d, --device <device>            Use the specified bladeRF device.
  -f, --flash-firmware <file>      Flash specified firmware file.
  -l, --load-fpga <file>           Load specified FPGA bitstream.
  -p, --probe                      Probe for devices, print results, then exit.
  -s, --script <file>              Run provided script.
  -b, --batch                      Batch mode - do not enter interactive mode.
  -L, --lib-version                Print libbladeRF version and exit.
  -V, --version                    Print CLI version and exit.
  -h, --help                       Show this help text.

Notes:
  If the -d parameter is not provided, the first available device
  will be used for the provided command, or will be opened prior
  to entering interactive mode.

  Batch mode is implicit for the following options:
     -p, --probe               -h, --help
     -L, --lib-version         -V, --version

ecokees@ubuntu:~/sandbox/bladeRF/linux/apps/bin$ ./bladeRF-cli --version
0.2.0
ecokees@ubuntu:~/sandbox/bladeRF/linux/apps/bin$

So, bladeRF-cli works and I should be able to control my BladeRF-board!!!!!!!

bladeRF> print

Error: No devices are currently opened

bladeRF> open

open: No device specified

bladeRF> probe

bladeRF> version
Inside version
bladeRF> quit
ecokees@ubuntu:~/sandbox/bladeRF/linux/apps/bin$

About power supply for the BladeRF. It seems to be completely run on the USB-power.
I found a set of jumpers (J70) that are placed to have the USB-power feed the board. It is also
possible to use external power.

I can imagine that the FX3-chip on the bladeRF needs to be inited first?

So, go on with the installation from http://forums.nuand.com/forums/viewtopic.pphp?f=9&t=2804

*******************************************************************************************
**** THIS SETUP GUIDE Works with the kernel driver implementation only ****
**** LIBUSB implementation setup guide to come soon. ****

I don’t need to make the FX3 image, just download. Last command is:

$ sudo cp bladeRF.img /opt/bladeRf/firmware/

I downloaded bladeRF.img to my shared directory in Windows and then:

ecokees@ubuntu:~/sandbox/bladeRF/linux/apps/bin$ sudo cp /mnt/hgfs/bladeRF/bladeRF.img /opt/bladeRF/firmware/

ecokees@ubuntu:/etc/udev/rules.d$ sudo gedit 10-bladeRF.rules

Well, I still cannot use my BladeRF-board.

I am afraid that windows is hiding the USB-device bladeRF for me.

I don't know what to do now:

  1. just go on and install gnuradio on Ubuntu in VMWare in Windows7 and hoping that I see the bladeRF as a source in gnuradio
  2. install linux on a stick or CD, boot from it and do the whole installation again
  3. trying to figure out where it is going wrong. I pasted almost everything I did in a word-diary, inclusive of all messages I got.
  4. Ask for help on the forum
  5. Go on with libusb and java in Windows, I have done something like this before with the EZUSB-software
I don't know yet. I am afraid that VMWare is causing some problems here with USB. 
I really love to learn and find out what is happening but I also want results finally. My goal is building a GPS-receiver using the FPGA on the BladeRF and Python on the PC. I do not want to become an expert in VMWare/Windows-problem-solving...

I hope some nice guy or girl from the BladeRF community will help me in some way. I am not stuck yet, there are some things to investigate so I don't yet have clear questions to put in the forum.


Linux is daunting, but I will survive: YES I CAN!!








Tuesday, August 20, 2013

Git and Github is great! Nice version control software for my bladeRF software

I was stuck in git last time I tried to get working software for my bladeRF.

The software for the bladeRF is on https://github.com/Nuand/bladeRF

So, you have to use git. Git is all about version control software (VCS). At first git scared me, it was daunting, it looked very complex. But I had to use it. So, after installing the software, play with it and trying to avoid RFM., I had to admit: you have a problem. Tonight I finally did some serious study, found a nice tutorial and finally had success! I cloned the bladeRF software and I now have a working version locally which I can easily keep up to date with git!

I even understand what I am doing now!

This is the URL for help about git:  http://git-scm.com/book/en/Getting-Started

I finally managed to patiently read the tutorial and try some commands. This is great stuff! It is all about RFM. Normally I avoid manuals/tutorials/notes, etc. But this time was different.

I managed to set up git the right way. I installed gitk and git-gui. I configured git (just a matter of typing a username and email-address after having set up an account at github).

Then I finally cloned the bladeRF software to a local directory. Now I had the last version! I made the kernel, the lib and the apps. Now I have my bladeRF-cli

OK, I can't do anything useful with it right now but I am slowly creeping to success!

Next I'll try to build the software using the very clear tutorial in the bladeRF forum.


from my photo-archive: in March 2013 I photographed this
plate in Castrojeriz, Spain. It is about the "route de Santiago".
(I walked, with my dog, about 5 km of this route).




Saturday, August 17, 2013

First steps from git to bladeRF-software

This whole project is becoming quite a challenge!

I installed a window-program to use github and somehow I managed (by accident?) to get a copy of github's bladeRF software to a more local place on my hard disk. I use Windows 7 prof. Studying the software I decided to go for linux. Most of the bladeRF-people seem to do that. Why do it differently? Yes, think differently takes you to a higher place but this is already difficult enough!

I had Ubunti running under VMWare under Windows prof 7.

I managed to mount my bladeRF-directory-tree and could access the files from Ubuntu.

Ubuntu warned me to get about 52 updates. I got the updates and discovered I lost my bladeRF-files. That is to say: I could not access the share anymore.

OK, I had to reinstall VMware-tools.

After that I went to the linux/kernel directory and did what I had to do

I went to the linux/lib directory and libusb was missing.

I installed aptitude and did: sudo apt-get install libusb
I choose for lib 1.0.0

Back to make lib
Lot of errors. Difficult to understand what is happening here.

I had to install teclalib or libtecla and back to lib

Finally go to the directory linux/apps and make apps

Problems: there is not any sign of bin/bladeRF-cli the directory bin is empty

I have to find out what is going wrong.

The main idea for installing software in linux is becoming clear to me:

1. there is an automatic installer: apt-get   OR:
2. there are tar-archives that should be copied to and extracted from /tmp
3. you look for a readme and RFM!
4. you give the command 'make' (yes, without the quotes)
5. you do sort of make install
6. somehow go through the pile of messages to find out if all is OK

Well, thusfar I learned an enormous lot of things about linux. However, the bladeRF-board is still in the box, it is no use connect it to my laptop-USB-3-port if there is no corresponding software running...

Do I need libusb1.0.0 or libusb0.1.0????

A lot of questions.

Plans:
1. I want to make/install the bladeRF demo software running Ubuntu/linux
2. I will install gnuradio in Ubuntu (it more or less runs in Windows already!)

Comments on my ramblings are more than welcome. I can use any suggestion of more experienced users (perhaps almost every bladeRF-owner ?)


big storm: broken mill in a garden in Caminha, Portugal


Tuesday, August 13, 2013

Wrote a Sudoku solver in Python on an iPad

My BladeRF-board is burning in my hands. I want to connect the beast to my laptop, experiment with gnuradio, write some VHDL-code, program the FX3-USB-chip with C-code and eventually write some python-code to control the BladeRF from my laptop. And I need to understand GitHub, become familiar with unix again etc.

Well, I was thinking about where to start now when my wife got that (persistent?) idea to go out for a fortnight and go camping on that nice campsite without electricity and Internet. OK, no BladeRF for a few weeks. But life is about chances, so I took the iPad, found the 12V charger, checked my Smart phone for Internet-access (tethering!) and a few days later we went for the trip.

Between dividing my attention to my wife, our dog and the neighbours, I had ample time for python. Previously I installed Pythonista on the iPad. I had a marvellous fortnight. I spent hours in bed with Pythonista just before sleeping. I did the language tutorial a few times. Read most of the language reference and read some forums on the Internet (yes, tethering on the Smart phone and discovering that you 'burn' a lot of MB's from your 500 MB month-limit). Then I examined the examples from the Pythonista-app. It looked quite simple finally.

I decided to go for a Sudoku-solver. This is medium-difficult project with classes, functions, lists and drawing/animation. Just to get familiar with python.

First I programmed a white tile. I you touch the tile it changes to red, touch it again and it is white again. That is fun! The equivalent of Hello world or a blinking LED!

I programmed an array of 9 * 9 tiles. To make it interesting I programmed the tiles to flip the color of its 4 neighbours if you touch one. Then I had the value increment for every touch. Later I made a small modification to set the value back to 0 after reaching a value of 10.

I changed the graphics to show a subdivision into 9 bigger tiles, each divided into 3 * 3 tiles.

I programmed functions to check for doubles in a row, a column or a 3*3 tile according to the Sudoku-rules.

Finally I made a big green START-button and programmed a solver using backtracking. Believe me, this was the simplest part of the game!

Now I can touch my empty Sudoku and program a challenge from a newspaper. Few minutes later it shows the solution. But more than that it animates the progress. It is fun to watch the solver solve the Sudoku. You see the backtracking to the first tile and going up again to find a solution.

I found some hard Sudoku-problems on the Internet and my python-program could solve them all. The hardest one took more than half an hour, but perhaps it took that long because the iPad switched itself off after so many minutes. Later I changed the setup and got an empty battery after a long walk with the dog ;<((

I sent the python-program to my laptop using email and tried to run it from the python-implementation on the laptop. Nope: 'import scene' does not work. Of course, the class/module Scene is specific for the OS on an iPad, I presume. OK, a pity. If someone wants the code, comment on this article or send me an email. This Sudoku-program is really fun to play with! But quite distracting if you want to do something useful with your life...

I found an enormous lot of Sudoku-implementations on the internet! I knew that already because I programmed a solver in MathCad once and also in java in my worktime before retirement. To learn the language of course (my boss agreed ;>)) to that).

This Sudoku-project taught me a lot about python. Python looks a lot like java, but it is easier perhaps. I am quite surprised that python does not insist in declaring variables. I can't resist to program "x = 1.0" to explicitly declare x to be a floating point variable. The for loop is fantastic! Just write "for i in elem" where elem is a list, an array, a dictionary or whatever datastructure and you get every element in the variable i. From then on you can use i.x for its x-value or whatever attribute. The scope of variables puzzled me in the beginning. I still have some problems with the argument 'self'. In a class every function gets a pointer to itself automagically? I'll try to grasp that later, if I have to.


I sent this photo to my little grandson (he likes big
machines). However he thought it was a picture of
the present he was going to get from us...