14 Feb 2012

Mmmmh, Raspberry Pi

It looks like we can soon play with the Raspberry Pi.

Their slogan: «An ARM GNU/Linux box for $25. Take a byte!»

The RasPi is an ARM based is a cheap education computer running various Operating Systems (Linux, Android, Risc OS, Risc iX and probably more). The board comes in two flavours; $25 without and $35 with ethernet (and 256MB instead of 128MB ram). This is great hardware for tinkering. It has a hand full of GPIO ports, SPI, I2C, UART, USB, Ethernet on board as well as a HDMI/Composite output.

 



 Spcifications


Model A Model B
Target price:[1] US$25 (GBP £16) US$35 (GBP £22)
System-on-a-chip (SoC):[1] Broadcom BCM2835 (CPU + GPU + SDRAM)
CPU: 700 MHz ARM11 ARM1176JZF-S core
GPU: Broadcom VideoCore IV,OpenGL ES 2.0,OpenVG 1080p30 H.264 high-profile encode/decode
Memory (SDRAM): 128 MiB 256 MiB
USB 2.0 ports: 1(provided by the BCM2835) 2 (via integrated USB hub)
Video outputs:[1] Composite video|Composite RCA, HDMI (not at the same time)
Audio outputs:[1] TRS connector|3.5 mm jack, HDMI
Audio inputs: none, but a USB mic or sound-card could be added
Onboard Storage: Secure Digital|SD / MMC / SDIO card slot
Onboard Network:[1] None 10/100 wired Ethernet RJ45
Low-level peripherals: General Purpose Input/Output (GPIO) pins, Serial Peripheral Interface Bus (SPI), I²C, I²S[2], Universal asynchronous receiver/transmitter (UART)
Real-time clock:[1] None
Power ratings (provisional, from alpha board): 500mA, (2.5 Watt) [1] 700mA, (3.5 Watt)
Power source:[1] 5V via Micro USB or GPIO header
Size: 85.60mm x 53.98mm[3] (3.370 × 2.125 inch)

(Provisional - some of the expansion interfaces won't be available on production boards) (PCB IDs are those of the Model B Beta board)
  • SoC: Broadcom BCM2835 media processor (partial datasheet, BCM2835 datasheet errata) system-on-chip featuring:
    • CPU core: ARM1176JZF-S ARM11 core clocked at 700MHz; ARM VFP. The ARM11 core implements the ARMv6 Architecture. For details on ARM instruction sets and naming conventions, see ARM architecrture and List of ARM microprocessor cores.
    • GPU core: a Broadcom VideoCore IV GPU providing OpenGL ES 1.1, OpenGL ES 2.0, hardware-accelerated OpenVG 1.1, Open EGL, OpenMAX and 1080p30 H.264 high-profile decode. There are 24 GFLOPS of general purpose compute and a bunch of texture filtering and DMA infrastructure. Eben worked on the architecture team for this and the Raspberry Pi team are looking at how they can make some of the proprietary features available to application programmers
    • DSP core: There is a DSP, but there isn't currently a public API (Liz thinks the BC team are keen to make one available at some point)
    • RAM: 128MiB (Model A) or 256MiB (Model B) of SDRAM. The RAM is physically stacked on top of the Broadcom media processor (package-on-package technology)
  • LAN9512 (Data Brief | Data Sheet)(Model B) providing:
    • 10/100Mb Ethernet (Auto-MDIX)[4]
    • 2x USB 2.0
  • S1: Micro USB power jack (5v - Power Only)
  • S2: DSI interface. 15-pin surface mounted flat flex connector (possibly no-fit).
  • S3: HDMI connector providing HDMI 1.3a out
  • S4: Composite Video connector: RCA
  • S5: MIPI CSI-2 interface. 15-pin surface mounted flat flex connector (possibly no-fit).
  • S6: Audio connector: 3.5mm stereo jack (output only)
  • S8: SD/MMC/SDIO memory card slot (underside)
  • S7: Either 1x USB 2.0 (Model A) 2x USB 2.0 (Model B)
  • P1: 26-pin 2.54mm header expansion (header not fitted), providing: see Low-level peripherals
    • 8 GPIOs at 3v3
    • 2-pin UART serial console, 3v3 TTL (debug); or 2 GPIOs at 3v3
    • I2C interface (3v3); or 2 GPIOs at 3v3
    • SPI interface (3v3); or 5 GPIOs at 3v3
    • 3v3, 5v and GND supply pins
    • ARM JTAG (if pins are reconfigured in software)
    • Second I2C interface (3v3) (if pins are reconfigured in software)
    • I2S interface (if pins are reconfigured in software, hardware hack may be required[2])
    • 6 pins reserved for future use
  • P2 and P3: 8-pin and 7-pin 2.54mm header expansion (header not fitted), providing:
    • 6-pin GPU JTAG (ARM11 pinout)
  • P4: 10/100Mb RJ45 Ethernet jack (Model B)
  • 5 Status LEDs[5][6][7]:
    • D5(Yellow) - OK - SDCard Access (via GPIO16)
    • D6(Red) - PWR - 3.3V Power
    • D7(Green) - FDX - Full Duplex (LAN) (Model B)
    • D8(Green) - LNK - Link/Activity (LAN) (Model B)
    • D9(Yellow) - 10M - 10/100Mbit (LAN) (Model B)


  • Board size: 85.60mm x 53.98mm. Overall height expected to be less than 25mm. [8]
  • Weight: <40g? (Alpha board weighs ~55g [9])
  • 6 layer PCB [8]





5 Feb 2012

Python - Convert google Calendar ICS to CSV

#!/usr/bin/env python

import urllib2
from icalendar import Calendar#, Event

outfile = "output.xls"
theurl = 'https://...'
username = 'xxx'
password = 'xxx'

QUOTE='"'
DELIM_FIELD = ","
DELIM_ROW   = "\n"
DATE_FORMAT = "%d.%m.%Y"
# a great password

passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
# this creates a password manager
passman.add_password(None, theurl, username, password)
# because we have put None at the start it will always
# use this username/password combination for  urls
# for which `theurl` is a super-url

authhandler = urllib2.HTTPBasicAuthHandler(passman)
# create the AuthHandler

opener = urllib2.build_opener(authhandler)

urllib2.install_opener(opener)
# All calls to urllib2.urlopen will now use our handler
# Make sure not to include the protocol in with the URL, or
# HTTPPasswordMgrWithDefaultRealm will be very confused.
# You must (of course) use it when fetching the page though.

pagehandle = urllib2.urlopen(theurl)
# authentication is now handled automatically for us

if pagehandle.code != 200:
 print "Something went wrong. HTTP response code: %s" % pagehandle.code

fp = open(outfile,'wb')
fp.write(QUOTE)
fp.write("Start")
fp.write(QUOTE)
fp.write(DELIM_FIELD)
fp.write(QUOTE)
fp.write("End")
fp.write(QUOTE)
fp.write(DELIM_FIELD)
fp.write(QUOTE)
fp.write("Days")
fp.write(QUOTE)
fp.write(DELIM_FIELD)
fp.write(QUOTE)
fp.write("Summary")
fp.write(QUOTE)
fp.write(DELIM_ROW)

cal = Calendar.from_string(pagehandle.read())
for component in cal.walk():
 if component.name == "VEVENT":
  fp.write(QUOTE)
  fp.write(component['dtstart'].dt.strftime(DATE_FORMAT))
  fp.write(QUOTE)
  fp.write(DELIM_FIELD)
  days = (component['dtend'].dt-component['dtstart'].dt).days
  fp.write(QUOTE)
  if (days > 1):
   fp.write(component['dtend'].dt.strftime(DATE_FORMAT))
  fp.write(QUOTE)
  fp.write(DELIM_FIELD)
  fp.write(QUOTE)
  fp.write(str(days))
  fp.write(QUOTE)
  fp.write(DELIM_FIELD)
  fp.write(QUOTE)
  fp.write(component['summary'])
  fp.write(QUOTE)
  fp.write(DELIM_ROW)

fp.close()