shoot a pi with eclipse kura david d woodar odard
play

+ Shoot A Pi! with Eclipse Kura David d Woodar odard @ Eurotech - PowerPoint PPT Presentation

+ Shoot A Pi! with Eclipse Kura David d Woodar odard @ Eurotech Luca uca Dazi @ Eurotech +Agenda Presentation of Kura architecture for Java and OSGi based multi service gateway platforms. (Dave, 20 mins) Presentation of the


  1. + Shoot A Pi! with Eclipse Kura David d Woodar odard @ Eurotech Luca uca Dazi @ Eurotech

  2. +Agenda Presentation of Kura architecture for Java and OSGi based • multi service gateway platforms. (Dave, 20 mins) Presentation of the Shoot-A-Pi arcade game simulator, game • logic explanation, MQTT topics and metrics (Luca, 15 mins) Hardware setup on the Raspberry Pi B+ (15 mins) • Assisted creation of the Shoot-A-Pi bundle (90 mins) • Tests (15 mins) • Dashboard showcase and final game (15 mins) • Q&A •

  3. + Before starting... Power on the Raspberry Pi with the micro USB cable • Connect the Raspbery Pi to an ethernet port on your PC • Connect your PC to the WiFi network named ‘ ShootAPi ’ • Password: KuraTut aTutor oria ial • Set the IP Address of your ethernet to 192.168.2.1 • Start VirtualBox and import the tutorial image (shootapi.ova) Start the newly imported EclipseCon VM • • Start the Terminal Emulator • Access the Raspberry Pi with ssh at address 192.168.2.10 ssh pi@1 @192.1 92.168.2 68.2.10 .10 Password: rasp spber erry

  4. + Share your WiFi with the Pi Linux ux / Mac c user ers Open the Kura Web Console on a browser (192.168.2.10) • Navigate to the Network panel and set eth0 on DHCP • • Share your WiFi with the Ethernet interface • Do an ifconfig on the terminal and take note of the IP address assigned to eth0 (defaults to 10.42.0.1 on Ubuntu) Scan for the IP of the Pi using nmap • nmap p 10.4 .42.0 .0.0 .0-255 255 Windo ndows s user ers • Share your WiFi with the Ethernet interface • Set the IP address of the Ethernet interface to 192.168.2.1 • The Raspberry Pi will be available at address 192.168.2.10

  5. + Share your WiFi with the Pi Windows Right-click on the Network icon in the taskbar • Open Network and Sharing Center • Click on Change adapter settings • • Right-click on WiFi, open the Properties • Activate the Sharing tab • Check the Allow other network users to connect checkbox Select Ethernet from the combo box below • • Apply and close

  6. + Share your WiFi with the Pi Ubuntu Click on the network icon, then Edit Connections... • Double click on the Wireless Connection • Open the IPv4 Settigns tab • • Select Shared with other computers on the Method combo box • Apply and exit. Once the Pi is connected and set to DHCP click on the Wired Network so to renew the DHCP lease

  7. + IoT T Gat ateways ys Revolution: Towards Real-time Actionable Data Business Application MQTT Broker

  8. + KURA URA is is the the ope open sour source ce Java and and OSGi OSGi-ba based sed Ap Appl plica ication tion Fram amework for or M2M Ser ervi vice ce Embedded App Gateways ys in in the the Eclip ipse se IOT IOTWorking ing Group. Purpose ose Simplify the design, deployment and remote management of embedded applications. It It provides vides • Cohesive and integrated app environment Java/OSGi • Modular software components • HW abstraction layer • Field protocol libraries Linux OS • Cloud connectivity • Remote app and device management Industrial Open HW • Local app and device management HW • Built-in Security • Development tools • Raspberry PI • BeagleBone M2M Smart Black gateways Sensors

  9. + Encapsulating complexity Increase productivity and decrease cultural barriers Kura help lps customer focusing on their core business Code on Code Code OSGi Java VM Linux Hardware

  10. Kura Developers’ Experience Designed from ground-up for developers Emul ulat ate on PC Deplo loy y on Target et Cloud d Managed ed Start developing your M2M When you are ready, deploy Provision your application application in the comfort your application on the to field devices from the of your PC. gateway. Cloud. Manage your application • Full Eclipse Integration • One-click Deployment configuration and lifecycle • Target Platform Definition • Eclipse Plugin from a Cloud infrastructure. • Emulated Services • Remote Debugging No more field visits! • Run/Debug from Eclipse • Support Mac/Linux Hosts • Web-based Console • REST API Integration • Smart Alerts

  11. Eclipse Open IoT Stack for Java Applica cations Remote Access Your Application Your Application Connectivity and Delivery Field d Protocols Cloud Services Data Services MQTT Paho Management Modbus Updates Network Configu guration ment Network work Config nfiguration ion Administration GUI geme CANBus Cellular, Wi-Fi, Firewall, Port Link Remote Manage Ethernet Forwarding Monitors Configuration ... Management Basic c Gatewa way Service ces DB Service Device Profile Custom Protocols Clock Service Watchdog Device ce Abstract ction javax.comm GPS Position GPIO / SPI / PWM / I2C javax.usb jdk.dio w/ udev access Your Application Java HID APIs javax.bluetooth / BLE OSGi Applic icat atio ion Contai ainer r (Ecl clip ipse se Equin inox, Conci cierge) Java va SE 7 / 8 (OpenJ enJDK)

  12. Shoot-A-Pi Arcade Shooter Simulator Architecture Web Dashboards Eclipse Equinox OSGi MQTT MQTT Websockets Java VM REST APIs Broker Linux Hardware Device/Gateway GPIO (data collection) I2C Laser RF Human Interface Device

  13. Shoot-A-Pi Arcade Shooter Simulator MQTT Topics and Metrics shootapi/ COMMAND/ DATA/ - Timestamp reset shot - Metrics: Remaining rounds - Timestamp new score - Metrics: Current score - Timestamp stop reload - Metrics: Realod flag - Timestamp - Timestamp reloading - Metrics: Game ID - Metrics: Realoding status

  14. + Shoot-A-Pi Arcade Shooter Simulator Game Logic Shoot-A-Pi HID Worker I2C Worker GPIO Actuator Game Logic shot score 250 ms 250 ms

  15. Shoot-A-Pi Arcade Shooter Simulator Hardware Setup I2C Raspberry Pi B+ J8 Header GPIO 3.3v DC Power 5v DC Power SDA1 - I2C 5v DC Power SCL1 - I2C Ground Ground GPIO17 GPIO18 Ground RF Dongl gle

  16. +Class Diagram LaserPenWorker GameLogic Runnable PenDetectListener Utilities DigitalLightSensorWorker ShootAPi Runnable LightSensorChangeListener GPIOActuator Runnable

  17. +Setting up the Laser Tag The LP-170 Laser Tag has two working modes. Mode A Pen Function Shoot A Pi Function Payload A Mode Switch - NONE B Page Down None 0x00004e C Page Up None 0x00004b Mode B Pen Function Shoot A Pi Function Payload A. Mode Switching B. Reload A Mode Switch - NONE C. Fire B Start Slideshow Reload 0x02003e D. Only laser E. RF USB Dongle B Stop Slideshow Reload 0x000029 C Hide Slideshow Shoot 0x000005

  18. +Setting up the Laser Tag Helpers We will use a helper class to trace the commands received from the pen public static enum PenCommand{ CMD_LASER_NO_REPEAT("000005", "Shooting Laser!"), CMD_LASER_REPEAT("00004b", "Scrolling down..."), CMD_RELOAD_REPEAT("00004e", "Scrolling up..."), CMD_RELOAD_NO_REPEAT_A("02003e", "Reload 1"), CMD_RELOAD_NO_REPEAT_B("000029", "Reload 2"), CMD_UNKNOWN_COMMAND("000000", "Unknown command"); . . . } Stub file: PenCommandsEnum.stub.java

  19. +Setting up the Laser Tag Worker Reading from the pen will be handled by a Runnable class, which will constantly poll the pen for input using HID APIs provided by Kura. A listener is passed in the constructor, so that when the worker detects a command, it can wake up the caller. public class LaserPenWorker implements public void run() { Runnable { byte[] data = new byte[3]; try { private static final int PEN_VENDOR_ID = if (null == thePen) { 4643; thePen= HIDManager.getInstance().openById( private static final int PEN_PRODUCT_ID = PEN_VENDOR_ID, 16230; PEN_PRODUCT_ID, null); } private static HIDDevice thePen = null; while (true) { thePen.read(data); private static PenDetectListener callback; // Convert data to string and put in result if (!result.toString().isEmpty() public LaserPenWorker(PenDetectListener && !result.toString().equals("000000")) { callback){ fireChangeEvent(result.toString()); LaserPenWorker. callback = callback; } } } . } catch (HIDDeviceNotFoundException ex) { . } catch (IOException ex) { . } finally { } } Stub file: LaserPenWorker.stub.java

  20. +Deploying the Bundle mToolkit  Export the bundle using Export -> Plug-in development -> Deployable plug-in and fragments  Open the mToolkit Frameworks view using Window -> Show View -> Others...  Activate the Frameworks tab and create a new Framework using the IP Address of the Pi  Start the newly created framework  Right-click on Bundles  Click on «Install new...» and select the plug-in you exported before  Connect to the Pi and see the Bundle in action!

  21. +Debugging and Logging  After accessing the Pi through ssh you will be able to inspect the log files and control Kura using these commands: tail – f /var/log/kura.log will show the realtime kura log tail – f /var/log/kura-console.log will show the System.err log telnet 127.0.0.1 5002 will open the OSGi telnet terminal Will restart Kura. Bundles installed with sudo /etc/init.d/kura restart mToolkit will be removed.

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend