Advertisement
Advertisement

More Related Content

Advertisement
Advertisement

Raspberry pi a la cfml

  1. Raspberry Pi A La CFML Tasty, tasty CFML on a Pi Brad Wood @bdw429s pi.bradwood.com
  2. ● ColdFusion Architect (12 years) ● Geek ● Android Lover ● Blogger (codersrevolution.com) ● ColdBox Platform Evangelist ● Musician ● Shade-Tree Mechanic ● Husband (12 years) ● Dad (3 beautiful girls) The Weird Dude With The Mic
  3. What Is It?
  4. What Is It?
  5. Arduino Haven’t I seen this before? Raspberry Pi
  6. ● $35 $25 ● 1 GB Ram ● 900 MHz Quadcore ARM CPU (overclockable) ● HDMI ● 4x USB ● Micro USB power ● Audio Jack ● Camera Interface ● Network ● GPIO ● Micro SD What Is It?
  7. Fits in the palm of your hand. What Is It?
  8. Well, almost... What Is It?
  9. ● 2A power adapter ● USB Keyboard ● USB Mouse ● MicroSD card ● An operating system ● HDMI display ● Wifi or Ethernet hookup ● LED-adorned hat (optional) You also want/need…
  10. It Does Cool Stuff!
  11. Like What? Run Linux
  12. Like What? Use Openoffice
  13. Make a cool case Like What?
  14. Play Minecraft Like What?
  15. Program in Python (Scratch) Like What?
  16. Media Center Like What?
  17. Robot Like What?
  18. Make a 4-RPI Cluster Like What?
  19. Make a 40-RPI Cluster Like What?
  20. Make a 64-RPI Cluster Like What?
  21. And you can run CFML Like What?
  22. ● NOOBS ● Raspbian Linux (Debian) ○ Gnome Desktop (Pi Store) ○ Bash (apt-get) ● Oracle Java 1.8 (ARM) ● SSH Environment
  23. ● PuTTY ● IP Address?? (Router, Nmap) ● CommandBox 2.0.0 beta ○ REPL ○ ForgeBox ○ Embedded Server Tools
  24. /etc/apt/sources.list.d/box.list $> apt-get install commandbox /usr/bin/box $> box version Install CommandBox
  25. myFile.cfm <cfoutput>#now()#</cfoutput> $> box myFile.cfm Run CFML!
  26. myScript #! /usr/bin/env box <cfoutput>#now()#</cfoutput> $> chmod a+x myScript $> ./myScript Run CFML!
  27. $> box CommandBox> install contentbox CommandBox> start --rewritesEnabled In-memory H2 DB Install ContentBox
  28. Install ContentBox
  29. #!/bin/sh # Get current CPU usage (10-second average, actually) top -bn 2 -d 10 | grep '^%Cpu' | tail -n 1 | gawk '{print $2+$4+$6}' >> ~/stats.txt <div style="float:right;"> #cb.widget("cpu-load")# </div> Adding CPU Load
  30. Adding CPU Load “Flot” JS graphing lib
  31. #!/bin/sh # Get current system memory max and usage, in that order mem_system=`free -m | grep Mem: | gawk '{print $2,$3}'` # Start by getting the pid of the largest java process java_pid=`top -b -n 1|awk '{if ($1~/[0-9]+/) {if ($5~/m/) {$5=int($5*1024*1024)};print}}'|sort -k5rn,5 | grep java | head -n1 | gawk '{print $1}'` # Get the actual heap usage mem_heap=`jstat -gc $java_pid | tail -n 1 | gawk '{print ($1+$2+$5+$7+$9)/1000,($3+$4+$6+$8+$10)/1000}'` Adding Memory Usage
  32. #cb.widget("mem-load")# Adding Memory Usage
  33. Rate Limiter installed Posted to Reddit!
  34. Performance test parameters ● No overclocking ● Bumped heap size to 768 MB ● Simple page with #now()# output ● Use CLI load tool call “Siege” ● Started with 1 thread and increased to 100 threads How fast does this baby go?
  35. #!/bin/bash url="http://192.168.1.xxx/bench/" reqs=5000 NUMS="1 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100" for NUM in $NUMS do RPS=`siege -r $((reqs/NUM)) -c $NUM "$url" 2>&1 | grep "Transaction rate:" | awk '{print $3}'` echo -e "$NUMt$RPS" done How fast does this baby go?
  36. How fast does this baby go? 1000 request per second!
  37. What’s Next?
  38. GPIO (General Purpose Input Output) ● 40 pins of wonderment ○ 8 Ground pins ○ 2 +3.3v pins (50 mA max) ○ 2 +5v pins (direct current from power supply ) ○ 28 digital pins 3.3v “high” (50 mA max) ● Three different naming schemes ○ Broadcom (BCM) chip numbers ○ Physical header position ○ Wiring Pi Numbers
  39. GPIO (General Purpose Input Output)
  40. GPIO (General Purpose Input Output) ● Cobbler (breakout) board ● Solderless Breadboard ● Red LED ● 330 Ohm resistor ● Hook in series between digital pin and ground
  41. Pi4J ● Java-based library for interacting with GPIO pins ● Wraps “native” JNI calls to C library ● Easy to use from CFML! Yum!!
  42. Pi4J $> curl -s get.pi4j.com | sudo bash $> cp /opt/pi4j/lib/pi4j-core.jar ~/.CommandBox/lib/ $> cp /opt/pi4j/lib/pi4j-device.jar ~/.CommandBox/lib/ $> cp /opt/pi4j/lib/pi4j-service.jar ~/.CommandBox/lib/ $> cp /opt/pi4j/lib/pi4j-gpio-extension.jar ~/.CommandBox/lib/
  43. CommandBox REPL + Pi4J = Blinky Blinky LED GPIO = createObject( 'java', 'com.pi4j.io.gpio.GpioFactory').getInstance() pinState = createObject( 'java', 'com.pi4j.io.gpio.PinState') Raspipin = createObject( 'java', 'com.pi4j.io.gpio.RaspiPin') LED = GPIO.provisionDigitalOutputPin( RaspiPin.GPIO_01, "MyLED", PinState.HIGH)
  44. CommandBox REPL + Pi4J = Blinky Blinky LED // Have you tried turning it // off and back on again? LED.low() LED.high() // Toggle the current state LED.toggle() // On and back off once LED.pulse( 2000 )
  45. The (LED) Matrix has you 64 LEDs (8x8)
  46. The (LED) Matrix has you Only 16 pins!
  47. The (LED) Matrix has you
  48. The (LED) Matrix has you --Multiplexing-- Only one column can be lit at a time.
  49. The (LED) Matrix has you Inline 330 Ohm resistor on each row Each column switched to ground via NPN transistor
  50. The (LED) Matrix has you CFML Redraw each column > 60 times a second
  51. The (LED) Matrix has you
  52. Shift Your Focus Shift Register
  53. Shift Your Focus SIPO -- Serial In, Parallel Out
  54. Shift Your Focus 1 0 1 0 1 0 1 0 Bit banging Allows transfer of large amount of data over a few wires in “chunks”
  55. Shift Your Focus 5 input wires drives 16 output Data Clock Latch 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 5V GND
  56. Shift Your Focus
  57. Design In Flux
  58. Design In Flux
  59. Wired To The Brim
  60. Wired To The Brim
  61. “Smiley” animation delay 10000 frame 00111100 01000010 10100101 10000001 10100101 10011001 01000010 00111100
  62. The Code https://github.com/bdw429s/CFML-Pi-Hat/
  63. Is that bacon I smell?
  64. Is that bacon I smell?
  65. What’s Next? ● Interactive projects (control from web) ● Clustered Pis (CFML, Couchbase, etc) ● Home Automation ● CFGPIO library ● What will you build?
Advertisement