SQUARISM addicted to pixels

iPadDC 2010

Posted on April 17, 2010

Some notes from the 2010 iPadDC conference, I typed as fast as I could. 2nd annual iPhone OS barcamp style un-conference with many good speakers and donuts. Yum.

Full slides might be available under the #iPadDC hashtag.

Rob Rhyne @capttaco

iPad UI Design

Walter Gropius, founded the Bauhaus.
He loved Claire De Lune from Ocean's Eleven, builds up in fountain scene.
Find the simple.
Discover the hook and bust your ass to make your app enjoyable.
When in doubt, polish.
Demo'd his mock up/wireframe iPhone app Brief. Really looks nice. http://giveabrief.com/
Ruby based BS script for mock up movement.
Mentioned we should check out a Brett Victor mock up talk at WWDC. Video might be hard to find.

Nic Schlueter @schlu

Pleasing Everyone

blog.simpltry.com
Taxi Magic (super awesome), PM Android and WebOS
JSConf
Very cool taxi booking and payment app.
Order of market importance
iPhone -> Android -> Blackberry -> iPad -> WebOS -> WinMobile Phone 7 -> WinMobile 6.5
Basically WinMobile is dead.

Things to worry about
- Isms (metaphors per platform)
- Cross Device Within Platform
- Location
- Multitasking
- App Stores

Androidisms
Back button kills app. Home keeps it alive. These are hardware buttons so this is the way it is. You can't disable this. Android phones don't get latest versions of the OS. And they don't care because they're going to sell a newer phone. So you have to support old OS's.

BlackBerryism
- Learn to love the menus
- Hardware back button
- T-Mobile users prepare for pain
- Blackberry users never upgrade their OS
- Very low expectations

WebOSisms
- hardware back
- software swipe down menu, supported by almost all apps
- most similar to iPhone

Platform Quirks (deep dive)
Android
- screen resolution
- biggest challenge
- must support landscape if you want cred!
- watch the font size
- large variety in PPI and resolution in phones
- so you have to use different pixel density features of fonts?
- Which OS to Target
- 1.6 unless you have a good reason
- 6-9 mo you can safely target 2.0 or 2.1
- expensive to test old devices (subscriptions)
- device manufacturers don't make it a priority to update device OS

Blackberry
- layout manager not quite as flexible as Android, you have to do lots of detection on your end
- Currently a lot of resolutions
- In the future, should be less than Android
- Which OS to target. The Blackberry App World allows you to submit apps targeted from 4.2.1+.
- Enterprises might want you to target older devices.
- Too many threads bug
- 6-7 threads seem to be the max. Nasty. A problem on older BBs.

Future Proof
- build support into your price
- either the app is going to suck or you'll be broke if you don't
- unreleased phones will break your app

T-Mobile
- some crazy APN process to enable 3rd party internet support on your app

BB partner
$2000/year to be a partner. They'll send source code. 1-on-1 support person. If you're serious about BB, it's worth it.

WebOS
- multi-resolutions, not that bad. It's all CSS3.
- Bottom position sticky to the bottom.
- PDK makes games fairly trivial. C & C++ are easily portable.
- Single threaded, not a problem with Ajax async for network calls etc.
- Ares web based IDE developing in the browser.
- Is it worth it? Probably not. Still better than WindowsMobile! HAHA

iPhone location services are awesome, spoiled. Others aren't as good. The Droid rate limits how frequently you can get a location. Even between app restarts. Check time on the last known location. Nasty behavior for him to figure out.

BB Location. Slow GPS only. Not on older phones.
WebOS Location is basically fine.

Multitasking
- Do not do things that kill the battery. Location or network.
- Consider the user experience if a user comes back to a screen days later.
Android
- full access
- prog con running
- save state when users leave app
- your app gets killed in low mem situtations
BB
- full access
- your prog con running
- do what you want (spawn, background, you can watch sms/email - poor man's push)
WebOS
- full access
- won't kill your app, prevents users from starting a new app if too much mem in use
- You must have a card or icon when running in bg, or prepare to be killed

App Stores
Apple - submit, wait, pray (14 days to 24 hours to 3 days). Apple is the only one with identifiers for betas. 70/30
Android - no permission, 325 character description limit, can only sell from certain countries. Money collected from Google Checkout. Betas run from your own server. Free to publish. 70/30
Blackberry - 3ish day approval time. $2.99 minimum price. Betas run through your own server. $200 per app. 80/20 split
WebOS - 5ish day approval. $50 per app. 70/30.

Dana Nuon @wdnuon

iBooks Page Curl in Six Lines of Code

Transforming page by page turning with deformation. Method returns a vector which is applied to a flat matrix. Each vertex in a matrix has an X/Y. The function adds a Z.

He basically showed how to implement the Apple iBook page turn effect in six lines of code using a Xerox algorithm from a one page PDF with some super heavy conic math. Super awesome demos he had. He's been doing this stuff for a while. Very experienced, very nice chats after his talk.

Luis de la Rosa @louielouie

Seven Ways to Improve Your App with Servers

Pro: Access more data, differentiate
Con: More work, maintenance

JSON vs XML
JSON - smaller, more efficient - TouchJSON
XML - built-in, ubiquitous - TouchXML
runner-ups: plist (no server will recognize this), custom binary

API enables community (high score list). More processing power (upload image to amazon mechanical turk)

Debugging. Inspect traffic. Charles Proxy. Adjust WiFi proxy preference. Debug with proxy.

Push notification: Your Server -> Apple Push Server -> iPad -> Popup: Your App: Hello World!
- Registration
- Push message, badge, sound. Message 5lines, 24 char
- Best Practice, custom data to highlight item. Push some JSON to highlight.

In-App Purchase
Three types:
- Consumable (example: uBoot torpedos).
- Non-consumable (ie: uBoot levels) - usually built-in
- Subscriptions (magazine)

In-App Purchase Server Product Model
- App store handles CC but then passes it to you.
iPad -> App Store -> Your Server -> iPad

Sync
User data survives data / app loss. Or enable multiple devices per user. Out of scope: WiFi Sync (sync to mac) + GameKit (P2P)

Analytics
- Track usage
- Easy to setup
- Best practice: Send specific custom data (which level are people playing the most?)
- Best practice: Crash handler

Advertising
- Make money with free app
- Design: Dedicate some space
- Animation may help

How to implement
- Hire a consultant like Happy Apps
- DIY
- 3rd party providers like Millennial Media
- Apple (they don't do much)

Christopher Brown

iPad Advertising

Answered questions and talked about how to do analytics, marketing, ads and what iAds might affect the space. He had solid metrics and graphs that I can't type out like he did last year with his Tap Metrics talk.

David Smith

14 Days and 11 Apps Later

An amazing walkthrough his flurry of app submissions. He walked through ideas he and his team had for the iPad, demo'd his ELEVEN APPS and showed sales results. Shotgun approach gets a bit of cash but not really going to start a business. He had a lot of great insight like, "it's not about making money but about getting your $99 worth and learning". I'm not doing his talk justice. Cool guy.

James Norton @jnorton

OpenGL ES 2.0 & the OpenGL Shading Language

Graphics Pipeline
Why 2.0?
- Programmable shaders enable things that are difficult or impossible without them
- Computations in the GPU
- Can free up memory by replacing static textures

Shaders (introduced in 2.0)
- Vertex Shaders operate on vertex data (attributes)
- Enables CPU to offload many vertex computations to GPU
- Fragment Shaders operate on fragment (pixel) data
- Allow per-pixel effects like per-pixel lighting, procedural textures (bump mapping or env mapping), noise, etc

Shading Language
- Based on C
- Variables, structures, arrays, operators, functions, flow control
- Additional types to support gfx operations (vectors and matrices)

Differences from C
- Stricter type conversions
- No pointers
- Function parameters can be qualified with modification: in (default), inout, out
- For loopers require iteration count to be known at compile time
- Array indices must be constants

Variable Types
- Scalars - float, int, bool

Vectors and Matrices
- Ops work with vec and matrices too
- Multiplication op handles vec matrix and mat/matrix multiplies correctly
- Math ops likely to be HW accel
- Position component access

vec2 pos = vec2(0,1.0)
float xPost = pos.x;
float yPos = pos.y;

Variable Constructors
vec2 texCoord = vec2(0.5, 0.5);

Type conversion
int count = 4;
float fCount = float(count);

Flexible
vec3 pos = vec3(1.0,1.0,1.0);
vec2 something = vec2(pos);

Precision Qualifiers
lowp,mediump,highp (high precision)
highp vec4 color;
MUST declare default or per var precision for float in frag shaders

Type Modifiers
- Uniforms - readonly variables passed in by the application
- Attributes - per-vertex input to the vertex shader
- Varyings - user to communicate form vertex shaders to fragment shader

Simple Shaders
Vertex Shader
attribute vec4 position;
attribute vec2 texCoord;
varying vec2 fTexCoord;

void main(void) {
gl_Position = position; // no view transformation
fTexCoord = texCoord; // will be linearly interpolated
}

Fragment Shader
precision highp float;
varying vec2 fTexCoord;

uniform sampler2D myTextureSampler;

void main(void) {
gl_FragColor = texture2D(myTextureSampler,fTexCoord);
}

TV Noise Fade in Demo
Sigmoid Function: s(t) = 1 / (1 + e^ -f(t-t0) )
Vertex Shader simply passes position to gl_Position like before.

Fragment Shader preample
precision highp float; // use high p as defaulit for floats
uniforma smapler2D test_pattern_texture; // texture sampler for text patter
uniform highp float time; //time since animation start
varying highp vec2 vTexCoord;

void main() {
float weight = sigmoid(time);
float randStatic = rand(vTextCoord);
float randDynamic = rand(vec2(randStatic,weight));
vec4 texVal = texture2D(test_pattern_texture, vTexCoord);
//don't add noise to the black border
if(textVal != vec4(0,0,0,1)){
gl_FragColor = weight * texVal + (12.0 - weight) * randDynamic;
} else {
gl_FragColor = texVal;
}
}

// sigmoid function
float sigmoid(highp float t) {
float f = 10.0;
float t0 = 1.25;
return 1.0 / (1.0 + exp(f * -(t - t0)));
}

// pseudo random number generator
float rand(highp vec2 pos){
return fract(sin(dot(pos, vec2(12.0909, 78 ....
}

Final Thoughts
- OpenGL ES 2.0 allows developers more flexibility than OpenGL ES 1.1. Only will run on 3GS, iPad
- Gold book (the purple book).
- Orange book later for advanced.

Filed under: Blog No Comments

How to pair a Bluetooth Keyboard with an iPad

Posted on April 3, 2010


I figured out something that was a bit unintuitive. I have an Apple Wireless Bluetooth keyboard paired with a Mac. I wanted to see if it works on my iPad. I went to Bluetooth->Disconnect on the Mac and the keyboard showed up in the iPad Bluetooth discovery screen but it wouldn't pair.

I just happened to find a method to get this working:

  • Select disconnect on the Mac.
  • Turn off bluetooth completely on the Mac.
  • Hold down the power button on the keyboard to turn it off.
  • Press the power button once on the keyboard to turn it on.
  • The keyboard will show up in the iPad bluetooth list as before but now when you click it, the keyboard light will start flashing as it pairs.
  • The iPad will tell you to type a code and enter.
  • Good to go!

It works for text areas in the browser and email windows. The on-screen keyboard doesn't appear. It's way faster to enter a blog post like this (hehe). It doesn't seem to work for navigating menus (with the arrow keys or anything). Think of it as a replacement for the on screen keyboard.

Also, be aware that you do have to unpair with the computer. Pairing means 1-to-1. Not 1-to-many. This is how bluetooth (even on PC) works unfortunately. If you want to broadcast keyboard strokes out to many computers you'll have to use something like VNC. Unfortunately there isn't a VNC server that I know of for the iPad yet (if ever). The iPhone versions of VNC require you to jailbreak your phone which can be a pain if you like "quick and easy". I rarely use my bluetooth keyboard on my media center so I didn't buy a second one. Your mileage may vary.

Hope this helps someone! Post a comment if it did.

Filed under: Blog 7 Comments

iPadcolypse

Posted on April 3, 2010

The Wiff was using the yahoo tv guide (free app) and wants one. It's got potential as a living room multitasker thingy. I got the 32gb. The 64gb is useless because you still have to pick your media you want to sync. Maybe the 16gb would have been better but I wanted to cram a bunch of stuff on it. If they had a 1TB one (lol) then you could sync your whole iTunes library and movies etc etc. I wish it had an SD slot and some other expansion stuff on it. Like it just mounting up as a disk.

But I did grab an app called "GoodReader". It'll probably be replaced by something better (a lot of apps are rushed first to market attempts) but it has DropBox download support (not sync). So I just threw my ebook PDFs (like from other publishers such as PragProg other than the Kindle) and that's how I got PDFs on it.

Among the star apps so far:
- Kindle app (free), pretty nice. Nicer than the Kindle. I wish it had two page view like iBooks does. iBooks doesn't have shit for selection right now. No tech books. All my tech books are in the Kindle store or PDF.
- Twitterific (widscreen is the best mode, probably more improvements later)
- NY Times (please release digital Wired mag like this)
- Yahoo Entertainment app
- ABC app, plays episodes in crappy SD but free
- Weatherbug (super slick Radar and forecast all in one huge data overload view)
- Evernote (online notebook). Not as slick as it should be. No formatting options while editing.
- BBC news (meh kinda redudant)
- Plants vs Zombies (PvZ), perfect port

All the official apps are super polished. I haven't bought the iLife suite apps. I don't think I need them (maybe I will at work?). I'm waiting for a few of my favorite devs to update their apps:
- Mint
- IRC chat called FlowChat
- Lux Touch (woo multitouch strategy)
- Some kind of SSH awesomeness.
- Ruler app (just because I could measure bigger things?)
- Official facebook app
- How about a WoW auction app?!?! COME ON! Even if I don't play.

Many apps are $10. So I'm holding out for more free competition.

There's a scrabble app that plays with your phone. You put your tiles on your phone as the tile rack so you can hide your letters. Everyone plays on the iPad. I haven't tried it but what a great idea! I'd like to see the MS Surface stuff on these devices like that. Imagine some geeky strategy game or RPG. Or Battleship.

I have to figure out how to sync my calendar and all the stuff I set up on my phone. I'm trying to keep the two devices separate. For example, I don't need any apps that scan barcodes because it doesn't have a camera. :P

I'm surprised how fast this thing is. I see why so many games are coming out. Sorry for the short write-up but I'm in toy overload mode.

Filed under: Blog 2 Comments

Dokuwiki April Fools 2010

Posted on April 1, 2010

I was checking out some syntax on dokuwiki's website and suddenly a duck appeared from the right hand side. When I hovered over it, I got a web browser crosshair. When I clicked on it (*bang*), a bullet hole image appeared in the web page and the duck (*quack*) fell to the bottom of the browser window.

Duck hunt!

I didn't see it blogged about yet so there ya go. Techcrunch has a good wrap-up of 2010 april fool's jokes. This year didn't seem as big as last year's.

Filed under: Blog No Comments

RMagic, ImageMagick, Snow Leopard and Ruby 1.9

Posted on March 8, 2010

I ran into a problem that kept me busy over the weekend. It seems that rmagick (which is requires for the awesome sparklines project will compile and run on Snow Leopard, however it has a critical bug when trying to use it. The script/server process will crash with a "Trace/BPT trap" error. The logs won't say anything and the hell if anything is going to appear on the browser. WTF.

Here's my stack on my Mac: (do not use this stack, this is just for informational purposes only)

  • ruby19 installed via macports: sudo install ruby19
  • regular rubygems installed
  • ImageMagick 6.6.0-0 installed via macports
  • A bunch of github gems installed but not firing on the controller method that crashes

So I started over on a CentOS 5.4 VM just to try out my stack and it worked. Except, I used ruby 1.8.7 compiled via source. It's a really lengthy process and it'll be part of my README if I ever get this project done. On CentOS you have to compile and install ImageMagick yourself because yum has a really old version. There's a ton of devel dependencies too. If anyone needs the instructions, leave a comment and I'll copy/paste from my README.

So I suspected that ruby 1.9 was causing problems my mac laptop and that turned out to be true. I did a sudo port uninstall ruby19 and then a sudo port install ruby. I had to reinstall all the gems again but it wasn't too bad. If port gives you a ln error, just exit your shell and open a new one.

So RMagick, ImageMagick and ruby 1.9 do not play together.

Filed under: Mac, Ruby No Comments

Goddamn Solaris

Posted on March 6, 2010

sun_expensive
Solaris is a rock-solid serious OS with a dependable hardware platform. Sun has always been solid technically. Sun pours a lot of good tech into Solaris. ZFS is amazing. Dtrace is revolutionary. Zones are flexible and lightweight. They're doing good engineering all around in a crazy number of areas. But we're going to temporarily ignore those things and talk about why Solaris is horrifying. Hopefully Oracle can fix a number of these Goddamn Problems™. If not, maybe OpenSolaris will/has.

I'm open to counter-points except for the argument "but you can change it". I know a lot of this is configurable (like adding packages or editing the default files) but that's not the point. Linux comes out of the box "right" or most specifically, easier/better. It's especially annoying because Sun boxes are so much more expensive and are sooo close to perfection. And many times the box isn't yours or the baseline isn't yours so you can't just add packages or reconfigure a global config file.

1. Default Bash Prompt.
Seriously, -bash-3.00# in 2010? Which box am I on? I don't know! What directory am I in? Every box, I edit /etc/profile to have export PS1='[\u@\h \W]\$ '

2. No `locate'.
Everyone does a find /. Yay. I love waiting 5 minutes to find one file. In linux, I schedule updatedb at 2am and find files sub-second.

3. No `screen'.
Greatest command in the world and it's an optional install from sunfreeware. So I have a crappy default term program and no way to start processes except with nohup command &. Boo.

4. Solaris tar is stupid.
Can't have filenames greater than 100 characters. Ok, use gtar. Great. Gtar doesn't do bzip or gzip on the fly. Argh. Why can't Solaris just include and use exclusively GNU tar (as well as everything else GNU)?!

5. No network package installs
Yum is great. Aptitude is better. Emerge is slow and dangerous (try moving between major Gentoo profiles). But at least I can download packages from the net on the fly. Ubuntu even tells me what to install when a command isn't found!

6. You know what I meant Mr. Picky.
If I type ls file -l I get -l: No such file or directory and then a non-long file return. Because it thinks I meant "show me two files file and -l". When you type a command in Solaris and forget to put a switch on, you're doomed to Ctrl-A, insert the switch and make it look like ls -l file. In Linux, it knows what you meant. Most core commands are more flexible in this way under Linux. It's goddamn maddening when you go back to Solaris.

7. UFS is pathetic.
ZFS is pure bliss but it's tricky to put on your root partition. You can't do it during the default install and you have to migrate everything. Which is not only complicated but hard to do if you have UFS permissions all over the place (next point). Also, UFS logging should be the default. I don't want to do fsck checks if my box crashes. Really. W(hy)TF isn't logging the default? Who doesn't want journaling on?! What's the drawback?! *head asplode*

8. ACL translations
The problem with migrating is that fine-grained POSIX ACLs (UFS) aren't compatible with ZFS ACLs. You control POSIX ACLs on UFS with setfacl & getfacl. You control ACLs on ZFS with chmod. The two commands are very different in syntax. So you have to "port" them. Which is especially maddening if you do a `man get_acl'. There's a goddamn C system call that can translate the ACLs built into the OS! How do you think this works?
cp /zfs/my_file /ufs/

The OS doesn't strip the extended ACLs off the file when it appears in /ufs/my_file! The capability is in the OS but it's not exposed as a command or another acl_translate call. You'd have to write your own utility ... hmm. Maybe that's a project.

9. Embrace GCC plz
GCC can do a zillion things more than CC. Get rid of CC, embrace GNU. Keep format, keep whatever bios-replacement commands you want. Keep the nice stuff from Solaris but please don't try to compete with better GNU utilities that already are switch compatible with Solaris tools. Some of these GNU binaries are literally drop-in replacements with Solaris compatible switches. And even if not, make Solaris 11 a GNU platform milestone and let customers decide if they want to upgrade.

10. X11, CDE, openwin
I love the new /SP/console and LOM stuff. I love the console architecture. I love all the things that PCs can't do (unless you buy Vendor specific add-in cards). I do not love CDE (yes Gnome is there) and OpenWindows. /usr/openwin/bin/xclock should not be the path to xclock. xclock should be in my default /usr/bin/ path and Xorg should be the only X11 anything anywhere. I'm sick of not having Xnest and all the other awesome Linux standard tools.

11. netstat -pan doesn't work.
Solaris netstat won't show me the process number of a network port. This is heresy. Just add the goddamn -p. Do you know how useful it is to do something like netstat -pan | grep `ps -ef|grep -v grep |grep java | awk '{print $2}'` | grep LISTEN is? Works on Linux. Bam! All the java listening ports. Done. Great for security, debugging and scripting.

12. Solaris ps -ef is stupid.
Linux ps auxww is God. GNU ps rules. Holy ass this is annoying on Solaris.

13. No top.
All you get is prstat. Linux (some distros) has this awesome improvement on top called htop. Htop lets you nice, kill and highlight processes. It's really great but I'd be happy with top on default Solaris installs. Even my Mac has top on it. I'd love to know why adding a binary in /usr/bin is so hard. Does it break some other command called top? Do things detect top in the $PATH and set Linux mode to true?

*breathe*

Rants are great. By the end of the list, I realize I'm nitpicking. But day in and day out, I'm praying to the Sun gods that they develops the absolute crap out of Solaris and get an amazing milestone together for Solaris 11 or Solaris 12 or whatever. Something that will appeal to ever-increasing Ubuntu and casual hacker community instead of reminiscing about legacy compatibility until x86 mediocrity makes the obscure Solaris way of doing things completely irrelevant.

I remember when Solaris didn't even have ssh by default. I guess this "behind" strategy continues. Maybe OpenSolaris can become the default on Sparc and people can stay behind until they feel like stepping into a different baseline. But even outside of packages and baselines, nice things left off (like UFS logging) by default is just maddening.

Filed under: Unix No Comments

Arduino command protocol

Posted on February 28, 2010

Here's my IRC Arduino Bot. It uses a regular Arduino 328 and an Ethernet Shield both from sparkfun. As for software, I'm using the Ethernet2 library (see my previous post about this), the WString library and a homerolled IRC protocol parser. The breadboard's power is connected to arbitrary pin 5 and some resistors to keep the LED from burning out.

arduino_irc_light

Basically, my bot joins an IRC channel and then listens for PRIVMSG commands starting with a password. It takes those commands and controls an LED. For example, I'd send this privately to the Arduino:
command password LEDON

And then the red LED comes on. I tell it "LEDOFF" and it turns off. Ok, it's not a new RFC spec worthy of IEEE recognition and international adoption. But it got the job done in a human-readable manner. Previously on my facebook status light project, I had done much of the processing on my laptop and only send hex codes to the Arduino to light up LEDs. The difference now is that the Arduino is doing the processing and no computer is needed.

While I was working on this little project, I had the bot join the channel and announce itself.
irc_log

At one point, I was working on code and then my bot would disconnect. I checked the serial monitor and the server seemed to drop me after a few minutes. The channel would say that I timed out. I realized that I wasn't responding to the PING from the server. So I threw in some code that checks for anything from the server that starts with "PING :". I then respond with "PONG". I remember seeing PING?/PONG! messages in mIRC back in the day. Now it makes sense why mIRC was doing that in the console window.

It works great and I was excited about how much this little board could do in 14KB. And then I kept testing it. After about 7 or 8 "turn on" and "turn off" commands, the Arduino wouldn't do anything anymore. It's like it just froze. If I typed 5 commands, it'd stay connected for a long time. But every time I'd send it 7 to 8 commands, it would lock up. And by lock up, I mean the commands wouldn't work anymore and it would time out from the server. WTF. So close!

So I figure that it's something to do with pointers and memory. I really don't have a solid grasp on pointers and C. I got a lot of this working by iterative experimentation over many days. So I was looking for a better way to send human readable commands to my bot. By human readable I mean something that works like a unix command "command arg1 arg2". Of course this human readable bit introduces strings which is tricky enough in C (for me) and even worse on the Arduino. I figured this was a problem that someone smarter than me had solved.

I found a library called Messenger. It's pretty simple to install, just throw it in your ~/Documents/Arduino/libraries folder on Mac and um ... the equivalent on Windows? There are examples in the Messenger folder that you can checkout. HOWEVER the whole point of me posting this big long thing is the following.

The example checkString really threw me for a loop. It did exactly what I need it do to in a much cleaner way. I uploaded to the Arduino and then broke out to a shell.

$ screen /dev/tty.usbserial-A9005bCr 115200

Substitute your virtual usb device for the /dev/tty path. Note that the sketch uses 115k serial speed. You won't see anything when you type but if you hit "enter" (to clear the buffer) "on[enter]" in screen LED 13 will turn on. Type "off[enter]" ([enter] means the enter key) and it will turn off. Great! Exactly what I need. But then I tried typing "on" then "off" then "muffins" then "on" and the light stayed off. Any garbage gets the Arduino stuck like my sketch. Ok, is what I'm trying to do impossible or is this just coincidence?

I modified the checkString example to look like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// This example demonstrates Messenger's checkString method
// It turns on the LED attached to pin 13 if it receives "on"
// It turns it off if it receives "off"
 
 
#include <messenger .h>
 
 
// Instantiate Messenger object with the message function and the default separator 
// (the space character)
Messenger message = Messenger(); 
 
 
// Define messenger function
void messageCompleted() {
  // This loop will echo each element of the message separately
  while ( message.available() ) {
    if ( message.checkString("on") ) {
      digitalWrite(13,HIGH);
    } else if ( message.checkString("off") ) {
      digitalWrite(13,LOW);
    } else {       // ADD THIS
      break;     // ADD THIS
    }                // ADD THIS
  }
 
 
}
 
void setup() {
  // Initiate Serial Communication
  Serial.begin(115200); 
  message.attach(messageCompleted);
 
  pinMode(13,OUTPUT);
 
}
 
void loop() {
 
  // The following line is the most effective way of 
  // feeding the serial data to Messenger
  while ( Serial.available() ) message.process( Serial.read() );
 
 
}
</messenger>

I added the break and it's able to deal with garbage. I tested more than 20 commands with banging on the keyboard in between and it seems pretty solid. Now I just need to integrate this with my IRC bot and I might have something that can stay online for a while.

By the way, after you use screen to connect to a serial port, hit "Ctrl+A, k" to kill the window and break out of screen.

Update: People have asked for the code. It's posted after the break.

Growl Network Notifications Not Working

Posted on February 27, 2010

Growl's network notifications weren't working. Either sending or receiving. I had two machines that had growl cleanly installed and my main machine that's had many versions installed over the years. It was my main box with a dirty growl history that was having problems.

I found a post on cocoaforge that helped a lot. First, I ran the uninstall applescript (I always keep uninstallers in ~/Uninstallers but you can find it in the Growl.dmg). That didn't really work, it gave me an Apple Script time out. So I removed everything manually. I deleted the pref pane from SysPrefs by right-clicking on Growl and selecting remove.

growl_remove

After that was done I removed the preferences file from ~/Library/Preferences and also a folder under ~/Library/Application Support called Growl (has two subfolders called Tickets and Plugins). I emptied trash. Reinstalled Growl 1.2 (latest). I didn't restart. I re-setup the network bit of Growl on this page:

growl_network

Notifications started working. Now all my boxes are notified when something cool happens. Weee!

Filed under: Mac No Comments

Basic 555 timer Arduino project

Posted on February 20, 2010

I put together the arduino protoshield from sparkfun. Excellent instructions at atomicsalad. Even though it's a standard through-hole kit, atomicsalad's instructions were nice to follow along.

After it was put together I had a few built-in LED lights to play with. I had seen this 555 timer in a piece kit I bought and I wondered what it does. I found a ton of examples and apparently you can do a zillion things with it. I wanted to start with the basics so I set out to make a light blink using only hardware. I'm only using the arduino for power in this one.

jump_breadboard_at_30
I found a great tutorial on youtube and modified it to work on a larger breadboard. I had some trouble because it turns out that this breadboard has its power rails split down the middle. I was confused and stuck on this for a day. Eventually I found a video that hinted at this fact and connected the two sides like so. After that, the power rails on each side will work like I expected. This is by design on these boards so that you can have two different voltages but I found it annoying.

So here's the schematic that I followed for the configuration on the big breadboard.
555_bb

I transferred this layout onto a mini breadboard and it works like a champ. The protoshield has room for a mini self-adhesive breadboard. Here's the actual wiring shot. This uses a light on the protoshield vs the light on the breadboard schematic. The concept is the same though. Pin3 on the 555 is the output which makes the light blink rapidly. You could use this chip as a cpu clock for example.
555_timer_wiring

You don't have to use the breadboard switch (the black thing on the left), it's just more convenient to flip a switch rather than plug in/out of the 3v. Oh yeah it's powered by 3v on the arduino. The cap is 100uf. You can use 2x orange,orange,maroon (gold) resistors or one of those and a blue,gray,maroon one (sorry I don't have the resistance values). Play with the resistor values to change the blink rate.

Filed under: Arduino No Comments

SCP vs RSync vs SMB vs FTP

Posted on February 11, 2010

@fearthepenguin made an rsync comment that made me curious. He said that rsync in cygwin is faster than native SMB in Windows. Ok I haven't done this test in a while, let's get a reminder about how fat SMB is.

Test Setup

SOHO gigabit switch. Ubuntu 9.10 and octo-core 2008 Mac Pro running 10.6. Both pretty fast boxes. Regular SATA drives in each, not very fast I/O. Whatever, network should be the bottleneck.

Get my test file generated.
$ dd if=/dev/zero of=1gb_file.zeros bs=1G count=1
1073741824 bytes (1.1 GB) copied, 133.577 s, 8.0 MB/s

Ignore that 8.0 MB/s. You can do a blocksize trick to make it output a file faster, I just didn't feel like looking up the switches. Now you can see Mr. 1GB Zero File in all it's empty and big glory.

$ ls -lh
total 1.2G
-rw-r--r-- 1 dude herd 1.0G 2010-02-11 12:29 1gb_file.zeros

The Tests

RSync
Copy from ubuntu box to Mac Pro:
$ time rsync -t /tmp/1gb_file.zeros dude@mac:~/tmp
real 0m17.694s
user 0m11.577s
sys 0m3.056s

SMB
Mount Mac share from Ubuntu box. Copy same file from ubuntu box to Mac Pro over SMB mount. I never do this. It's stupid, slow, strips permissions and requires a mount. In the name of science!
# time cp /tmp/1gb_file.zeros /mnt/tmp
real 0m32.649s
user 0m0.008s
sys 0m0.568s

FTP
Ok let's goddamn turn on OSX FTP and test that too. FTP is stupid.
The remote file "1gb_file.zeros" already exists.
Local: 1073741824 bytes, dated Thu 11 Feb 2010 12:29:06 PM EST.
(Files are identical, skipped)

Hey at least FTP is showing some smarts about it. Or maybe ncftp just rules. I dunno. Deleted it and got FTP time.

$ time ncftpput -u dude -p whoa mac /dest/tmp /tmp/1gb_file.zeros
/tmp/1gb_file.zeros: 1.00 GB 39.09 MB/s
real 0m26.507s
user 0m0.036s
sys 0m0.828s

SCP
Is SCP any different than rsync?
$ time scp /tmp/1gb_file.zeros dude@mac:~/tmp
1gb_file.zeros 100% 1024MB 42.7MB/s 00:24
real 0m24.303s
user 0m9.641s
sys 0m2.212s

Weird. It is. I wonder if rsync has compression flags whereas ssh does not without the -C magic switches. You can get SCP to be pretty quick with blowfish or arcfour:

$ time scp -c arcfour /tmp/1gb_file.zeros dude@mac:~/tmp
1gb_file.zeros 100% 1024MB 46.6MB/s 00:22
real 0m21.653s
user 0m5.452s
sys 0m2.032s

Conclusion
rsync SMB FTP SCP SCP arcfour
time 17.694 32.649 26.507 24.303 21.653
MB/sec 57.87 31.36 38.63 42.13 47.29

So RSync is pretty quick and SMB is pretty slow. @fearthepenguin was right.

Filed under: Blog No Comments