woensdag 25 november 2015

The learning curve of Google Now

Update 2015-12-11 I started writing this post to vent my frustration with Google Now. It mainly lists some things that I was really disappointed with. I disabled it altogether. But some people pointed out some things that made me reconsider. Since then, I found some pro's as well. Plus, I learned that I shouldn't have tried to learn to operate a smartphone just by operating a smartphone. In my case (I'm a laptop addict), it's much more efficient find on the laptop how things work on the smartphone. Some people may operate a smartphone like a body part, it's not nearly as user-friendly as I had expected.

One pro of Google Now is voice control - if you speak English: it's much more intelligent in English than it is in Dutch (my native language). For example, the command 'zet bluetooth aan' brings up the bluetooth app. Which you then must turn on manually. But the command 'turn on bluetooth' does just that.

Why Google Now made me Angry

About five years ago, some googler on YouTube, while explaining some function in Chrome, said: "One of the key tenets in Google is that we don't want to interrupt the user". I didn't know what a tenet is, so I looked it up. A tenet is a belief, a creed. So five years ago, Google believed interrupting the user was wrong.

I liked that. A lot. I hate "Are you sure?" pop-ups on totally trivial changes. I hate pop-ups, full stop. I hate ads. I hate basically any machine that interrupts my train of thoughts, that deliberately tries to distract me from what I intend to do.

Google Now does just that. That's why I hate it, that's why it makes me angry.

Why Google Now Sucks

It started when I bought my first smartphone, about a month ago. It had a function called swipe launch: swipe up from home, and you launch - yes - Google Now. This meant I launched Google Now unintentionally many many many times, while scrolling.

At first, I thought I'd give it a try. But it kept presenting me things I didn't want to know, at the wrong moment. A partial list:

  • I don't want to read what the temperature outside is, I can go out and feel it. I can even look at a thermometer!
  • I don't want to see perpetual calender reminders. I know all my appointments by heart a few days in advance.
  • I don't want to know when new e-mail comes in, I have the discipline to check, daily, and do not want to be disturbed at other times.
  • I don't want to see "news" items "popular in my area". I read a good newspaper, and I follow a couple of other news feeds.
  • I don't want to see "information" that other people "like me" find interesting. This is because the criteria that determine "like me" miss the point, hopelessly. Apparently, most people my age and gender are interested in cars, games, gadgets, nude women, superficial TV-shows, and any consumer society whim. I'm not.
  • It kept asking me which means of transportation I use mostly. But I walk, cycle, drive or ride public transport in just about any mix that's handy - so there is no way I can answer that question. Yet it kept asking me.
  • When visiting a customer, it triumphantly reminded me where I had parked my car. Except it was totally wrong. It told me the place where I had stopped moving fast, and stopped to look for a while. I got there by public transport, my car was about 60 kilometers away from where it said it was.

Google Now is like the encyclopedia salesman at your door, a very agressive and stubborn one, when you already have a very good encyclopedia, or two. Piss off, you idiot!

So, I went and took all the necessary steps to disable Google Now on my smartphone.

But, Google Now is designed to invade your online activities, anywhere, everywhere. It popped up on my laptop. So I disable it there. I operate a couple of old laptops, infrequently. It popped up on them. That made me very angry. If my bookmarks get synced across three different machines, why not sync undesired features in the same way? Never before did I have to explain Google more than once that I don't want something. Never before have I seen a Google product so stubbornly ignoring that I want it to stay away from me.

That is what I find fundamentally wrong with Google Now. Google used to show they understood. Now they deliberately keep disturbing me. Google is not stupid, so the nag factor must be by design. They keep nagging you, because it works with most. Most people do get lured into using it, making more people click more ads.

Don't I want to know anything?

I am interested in a whole lot of other things. And I know how to find them. I don't need ads. I search. Using Google. So it's not that I hate Google. I love Google (the search engine), it helps me find what I'm looking for, faster and more to the point than any other search engine out there. I do try others, they do not help me as well as Google does.

Internet is pull, not push. I've learned to distrust pretty much all information that companies push to me unsolicitedly. I've also learned that information I went out and looked for, and found, is the most valuable kind of information.

Google has a reputation for hiring bright people. How come no googler was so bright as to predict the anger-inducing properties of Google Now? I really don't understand. I guess most people are more gullible than me.

The best minds of my generation are thinking about how to make people click ads. I think that sucks.

said facebook big data guru Jeff Hammerbacher, and then he left facebook, in 2013. I think he was right then and he is still right today.

zondag 16 augustus 2015

Groeilampjes worden Rocket Science

Een écht goed idee heb je nooit in je eentje. Enige tijd geleden deed Loket Diversen verslag van Joule Robbin Hood, een simpel systeempje om bijna-lege batterijen te gebruiken als energiebron voor het kweken van plantjes onder led-licht.

In het nieuws deze week: het ruimtestation ISS gebruikt vergelijkbare technologie (en nog wat extra technologie erbij) om sla te kweken! Het systeem heet het Vegetable Production System, koosnaam Veggie. De astronauten recreëren met de verzorging van plantjes en kunnen bovendien ook eens verse groenten eten.

The Vegetable Production System (VEGGIE) provides a means to supply crews with a continuous source of fresh food and a tool for relaxation and recreation.

Aldus NASA. Wat verse rucola zal zeker een verademing zijn bij al dat voer uit tubes. Veggie wordt gemaakt door de firma Orbitec en bestaat verder uit een matras in een bak met in hoogte verstelbare rode en blauwe leds. Die matras bevat de overige voedingsstoffen voor de plantjes, want potgrond, gewichtloos in de ruimte, dat wordt natuurlijk een rommeltje.

Leds zijn zeer energiezuinig en dat komt goed van pas in een ruimtestation waar je louter afhankelijk bent van zonnepanelen. Maar rocket science? Welnee. Het ligt binnen handbereik van iedereen die maar wil, zoals wij op Loket Diversen en in (paywall alert) Elektor reeds in 2013 uit de doeken deden.

Niettemin, zonder aarzeling zien we mogelijkheden voor langdurige ruimtereizen. NASA weer:

Future spaceflight missions could involve four to six crew members living in a confined space for an extended period of time. [...] The farther and longer humans go away from Earth, the greater the need to be able to grow plants for food, atmosphere recycling and psychological benefits.

O ja, laten we niet vergeten dat die plantjes ook de CO2-uitstoot van de astronauten omzetten in zuurstof.

Ook moeten we inzien dat vegetariër-astronauten duidelijk in het voordeel zijn. Vergaat onze planeet en moeten wij op dwaaltocht door outer space naar een andere, dan wordt het groente en fruit eten! Hopelijk is de veggieburger tegen die tijd makkelijk te maken en smakelijk.

Onvermijdelijk is er op die reis daarentegen geen plaats voor vrome joden en moslims die hun geloof willen belijden met rituele slacht. Discriminatie? Zeker. Wel zal het de kans op vrede in de ruimte aanmerkelijk vergroten.

Ik herinner me een carnavalsschlager van de geniale Tom Manders alias Dorus:

En in de hemel is geen bier
en daarom drinken wij het hier.

Het zit er nu echter dik in dat men wel hop en gerst in de ruimte zal kunnen kweken, en water moet sowieso mee. Dus in de hemel is wél bier, tegen die tijd. Waarschijnlijker dus:

In de hemel is geen worst
en daarom laaf ik hier mijn dorst.

Proost. Op de vooruitgang!
bovenste foto: NASA, onderste foto (ja hij is onscherp) Loket Diversen.

vrijdag 6 februari 2015

Howto: persistent device names on Raspberry Pi

  *** Nerd Alert!    *** Geek Stuff! ***  

This text explains how to set up a persistent device name in Raspbian Linux. If you want to get cooking straight away, skip to the steps in detail.

Summary

By design, a USB device is assigned a unique address by its host, but that address may change from one session (bootup) to another. Software using the device, on the other hand, is much easier to make if the address does not change. In Linux, the solution to this problem is a persistent device name. How to make that is explained below.

Introduction

USB-enumeration for dummies

Elsewhere on Loket Diversen is a post about setting up Raspberry Pi (RPi) as SMS Gateway. I'm using a Huawei GSM/UMTS modem on RPi's USB port. Gammu or Gnokii deal with the modem. You specify in a config file where to find that modem: /dev/ttyUSBx (with x a number). The problem is that x may change unpredictably.

It turns out that this is by design. The process of USB address assignment is called enumeration. In a nutshell, it's a conversation between Device, Hub and Host and it goes something like this (metaphorically speaking):

Device: Wheehee, I'm plugged in!
Hub:   Host? Hey host, wake up, there's a customer!
Host:  (waking up) What? Oh, OK, well, enable a port, would you?
Hub:  (enables port)
Host:  (in a formal tone of voice) Device! Reset!
Device: Aye-aye Sir. I'm all Reset.
Host:  Device, what is your Descriptor?
Device: I'm X, from Y.
Host:  (muttering to self) Uhm, er.. where'd I leave the free addresses list? Oh here.
     (clears throat; formal voice:) Device X from Y, you shall be on address P.

Note that P is given out in order; the first Device gets ttyUSB0, the second ttyUSB1, and so on. But more importantly, note how timing isn't always the same! When booting up with two devices plugged in, one device might just respond slightly faster than the other. And next time it may be the other way around. That is why the number for x in /dev/ttyUSBx is unpredictable.[1]

Gnokii, Gammu and others

StackOverflow has a nice little overview of various open source SMS Gateway packages. I don't need large-scale SMS-messaging, so my choice was between Gnokii and Gammu. Gnokii is small and very simple. Gammu is a fork of Gnokii that took off on a life of its own. Gammu is much, much more rich in features and possibilities than Gnokii. Documentation, unfortunately, is less than perfect.

Gnokii's SMSreader-command just listens for SMS-messages, full stop. You could probably shove that into the background, but there's more to a well-behaved background process, also known in Linux/Unix as a daemon. Building a daemon is not trivial. But Gammu comes with a well-behaved daemon already, it's called Gammu-smsd. Making a message handler for that is a lot less work. That's why I chose Gammu.

A persistent device name, step by step.

One FAQ on Gammu is Device name always changes on Linux, how to solve that?  The answer given there is not very adequate. It took me quite some googling and trial & error to get it working. Hence this text.

We're using udev, Linux' device manager. It supports persistent device naming and it runs by default on any Linux distro. Just to verify:

  1. ps -A | grep udev

    should respond with something like

    156 ? 00:00:00 udevd

    Yup, it's running, process ID 156.

  2. Find out a unique enough identifier set for the device.

    lsusb

    lists all USB devices. This is the output in my case:

    Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
    Bus 001 Device 005: ID 12d1:1003 Huawei Technologies Co., Ltd. E220 HSDPA Modem / E230/E270/E870 HSDPA/HSUPA Modem
    Bus 001 Device 004: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]

    OK, so the modem is connected and it's USB device 005 (this time). Note the numbers. 12d1 is the Vendor ID (Huawei Technologies) and 1003 is the Product ID, this particular model modem that they make. In this case, the combination Vendor ID + Product ID is already a unique enough identifier set. (So you could skip the next two steps.)

    In other cases, things may be different. For instance, lots of devices use FTDI's USB-to-serial converter, all with the same Vendor and Product ID and you may want to have them all connected to you RPi. So you'll need some more information to distinguish one from the other(s).

  3. To find that extra bit of information, enter

    dmesg | grep usb

    the response might be a long list. Somewhere in there, you'll find something like this:

    [ 523.057081] usb 1-1.2: new high-speed USB device number 5 using dwc_otg
    [ 523.168297] usb 1-1.2: New USB device found, idVendor=12d1, idProduct=1003
    [ 523.168330] usb 1-1.2: New USB device strings: Mfr=2, Product=1, SerialNumber=0
    [ 523.168346] usb 1-1.2: Product: HUAWEI Mobile
    [ 523.168362] usb 1-1.2: Manufacturer: HUAWEI Technology

    Note idVendor and idProduct. We'll use them later on. Note also SerialNumber=0. I don't trust serialnumbers that are zero. With other devices you should see a non-zero serial number, usually on a line of its own.

  4. dmesg | grep ttyUSB

    will list all ttyUSB devices, like so:

    [ 6.546558] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB0
    [ 6.571094] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB1

    My modem occupies 2 ttyUSB's. By trial and error, I found out that sending and receiving works on ttyUSB1. I don't know why that is.

  5. To get an idea of all the attributes of a USB-device, try:

    udevadm info --name=/dev/ttyUSB1 --attribute-walk

    This walks along a branch of USB devices and lists, for each device, all possible attributes in the udev rules key format.[2]. Try it! If your device has a serial number, you will see it there. I always find it reassuring when different sources report the same information.

  6. Almost done.

  7. Create a file /etc/udev/rules.d/99-usb-serial.rules (yes you'll need root rights) with something like this line in it:

    SUBSYSTEM=="tty", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1003", SYMLINK+="kpn_dongel"

    with, of course, your values for idVendor, idProduct and the symlink. You may need to add idSerialNumber (or whatever) to make it unique. Add a similar line for each device you want a symlink for.

  8. Now load the new rule. Rebooting is the crass way, this is much more elegant:

    sudo udevadm trigger

  9. Finally, test it. Three useful commands:

    ls -l /dev/kpn_dongel

    will give something like:

    lrwxrwxrwx 1 root root 7 Jan 17 21:48 /dev/kpn_dongel -> ttyUSB1

    ls -l /dev/ttyUSB1

    Will give something similar to:

    crw-rw---T 1 root dialout 188, 1 Jan 17 21:48 /dev/ttyUSB1

    Note the ownerships and group memberships. Software will have to be aware of this, chown and chgrp may come in handy. But that's a different subject.

    Finally, the output of this should point to the appropriate ttyUSB, and you'll recognise vendor name in there too.

    udevadm test -a -p $(udevadm info -q path -n /dev/kpn_dongel)

That's it! In gammu's config file, you can now refer to the device by persistent name /dev/knp_dongel (for this example). And it won't change.

Final notes

Convenient file editing on RPi

My Pi is the early 256MB version. Anything you run on the GUI over VNC will lag. So I'm using it headless over SSH. Does it make sense to be working in 256 or even 512 MB using Pi's rather primitive nano editor, when I'm actually operating a nice laptop with 4000 times more memory and all the tools that I'm familiar with? I think not. So I used Samba to make a shared directory on my Pi, and I use Notepad++ on my laptop to edit the files in that directory. The only thing I need to take care of is ANSI-encoding and Linux line ending, but NPP can handle that for me.
And then all I need to do on Pi in a case like this is something like sudo cp [myshare]/filename /dev/udev/rules.d/ .

I wrote this post because I never found a single text with all the necessary information in one place. It's useful for me, I hope it's useful for you.

Sources and references

1. The conversation was paraphrased from an Powerpoint by Atmel that is no longer online. Instead, Atmel have a nice Application Note that also explains enumeration in detail. back.

2. Source: debian wiki on udev. back.

3. Thanks to Michael Ludvig's Hintshop for the syntax in step 6 and the ls tests in step 8.

Mogelijk gemaakt door Blogger.