Here’s a stable build for the serial-port-enabled kernel, finally! Get it at
http://forum.xda-developers.com/showthread.php?p=4521020#post4521020
and play safe!
What does it do? It lets you use the serial port present in the G1 phone for custom applications. Such as, I don’t know, robots
The main change from the older one, other than “it’s easier to install” because it doesn’t need the SDK, is that the older one had issues with wifi and bluetooth occasionally. This one on the other hand Just Works with most Cupcake based firmwares, just install it on top of the firmware. Here’s a good one from another Italian developer.
After seeing the excellent tutorial on Instructables on how to connect a serial cable to a G1 phone, I decided to do some followup work on that. I will post my own instructable on how to make your own serial port level shfter later — in the meantime, here’s a little treat: a 1.51 (Cupcake) kernel that lets you actually USE the serial port.
After unlocking your phone and downloading the Cupcake firmware or one of its variants (Cyanogen, JesusFreke and so on), you can try this kernel out by using fastboot (if you don’t know what that is, find an unlocking guide — you will after that!), as follows:
fastboot boot serialport_cupcake
This will let you use /dev/ttyMSM2 as a serial port. I’ve already hooked up a picaxe and servo to it, let’s see what you do
given the compass, accelerometer and GPS in the g1 phone the navigational applications are obvious…
If you want the technical discussion, I’ve contributed to a thread here. There’s also a config file if you want to build your own.
UPDATE:
Here’s the boot image you can use to flash your gphone with the serial port enabled: you can use fastboot to load the kernel without having to do so at every boot.
Get your phone into fastboot then use
fastboot flash:raw boot kernel_cupcake_serialport kernel_ramdisk_standard
to restore, use
fastboot flash:raw boot kernel_cupcake_standard kernel_ramdisk_standard
… especially when you have to contend with the limitations of whatever little microcontroller you’re working with; a lot of micros don’t have trig functions or only have sin/cos/tan. Atan2 is a fundamental function in navigation (it lets you turn two pairs of coordinates, for example where you are and where you’re going, into a heading, for example which way to turn how to get there) but if it’s there it tends to be slow as most microcontrollers don’t have lookup tables for it. You can do Taylor expansion, but it’s very slow — and on microcontrollers that can only do integer math precision is lost very quickly.
With this in mind, I had to come up with ways to approximate atan2 quickly and precisely enough to drive or sail by.
http://spirit-plumber.com/portfolio/math/fastatan2.htm
You can use this formula with a microcontroller that can handle 32 bit floating point numbers, such as the Parallax Propeller. If you’re limited to an even smaller system (say, a Basic Stamp or Picaxe or PIC micro) here’s the 16 bit integer version, accurate to 1 degree in most cases.
http://spirit-plumber.com/portfolio/math/fastatan2_integer.htm
Why the emphasis on using as few divisions as possible? Because micros generally have to do “long division in their head” by means of repeated subtraction; division generally takes long compared to other operations.