Author Archive for Oliver Kuster


Improved bash directory bookmarking

I’d recently found and decided to give it a try.

It’s simple and quite stable. AND you can change it without much thinking (although in bash this could end up in sadness).

To use, just add to your .bashrc. The ZSH and OSX versions are available in the original blogpost!

I’ve updated it to:

export MARKPATH=$HOME/.marks
test -d $MARKPATH || (
    echo "Creating dir MARKPATH=$MARKPATH ..."
    mkdir $MARKPATH
function jump {
    if [[ "$1" != "" ]]; then
        cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
        echo "Usage: $0 <mark>"
function mark {
    mkdir -p "$MARKPATH"; ln -s "$(pwd)" "$MARKPATH/$1"
function unmark {
    if [[ "$1" != "" ]]; then
        rm -i "$MARKPATH/$1"
        echo "Usage: $0 <mark>"
function marks {
    ls -l "$MARKPATH" | sed 's/ / /g' | cut -d' ' -f9- | sed 's/ -/\t-/g' | grep -v '^$'

_completemarks() {
    if [[ $COMP_CWORD -ne 1 ]]; then
        local curw=${COMP_WORDS[COMP_CWORD]}
        local wordlist=$(find $MARKPATH -type l -printf "%f\n")
        COMPREPLY=($(compgen -W '${wordlist[@]}' -- "$curw"))
    return 0
complete -F _completemarks jump unmark


  • create directory if it does not exist
  • do not accept ‘jump’ and ‘unmark’ without argument
  • do not print empty lines in ‘marks’
  • autocomplete only first argument


  • check if directory of mark is available

Part 3: XRF BACONZ(Beacons)

Let me start this post sharing my “Lessons learned”:

1. Arduino IDE sucks… still better having it than trying to program MSPs from Ti on Linux manually, without any IDE, but still… Arduino sucks. I hate when tab is replaced with spaces, why use tab then? just use your damn spaces. And I never get the double quotes to work, I always have to ctrl+c, ctrl+v them. I ended up editing the code in Gedit and kept pasting it to the IDE.

2. DON’T try to use the same Arduino installation for both Teensy and Arduino Duemillanove. You probably will more often than not choose the wrong library from the Examples menu.

3. Very nice discovering that the NewSoftwareSerial is in Arduino Core since 1.0!

4. Gnoduino is pretty, has better editor than Arduino IDE, and doesn’t work (on Arch at least). Something about a flash error. Will try more later.

So, why I’m sharing these? Well, if you own a Teensy and an Arduino and want to quickly write some code that kinda works on both for testing, say… XRF modules (hehehe) you’ll probably know by now at least two of the things from above.

But I digress. So, I wanted to test the comunication and range of the XRFs so I wrote these little hacks that pretty much work out of the box. (XRFs are configured for 868MHz and 9600 Baud serial from factory, don’t remember wireless bitrate.)

Teensy code is built around Serial(yay) and the Uart library that comes with Teensy. Teensy has a special Uart port that is not used for programming (bothersome in Arduino)

#define LED_PIN 11
#define BAUD 9600

HardwareSerial Uart = HardwareSerial();

void setup()
	pinMode(LED_PIN, OUTPUT);

	digitalWrite(LED_PIN, HIGH);
	pinMode(LED_PIN, LOW);

	Serial.begin(BAUD);	// USB, communication to PC or Mac
	Serial.println("SETUP teensy");

	Uart.begin(BAUD);	// UART, communication to Dorkboard

char beacon[]="abcdef";
char answer[]="fedcba";

unsigned i = 0;
long led_on_time=0;
char input[]="000000";

void loop()
	unsigned char c;

	if (Uart.available()) {
		digitalWrite(LED_PIN, HIGH);
		led_on_time = millis()+200;

		c =;
		if (c == beacon[0]){
			input[0] = c;
		}else if(i > 0){
			input[i] = c;
		if ( i >= strlen(beacon)){
			if (strcmp(input, beacon) == 0){
				digitalWrite(LED_PIN, HIGH);
				led_on_time = millis()+500;

				Serial.println("Got beacon!");
	if (millis() > led_on_time) {
		digitalWrite(LED_PIN, LOW);

I’m using the Teensy as the beacon receiver. When it receives the expected message it flashes the LED and sends the specified answer. (Receives “abcdef” and sends “febcba” back)

The Arduino code is pretty much the same thing but uses the SoftwareSerial on ports 2 and 3.

#include <SoftwareSerial.h>

#define SEND_DELAY 5000
#define LED_PIN 13

SoftwareSerial mySerial(2, 3); // RX, TX

void setup()  
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, HIGH);
  digitalWrite(LED_PIN, LOW);

  // Open serial communications and wait for port to open:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only

  Serial.println("SETUP Arduino");

  // set the data rate for the SoftwareSerial port

char beacon[]="abcdef";
char answer[]="fedcba";

char input[]="000000";

unsigned long timeLastSend = 0;
unsigned long led_on_time = 0;
unsigned i=0;

void loop() // run over and over
	unsigned char c;

	if (millis() > timeLastSend){

		timeLastSend = millis()+SEND_DELAY;

		led_on_time = millis()+200;
		digitalWrite(LED_PIN, HIGH);

		Serial.println("Sending beacon...");

	if (millis() > led_on_time){
		digitalWrite(LED_PIN, LOW);

	if (mySerial.available()){
		c =;


		if ( c == answer[0]){
		}else if(i > 0){
				input[i] = c;
	if ( i >= strlen(beacon)){
			if (strcmp(input, answer) == 0){
			digitalWrite(LED_PIN, HIGH);
			led_on_time = millis()+700;
			Serial.println("GOT BEACON");
			Serial.println("beacon failed...");

These sources aren’t exactly well tested and thoughtfully written. I thought of making both send and flash only when a beacon was received, would be simpler than answering beacons with another text. Possibly could also have used the same code on both of them.

Please comment if I’ve commited a serious mistake 😀

I tested them at home with no clear sight but with open path for about 10-15 meters. The Arduino was connected to my notebook and the Teensy to my S3 through OTG.

I still have to discover how to customize bitrate of the XRFs and test greater distances with direct path but haven’t had the chance.

EDIT: I know how to edit the bitrates and other config, just enter “+++” on the serial with the XRF, write nothing for a second at it should enter config mode, answering with a OK. Then send your favorite “AT” commands… just haven’t had the opportunity to reprocude these steps for various reasons. (Correct me if any of those directions was wrong hahaha)


Part 2: XRF, Teensy 2.0 and Xbee adaptor

So I had two XRFs modules, only one XBee adapter to use them with, which was unfortunately only working via serial, though still better than nothing.

I already had a Teensy, so I ordered a Xbee adaptor ( for it and two XBBOs from Ciseco. I’d certainly wouldn’t need more after this. (LOL, do need, want a XBee Explorer from Sparkfun)

Finally arrived, wasn’t so fun soldering the SMT parts on the board with a soldering iron and far too thick solder.. but seems I managed fine.

The XRF, the soldered Adaptor and the Teensy with Sockets.

The three connected.

The thing is, the Teensy is sold with pins… for breadboard connecting. And the XBee Adaptor is sold also with pins.. why? Thankfully I had a normal teensy (without pins or sockets) so I had ordered sockets too. Learned my lesson from last time.

Soldering the XBBOs took a bit longer, they have a lot more components but thankfully no SMT.

XBBO from Ciseco

Sadly the Teensy is now quite bit bigger with the sockets. Maybe I’ll order a new one for smaller purpouses which I had originally in mind. Would also have been VERY nice if the XBBOs had USB support…


Part 1: XRF, Bee Adapter v1.4 and Arduino

Trying to slowly assemble the hardware to build a quadcopter (sigh), I got myself a pair of Ciseco’s XRF modules and a Xbee USB Dongle (Bee Adapter v1.4).

XBee Adapter Back

XRF and XBee Adapter

(You can read more about the XRF modules here:

The Ciseco XRFs are nice little buggers, they work at various frequencies, in the 1KHz range. I find this great because it’s far away from the 2.4GHz noise (microwave, wireless phone stations, wifi and bluetooth). Sure, it may be illegal or require a license in your country but who cares? (Actually, readers that live in more developed and orderly parts of the world, YOU should…)
The XRFs are very nice, since they have the form and pins of the Zigbees (Xbees, whatever), so you practically can use one wherever you’d use a Xbee. Just for a much lower price and various frequencies.

Since my project involved sometime being able to use an Android Phone with the XRFs, I bought the Bee Adapter from, which has serial and usb access. The Arduino I had bought a while ago, just upgraded it with a prototyping shield.

Notice something is missing? Yeah, it so happens that I completely forgot that to do anything with the modules, I’d need to connect the TWO of them. But I only bought one adapter. Genius, right?

Even so, they finally arrived. Shipping from the UK to Brazil is actually quite fast. From HK or US it’d probably get stuck in customs for a while…

The Bee Adapter was a bit different from the picture at DX, though seemed legit. Got two toggles that let you choose between High/Low, which seems to be power consumption, and 3v3/5v.

XBee Adapter Back

XBee Adapter Back

So! Let’s connect’em… Power levels fail via usb… power status led barely shines with the XRF module… Hmmm, XRF module must be using a lot of power! (shouldn’t but who knows..) So I plugged it in my newest Prototyping shield, wired up the serial connectors and blam… It worked fine with the Arduino. Tested it for the +++ command which get’s it to enter the config mode, it sends OK.

XBee Adapter Back

Arduino with Prototyping shield, Xbee Adapter and XRF module.

Great little adapter doesn’t work via USB… I’d guess it needs a current limiter, didn’t care to debug it…

Aaaaand there was the need for the other adapter more than ever, specially because the Xbee modules pins are not breadboard compatible…yay…


The Galaxy S3 faults and problems

I’ve had the Samsung Galaxy S3 now for a few months and am somewhat satisfied with it. Even more since I previously was using that XT300(and still am as a secondary phone) which is far from the leading phones.

So, as I said, I somewhat satisfied. The 4.1 update was nice; project butter, the more complex notifications and Google Now are interesting features which make Android a better OS.

The problem is that with new features there are always unexpected/undocumented/unwanted features, aka. Bugs. One of the most annoying is that now it takes a while to wake the phone, pressing home or power, a few seconds, just to make one of the strongest phones in the market appear to lag. Also now when waking up the phone with the home button, it actually does go to home, forcing you to go to the app that was in foreground at the time once more.

Since the last update the phone has been freezing and rebooting automatically more than I’d like, I’m thinking of wiping the phone and seeing if the problems continue. Starting of having thoughts of flashing another rom. I don’t really want that since new problems normally come up, like instability, bad hardware support(slow video playback, camera stops working and such problems) and recurrent rom changes until I finally find one that works more or less.

I’ve been having problems with my SanDisk 32GB Class 10 U1 microSDHC card, which was slowly dying on me. It started with my netbook (Asus Eee PC 1005HA) having problems writing to it (I/O problem with something about cluster chain). On the phone it worked fine for a while but I started noticing that the card kept remounting (notification icon flashing) whenever I woke the phone. After a while it started claiming that I had a blank card and would not mount.

My computer displayed only sdb and not sdb1, fdisk and mount complained that /dev/sdb had no medium.

Keeping it off for a few days and plugging the card back in fixed the problem for a few hours, after that the same problem occurred.

I’m currently in contact with SanDisk support and seems I will get replaced, perhaps. I bought the thing on eBay  from a reputable seller, but you know… they say EVERY memory chip on eBay is counterfeit.. hehehe.

I’m using a 1 GB just for kicks that I had lying around and the remounting problem does not occur with it. Hopefully it doesn’t die on me also.

I found an interesting post regarding a similar issue. I do not know if it is really true or not, and probably will void your warranty..

XDA:”SD Card Unexpectedly Removed” hardware issue solved

Other than that, I still have a few rants complaints about the casing and screen. I keep my phone almost always in my pocket and on the table. I hate those protective screens and cases. The make the phone bulgier and the touch screen gets a plastic feeling. Unfortunately the back cover of my phone has already a lot of small scratches which make a few spots already seem dull, instead of the reflective “pebble blue”. Around the headphone jack there are bits chipping off. And, of course, GorillaGlass 2 is not up to it’s name. There is already a small nick on the screen.

There is one thing that surprised me a lot in this phone. The GPS. It’s one thing I can’t complain about. Together with GLONASS, the lock on is very fast and works (somewhat) indoors too!

Here is a comparison of the Galaxy S2 and a Galaxy S3:

S2 vs S3

S3 on the left and S2 on the right

It’s not that I regret having paid a lot of money for the phone ( about $900 at the time), tough I’d thought I’d have a better experience with it.

Maybe next time I’ll learn and buy an iPhone 😛 not a chance!

That’s it for my rants… I have to get back to posting useful guides/texts.


Galaxy S3 access files in Linux

I’ve gotten myself a Samsung Galaxy S3 recently, and wanted to change the ringtones and upload some music.

The problem is, I use mainly linux (read: ‘I don’t have Windows’).

So what with the MTP/PTP?

Apparently libmtp and jmtpfs don’t work with the S3 very well. The error is something like:

$ mtp-detect
libmtp version: 1.1.3

Listing raw device(s)
Device 0 (VID=04e8 and PID=6860) is a Samsung GT-P7310/P7510/N7000/I9100/Galaxy Tab 7.7/10.1/S2/Nexus/Note.
Found 1 device(s):
Samsung: GT-P7310/P7510/N7000/I9100/Galaxy Tab 7.7/10.1/S2/Nexus/Note (04e8:6860) @ bus 2, dev 21
Attempting to connect device(s)
PTP_ERROR_IO: failed to open session, trying again after resetting USB interface
LIBMTP libusb: Attempt to reset device
LIBMTP PANIC: failed to open session on second attempt
Unable to open raw device 0

And since Kies is not available for linux (afaik) and running it on Wine is not really something I’m fond of, I had been searching for a way to access the phones files in a fast way.

There is a way, through rooting your phone, and installing an app, but my phone is new so I didn’t want that…yet 😀

Since the access would have to be fast to be of my liking, it would have to be through USB cable, not Wifi. So I would probably have to do sth with ADB (Android Debug Bridge, google it)..

There is an adbfs solution already there:

But it seems to be extremely slow. Adb was NOT designed for this kind of usage (continuous I/O access).

So I went on using an app I already knew, SSHDroid:

But doesn’t this create a SSH server for remote shell login? Yeah, kinda does… but it’s SSH! This means you can run SSHFS through it! And better, forward the listening port through ADB to your own machine, via USB cable, so no Wifi is needed.

Here are the steps:
1. Install SSHDroid and run it
2. With the phone connected via USB, test adb with

$adb devices

and see if it shows up
3. Forward the remote SSHDroid port to your machine with

$adb forward tcp:2222 tcp:2222

(2222 is the default SSHDroid port for none rooted phones)
4. Mount sshfs on your machine with:

$sshfs -p 2222 root@localhost:/mnt/ >mount point, like ~/Desktop/sshfs<

The default password should be admin, if you haven’t changed it. YOU SHOULD HAVE!
5. Done! On my Arch, nautilus did not want to unmount it, so I ran

$fusermount -u <mount point, like ~/Desktop/sshfs>

As always, don’t trust what I tell you to do, just some guidelines to be able to find a similar, if not the same, solution. Have in mind that the steps here are not idiot-proof, I expect that people at least be able to use google and the basics of linux, like installing sshfs.

UPDATE (2013-04-12):
I decided to try again using the S3 with MTP and installed go-mtpfs on Arch.

After adding me as owner to udev rule, it seems to work but has some bugs:

$ touch test
touch: failed to close ‘test’: Invalid argument

but the file shows up:

$ ls
BKP clockworkmod data DCIM Downloads LOST.DIR MOV07784.MPG Roms test Tools

$ cat test
cat: test: Invalid argument

removing it works fine…

mtpfs still doesn’t work… either with

$ mtfps ~/s3/


# mtfps -o allow_other /home/oliver/s3/

Just does nothing.

simple-mtfps seems to work fine, will test it further! (available in AUR from Arch or

Showing the devices:

$ simple-mtpfs -l
Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP).
Unable to open ~/.mtpz-data for reading, MTPZ disabled.1: SamsungGalaxy models (MTP)


$ simple-mtpfs –device 1 s3/
Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP).

Unmounting (obvious):

$ fusermount -u /home/oliver/s3

It is recomended not running simple-mtfps as root, as always… but nice that it doesn’t need to run as root 😀

Touching, displaying and removing files from both Phone and Card directories worked flawlessly.
Though I did not do a stress test on this method. Will try to pass some gigs later 😀

Seems jmtpfs is working too! Some time that I haven’t tried it. Another solution, I prefer simple-mtpfs though for more options, listing and specifying the device to be mounted.


Failed 1005ha battery mod

In the end of 2009 I bought my Asus Eee pc 1005ha netbook. It’s pretty good for what it is designed for. Have no complaints, just that the cpu could be a newer Intel Atom model.(Which would support 64bits OS’ and some virtualization options.)

Having used it heavily for more than a year and not really trying to save my battery life, the same has gone down the drain. From the advertised 8 hours, 6 hours good use to now less than an hour. Time to buy a new one.

I saw some batteries with 7200 mAh at eBay. Almost double the power my original battery had, which was 4800mAh. And they were sold for $40! I ended up buying one.

After receiving the battery I plugged it in my netbook and turned it on with the power supply connected.
Weird. The charging light(orange) flashed but stayed off. The BIOS froze at ‘Checking NVRAM’ for some time, but eventually continued. Ubuntu and Windows XP did not recognize the battery.
First thought: defective.

I browsed to the manufacturers(AGPTEK) website and voila, the battery shown in the site was different than mine! Did not have the logo, the battery text was upside down, and the voltage should be 10.8V instead of the 11.1V my new battery had.

I contacted the seller and, of course, I would have to send the battery back, which would cost the equivalent of $30 for a $40 refund. Of course I didn’t. I ended up loosing the dispute date in eBay, or else I would have disputed the payment.

Meanwhile, I decided to buy one from Amazon. Same price, same manufacturer. Should be safe.

Nope, I was wrong. Exactly the SAME battery arrived. And with the same behavior. Now I had two paperweights which I could not really use to power my netbook.

I gave up and put up a bet, all or nothing. I would replace the cells from the old battery with the ones from one of the new batteries. If it worked, I would have a working battery with huge capacity, or else I would have no working battery at all.

After finally managing to open the cases of the two battery packs, which were by no means designed to be opened ever again, I finally dis-soldered the cells and swapped the 6 pack for the new 9 pack. Put it halfway together and inserted it into the netbook while connected to the power supply.
(I recommend using a drill and CAREFULLY cutting into the edges of the battery that have been sealed, or use a heated knife.)

YAY! The charging light turned on! Thats a good start. I left the netbook charging for a bit. I kept checking the


files for any changes or status indications. Nothing.

I disconnected the power supply to test the battery. And my netbook powered of instantly….
I tried it again and got the same effect. The battery was not giving any juice. CRAP.

I looked it over to check if I had done something wrong or if there was some kind of sensor which had been triggered. Nada.
Oh well, time to put my old cell pack back into the battery.
After re-soldering the contacts and sticking the heat sensor back to one cell I tried it….
The same. No power.

YAY. No working battery. I wrapped both in tape to keep the pieces together and put the away. Had no more patience to keep fiddling with them.

It could be that without charge the circuit looses it’s memory or locks. If someone should try this, keep the circuit charged at all times, connecting the new battery pack in parallel first and then removing the old one.

Since I still had to use my netbook and did want to have a little liberty of mobility, I ended up plugging the second battery pack into it. Would have to find a work around with the BIOS issue.

So I was using the netbook for a time and noticed the charging light was ON. Rebooted, still had the BIOS issue and the charging light was off.

I insisted using the new battery for a time, and it ended up working perfectly after a while. Has a very good duration!
I was very confused about the apparent symbiosis the battery made with my netbook.. seems they take a while to understand each other.


Comparison of the old/original and new/chinese(lol) battery casing.(Obviously the old one has ASUS written on it).

The cells from the original battery.

The cells from the Agptek battery.

Front of the new Agptek battery control circuit. Casing below is from the new battery as well.

Back of the new Agptek battery control circuit. The heatsensor can be seen.

Front of the original battery control circuit connected to the new batteries cells.

Backside of the original battery control circuit

My original battery put back together. Purple wire is a substitution of the sheet/slab which I had to cut.

Sorry if this post seems heavy. Open the images in a new tab and you’ll see why.

Hope this helps someone who had the same problem/idea as I had.

The Author

Older Ramblings


Linux User Sig