raspberry pi a la cfml
TRANSCRIPT
![Page 1: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/1.jpg)
Raspberry Pi A La CFMLTasty, tasty CFML on a Pi
Brad Wood@bdw429s
pi.bradwood.com
![Page 2: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/2.jpg)
● 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
![Page 3: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/3.jpg)
What Is It?
![Page 4: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/4.jpg)
What Is It?
![Page 5: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/5.jpg)
Arduino
Haven’t I seen this before?
Raspberry Pi
![Page 6: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/6.jpg)
● $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?
![Page 7: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/7.jpg)
Fits in the palm of your hand.
What Is It?
![Page 8: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/8.jpg)
Well, almost...
What Is It?
![Page 9: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/9.jpg)
● 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…
![Page 10: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/10.jpg)
It Does Cool Stuff!
![Page 11: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/11.jpg)
Like What?
Run Linux
![Page 12: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/12.jpg)
Like What?
Use Openoffice
![Page 13: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/13.jpg)
Make a cool case
Like What?
![Page 14: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/14.jpg)
Play Minecraft
Like What?
![Page 15: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/15.jpg)
Program in Python (Scratch)
Like What?
![Page 16: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/16.jpg)
Media Center
Like What?
![Page 17: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/17.jpg)
Robot
Like What?
![Page 18: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/18.jpg)
Make a 4-RPI Cluster
Like What?
![Page 19: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/19.jpg)
Make a 40-RPI Cluster
Like What?
![Page 20: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/20.jpg)
Make a 64-RPI Cluster
Like What?
![Page 21: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/21.jpg)
And you can run CFML
Like What?
![Page 22: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/22.jpg)
● NOOBS● Raspbian Linux (Debian)
○ Gnome Desktop (Pi Store)○ Bash (apt-get)
● Oracle Java 1.8 (ARM)● SSH
Environment
![Page 23: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/23.jpg)
● PuTTY● IP Address?? (Router, Nmap)● CommandBox 2.0.0 beta
○ REPL○ ForgeBox○ Embedded Server
Tools
![Page 24: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/24.jpg)
/etc/apt/sources.list.d/box.list
$> apt-get install commandbox
/usr/bin/box
$> box version
Install CommandBox
![Page 25: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/25.jpg)
myFile.cfm
<cfoutput>#now()#</cfoutput>
$> box myFile.cfm
Run CFML!
![Page 26: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/26.jpg)
myScript
#! /usr/bin/env box<cfoutput>#now()#</cfoutput>
$> chmod a+x myScript$> ./myScript
Run CFML!
![Page 27: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/27.jpg)
$> box
CommandBox> install contentbox
CommandBox> start --rewritesEnabled
In-memory H2 DB
Install ContentBox
![Page 28: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/28.jpg)
Install ContentBox
![Page 29: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/29.jpg)
#!/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
![Page 30: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/30.jpg)
Adding CPU Load
“Flot” JS graphing lib
![Page 31: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/31.jpg)
#!/bin/sh
# Get current system memory max and usage, in that ordermem_system=`free -m | grep Mem: | gawk '{print $2,$3}'`
# Start by getting the pid of the largest java processjava_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 usagemem_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
![Page 32: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/32.jpg)
#cb.widget("mem-load")#
Adding Memory Usage
![Page 33: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/33.jpg)
Rate Limiter installed
Posted to Reddit!
![Page 34: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/34.jpg)
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?
![Page 35: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/35.jpg)
#!/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 $NUMSdo
RPS=`siege -r $((reqs/NUM)) -c $NUM "$url" 2>&1 | grep "Transaction rate:" | awk '{print $3}'`
echo -e "$NUM\t$RPS"done
How fast does this baby go?
![Page 36: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/36.jpg)
How fast does this baby go?
1000 request per second!
![Page 37: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/37.jpg)
What’s Next?
![Page 38: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/38.jpg)
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
![Page 39: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/39.jpg)
GPIO(General Purpose Input Output)
![Page 40: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/40.jpg)
GPIO(General Purpose Input Output)
● Cobbler (breakout) board● Solderless Breadboard● Red LED● 330 Ohm resistor● Hook in series between
digital pin and ground
![Page 41: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/41.jpg)
Pi4J
● Java-based library for interacting with GPIO pins● Wraps “native” JNI calls to C library● Easy to use from CFML!
Yum!!
![Page 42: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/42.jpg)
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/
![Page 43: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/43.jpg)
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)
![Page 44: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/44.jpg)
CommandBox REPL + Pi4J =Blinky Blinky LED
// Have you tried turning it // off and back on again?LED.low()LED.high()
// Toggle the current stateLED.toggle()
// On and back off onceLED.pulse( 2000 )
![Page 45: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/45.jpg)
The (LED) Matrix has you
64 LEDs (8x8)
![Page 46: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/46.jpg)
The (LED) Matrix has you
Only 16 pins!
![Page 47: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/47.jpg)
The (LED) Matrix has you
![Page 48: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/48.jpg)
The (LED) Matrix has you
--Multiplexing--Only one column can be lit at a time.
![Page 49: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/49.jpg)
The (LED) Matrix has you
Inline 330 Ohm resistor on each rowEach column switched to ground via NPN transistor
![Page 50: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/50.jpg)
The (LED) Matrix has you
CFMLRedraw each column > 60 times a second
![Page 51: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/51.jpg)
The (LED) Matrix has you
![Page 52: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/52.jpg)
Shift Your Focus
Shift Register
![Page 53: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/53.jpg)
Shift Your Focus
SIPO -- Serial In, Parallel Out
![Page 54: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/54.jpg)
Shift Your Focus
1 0 1 0 1 0 1 0
Bit bangingAllows transfer of large amount of data
over a few wires in “chunks”
![Page 55: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/55.jpg)
Shift Your Focus
5 input wires drives 16 output
Data
ClockLatch
12345678910111213141516
5VGND
![Page 56: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/56.jpg)
Shift Your Focus
![Page 57: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/57.jpg)
Design In Flux
![Page 58: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/58.jpg)
Design In Flux
![Page 59: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/59.jpg)
Wired To The Brim
![Page 60: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/60.jpg)
Wired To The Brim
![Page 61: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/61.jpg)
“Smiley” animation
delay 10000frame0011110001000010101001011000000110100101100110010100001000111100
![Page 62: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/62.jpg)
The Code
https://github.com/bdw429s/CFML-Pi-Hat/
![Page 63: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/63.jpg)
Is that bacon I smell?
![Page 64: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/64.jpg)
Is that bacon I smell?
![Page 65: Raspberry pi a la cfml](https://reader034.vdocuments.site/reader034/viewer/2022052401/55b678d5bb61eb87788b45ff/html5/thumbnails/65.jpg)
What’s Next?
● Interactive projects (control from web)● Clustered Pis (CFML, Couchbase, etc)● Home Automation● CFGPIO library● What will you build?