Download - Vending Machine Example
© On-Line Applications Research Corporation
AcknowledgementsAcknowledgements
• Original code is from Chapter Five of the Original code is from Chapter Five of the Upcoming Book:Upcoming Book:
Building Parallel, Embedded, and Building Parallel, Embedded, and Real-Time Applications with AdaReal-Time Applications with Ada
bybyJohn W. McCormick, Frank Singhoff, and John W. McCormick, Frank Singhoff, and
Jerome HuguesJerome Hugues
© On-Line Applications Research Corporation
Get the Tutorial FilesGet the Tutorial Files
Let’s get the necessary filesLet’s get the necessary files– cd /home/liveusercd /home/liveuser– tar xvf /tutorial.tar.bz2tar xvf /tutorial.tar.bz2
RTEMS Intro-4
© On-Line Applications Research Corporation
ScriptsScripts
env.sh – set necessary environment variables for env.sh – set necessary environment variables for compiling/runningcompiling/running
run-qemu – run RTEMS examples under Qemurun-qemu – run RTEMS examples under Qemu README-building-RTEMS-Ada.html – instructionsREADME-building-RTEMS-Ada.html – instructions build_rtems – script for building RTEMS with GNAT build_rtems – script for building RTEMS with GNAT
Ada 2005 from source code under GNU/LinuxAda 2005 from source code under GNU/Linux get_rtems – script to get RTEMS source code from get_rtems – script to get RTEMS source code from
RTEMS CVS repositoryRTEMS CVS repository get_ada-examples – script to get RTEMS Ada get_ada-examples – script to get RTEMS Ada
example source code from the RTEMS CVS example source code from the RTEMS CVS repositoryrepository
RTEMS Intro-6
© On-Line Applications Research Corporation
Vending Example SubdirectoriesVending Example Subdirectories
original – version from book (native)original – version from book (native) shared – source shared across examplesshared – source shared across examples random_native, random_rtems – random random_native, random_rtems – random
ordersorders web_native, web_rtems – embedded web web_native, web_rtems – embedded web
serverserver shell_rtems – RTEMS command lineshell_rtems – RTEMS command line rootfs – root file system directory for rootfs – root file system directory for
web_rtems and shell_rtemsweb_rtems and shell_rtems
© On-Line Applications Research Corporation
Canonical Coffee Vending MachineCanonical Coffee Vending Machine
selection
reload
drink
report
© On-Line Applications Research Corporation
Original VersionOriginal Version
Directory: originalDirectory: original Characteristics:Characteristics:
– Single Ada fileSingle Ada file– No packagesNo packages– Main has loop which makes random ordersMain has loop which makes random orders
© On-Line Applications Research Corporation
EnhancementsEnhancements
Refactored to have Vending_Machine packageRefactored to have Vending_Machine package– Added Reload and Report subprogramsAdded Reload and Report subprograms
– Added Dispenser package to interface to Added Dispenser package to interface to dispensing hardware dispensing hardware
e.g. same specification file, different body for e.g. same specification file, different body for hardwarehardware
Added Inventory packageAdded Inventory package
Source for all of the above is in Source for all of the above is in shared/shared/
© On-Line Applications Research Corporation
Time To Build ThemTime To Build Them
Let’s build the various vending variationsLet’s build the various vending variations– source /home/liveuser/scripts/env.shsource /home/liveuser/scripts/env.sh– cd /home/liveuser/vending-examplecd /home/liveuser/vending-example– makemake
When that works for everyone, we will look at When that works for everyone, we will look at the individual examplesthe individual examples
© On-Line Applications Research Corporation
Random Input VersionRandom Input Version
Directory: random_native and random_rtemsDirectory: random_native and random_rtems Characteristics:Characteristics:
– Ada Main has loop which makes random ordersAda Main has loop which makes random orders Main is based on Main in original versionMain is based on Main in original version
– Fixed set of add-ins requested (e.g. sugar, etc)Fixed set of add-ins requested (e.g. sugar, etc)– Similar in spirit to an automated system testSimilar in spirit to an automated system test
© On-Line Applications Research Corporation
Running the Random Input VersionRunning the Random Input Version
Run it nativelyRun it natively– cd random_nativecd random_native– ./random./random
Run it on RTEMSRun it on RTEMS– cd random_rtemscd random_rtems– /home/liveuser/scripts/run-qemu random.exe/home/liveuser/scripts/run-qemu random.exe
Output will come to terminal on bothOutput will come to terminal on both Should appear similarShould appear similar
© On-Line Applications Research Corporation
Web Interface Vending MachineWeb Interface Vending Machine
selection
reload
drink
report
© On-Line Applications Research Corporation
Web Interface VersionWeb Interface Version
Directory: web_native and web_rtemsDirectory: web_native and web_rtems Characteristics:Characteristics:
– Includes Mongoose embedded web serverIncludes Mongoose embedded web server http://code.google.com/p/mongoose/
– User interface is provided by browserUser interface is provided by browser– User requests add-ins, reports, reload, etc.User requests add-ins, reports, reload, etc.
© On-Line Applications Research Corporation
Web Interface Version (continued)Web Interface Version (continued)
Mix of C webserver (Mongoose) with Ada Mix of C webserver (Mongoose) with Ada application codeapplication code
RTEMS version is simple but complete RTEMS version is simple but complete embedded applicationembedded application
Native URL: Native URL: http://localhost:8080/ RTEMS URL: RTEMS URL: http://10.0.2.5/
© On-Line Applications Research Corporation
Running the Web Interface VersionRunning the Web Interface Version
Run it nativelyRun it natively– cd web_nativecd web_native– ./web_vending./web_vending– *** direct browser to *** direct browser to http://localhost:8080/
Run it on RTEMSRun it on RTEMS– cd web_rtemscd web_rtems– susu– source /home/liveuser/scripts/env.shsource /home/liveuser/scripts/env.sh– /home/liveuser/scripts/run-qemu web_vending.exe/home/liveuser/scripts/run-qemu web_vending.exe– *** direct browser to *** direct browser to http://10.0.2.5/
Except for stack and cpu usage reporting, the Except for stack and cpu usage reporting, the versions should be identical to userversions should be identical to user
© On-Line Applications Research Corporation
Command Line Interface Vending Command Line Interface Vending MachineMachine
selection
reload
drink
report
© On-Line Applications Research Corporation
RTEMS Shell VersionRTEMS Shell Version
Directory: shell_rtemsDirectory: shell_rtems Characteristics:Characteristics:
– Provides command interface to vending machineProvides command interface to vending machine– Typical of diagnostics interfaceTypical of diagnostics interface– Both shell and web interfaces could coexistBoth shell and web interfaces could coexist– Command interface could be available via telnetCommand interface could be available via telnet– Complete small embedded systemComplete small embedded system
© On-Line Applications Research Corporation
Running the Command Line Running the Command Line Interface VersionInterface Version
Run it on RTEMSRun it on RTEMS– cd shell_rtemscd shell_rtems– susu– source /home/liveuser/scripts/env.shsource /home/liveuser/scripts/env.sh– /home/liveuser/scripts/run-qemu shell.exe/home/liveuser/scripts/run-qemu shell.exe– *** login as rtems*** login as rtems– *** command is vend*** command is vend
© On-Line Applications Research Corporation
Your TurnYour Turn
Modify web_rtems and/or shell_rtemsModify web_rtems and/or shell_rtems– Allow the user to request multiple add ins (e.g. 2 Allow the user to request multiple add ins (e.g. 2
sugars)sugars)– Allow the user to request a stronger beverage (e.g. a Allow the user to request a stronger beverage (e.g. a
double shot of coffee)double shot of coffee)– Add a new beverage (e.g. decaffeinated coffee)Add a new beverage (e.g. decaffeinated coffee)– Add a payment interfaceAdd a payment interface– ??????