Programming CAN-based Fieldbus Systems using Java



Similar documents
CSE 452: Programming Languages. Acknowledgements. Contents. Java and its Evolution

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

Contents. Java - An Introduction. Java Milestones. Java and its Evolution

Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming

Numerical Algorithms Group

System Structures. Services Interface Structure

Mobile Operating Systems. Week I

Fachbereich Informatik und Elektrotechnik SunSPOT. Ubiquitous Computing. Ubiquitous Computing, Helmut Dispert

CSC 551: Web Programming. Spring 2004

Chapter 1 Fundamentals of Java Programming

Introduction to Native Android Development with NDK

Java and Real Time Storage Applications

CS Software Engineering for Scientific Computing. Lecture 25:Mixed Language Programming.

STM32JAVA. Embedded Java Solutions for STM32

What Perl Programmers Should Know About Java

Java applets. SwIG Jing He

Lesson 06: Basics of Software Development (W02D2

An Overview of Java. overview-1

Developing Embedded Software in Java Part 1: Technology and Architecture

INTRODUCTION TO JAVA PROGRAMMING LANGUAGE

SE 450 Object-Oriented Software Development. Requirements. Topics. Textbooks. Prerequisite: CSC 416

Building Applications Using Micro Focus COBOL

Mobile Application Languages XML, Java, J2ME and JavaCard Lesson 04 Java

Multithreading and Java Native Interface (JNI)!

The Java Virtual Machine and Mobile Devices. John Buford, Ph.D. Oct 2003 Presented to Gordon College CS 311

Programming Languages

CS 3530 Operating Systems. L02 OS Intro Part 1 Dr. Ken Hoganson

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

CS 209 Programming in Java #1

Java Embedded Applications

Example of Standard API

2 Introduction to Java. Introduction to Programming 1 1

Research and Design of Universal and Open Software Development Platform for Digital Home

CSC230 Getting Starting in C. Tyler Bletsch

CGI-based applications for distributed embedded systems for monitoring temperature and humidity

Technical Note. Micron Flash Data Integrator (FDI) Support for Java Applications. Introduction. Definition

Java in Education. Choosing appropriate tool for creating multimedia is the first step in multimedia design

Java Card. Smartcards. Demos. . p.1/30

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

Chapter 2 System Structures

1. Overview of the Java Language

Jonathan Worthington Scarborough Linux User Group

Crash Course in Java

VOL. 3, NO.10 Oct, 2012 ISSN Journal of Emerging Trends in Computing and Information Sciences CIS Journal. All rights reserved.

Installing Java. Table of contents

Fall Lecture 1. Operating Systems: Configuration & Use CIS345. Introduction to Operating Systems. Mostafa Z. Ali. mzali@just.edu.

Computer and Set of Robots

Chapter 3: Operating-System Structures. Common System Components

Software. Programming Language. Software. Instructor Özgür ZEYDAN. Bülent Ecevit University Department of Environmental Engineering

JPURE - A PURIFIED JAVA EXECUTION ENVIRONMENT FOR CONTROLLER NETWORKS 1

Using the Java Native Interface to Introduce Device Driver Basics

Effective Java Programming. efficient software development

Online Recruitment System 1. INTRODUCTION

Chapter 3 Operating-System Structures

Chapter 1 Introduction to Computers, Programs, and Java

02 B The Java Virtual Machine

GETTING STARTED WITH ANDROID DEVELOPMENT FOR EMBEDDED SYSTEMS

Software: Systems and Application Software

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

HYBRID JINI FOR LIMITED DEVICES

Chapter 5: System Software: Operating Systems and Utility Programs

picojava TM : A Hardware Implementation of the Java Virtual Machine

Java Programming. Binnur Kurt Istanbul Technical University Computer Engineering Department. Java Programming. Version 0.0.

Installing Java (Windows) and Writing your First Program

Smart Cards a(s) Safety Critical Systems

Nokia 9210i/9290 Communicators and PersonalJava TM Application Development

Japan Communication India Skill Development Center

Agent Languages. Overview. Requirements. Java. Tcl/Tk. Telescript. Evaluation. Artificial Intelligence Intelligent Agents

Java Real-Time Distributed Processing over Chorus/OS

How To Port A Program To Dynamic C (C) (C-Based) (Program) (For A Non Portable Program) (Un Portable) (Permanent) (Non Portable) C-Based (Programs) (Powerpoint)

TYLER JUNIOR COLLEGE School of Continuing Studies 1530 SSW Loop 323 Tyler, TX

Digitale Signalverarbeitung mit FPGA (DSF) Soft Core Prozessor NIOS II Stand Mai Jens Onno Krah

12. Introduction to Virtual Machines

C# and Other Languages

SIP Protocol as a Communication Bus to Control Embedded Devices

Chapter 1. Introduction to Computers, Programs, and Java

JavaPOS TM FAQ. What is an FAQ? What is JavaPOS?

Embedded Software development Process and Tools: Lesson-4 Linking and Locating Software

Japan Communication India Skill Development Center

Reminders. Lab opens from today. Many students want to use the extra I/O pins on

Star System Deitel & Associates, Inc. All rights reserved.

12/22/11. } Android by Pearson Education, Inc. All Rights Reserved by Pearson Education, Inc. All Rights Reserved.

Operator Touch Panel PC OTP/57V esom2586 / x86

Operating System Structures

Lecture 1 Introduction to Android

Ponto Series. A new concept for automation

Cloud Computing. Up until now

Java on z/os. Agenda. Java runtime environments on z/os. Java SDK 5 and 6. Java System Resource Integration. Java Backend Integration

Experimental Evaluation of Distributed Middleware with a Virtualized Java Environment

OPERATING SYSTEM SERVICES

Java Crash Course Part I

Ways to Use USB in Embedded Systems

How To Write A Windows Operating System (Windows) (For Linux) (Windows 2) (Programming) (Operating System) (Permanent) (Powerbook) (Unix) (Amd64) (Win2) (X

Can You Trust Your JVM Diagnostic Tools?

STLinux Software development environment

How To Write A Program In Java (Programming) On A Microsoft Macbook Or Ipad (For Pc) Or Ipa (For Mac) (For Microsoft) (Programmer) (Or Mac) Or Macbook (For

Java and JCA. Rok Sabjan 09/01/2008. Based on presentation by Ken Evans.

Objectives. Chapter 2: Operating-System Structures. Operating System Services (Cont.) Operating System Services. Operating System Services (Cont.

Chapter 8 Objectives. Chapter 8 Operating Systems and Utility Programs. Operating Systems. Operating Systems. Operating Systems.

FRONT FLYLEAF PAGE. This page has been intentionally left blank

Transcription:

Title Programming CAN-based Fieldbus Systems using Java Manuel Joaquim Pereira dos Santos, Ricardo José Caetano Loureiro Universidade de Aveiro, Aveiro, Portugal, Helmut Dispert Department of Computer Science and Electrical Engineering, Kiel University of Applied Sciences, Kiel, Germany

Contents 1. Introduction: Embedded Intelligent Devices 2. Java in Embedded Control: e.g.: Java Servlet Technology (the Embedded Java Controller - EJC) 3. Java and Native Code

Evolution The evolution of embedded intelligent devices is driven by technological advancements: low cost microprocessors and peripheral devices Internet Java programming language Examples: new hardware platforms (e.g. Strong ARM architecture) Internet and the HTTP to access devices Development of robust and reliable software using Java.

Opportunities Sun Microsystems, Inc.: "Combining the strengths of these (new) technologies, there is a huge market opportunity for companies that discover how to leverage the benefits of Java technology on embedded devices."

Java Solution: A New Paradigm: Write once, run anywhere Java

Java History of Java (true story) 1990: A small group is formed at Sun Microsystems with the task to think about the future of multimedia in private households. Group Member: James Gosling Idea: develop a generic and simple programming language to implement intelligent electronic devices (household). Embedded Programming

Java Why Java? Object-oriented (encapsulation, polymorphism, inheritance), No multiple inheritance, Platform independent bytecode, Java primitive data types have fixed sizes, Automatic run-time bounds-checking, True Boolean type, No pointer programming, Automatic garbage collection, Language support for multithreaded applications.

Java in Embedded Systems Java Usage Models: The proposed Java usage models fall into one of four categories: No Java Embedded Web Server Java Embedded Applet Java Application Java

Java in Embedded Systems These models are distinguished by two binary variables: location of the stored Java bytecodes the processor on which the bytecodes are executed These variables can take one of two values: target (the embedded system) host (a general-purpose computer attached to the embedded system) Ref.: Michael Barr

Java in Embedded Systems Host Host Host Host Java Java Target Target Target Target Java Java No Java Embedded Web Server Embedded Applet Application Ref.: Michael Barr

Java 2 Platform Profile Profile Profile Profile Java Java 2 Enterprise Edition (J2EE) Core Core APIs APIs Profile Profile Profile Profile Java Java 2 Standard Edition (J2SE) Core Core APIs APIs Java 2 Platform, Micro Edition (J2ME) encompasses VMs and core APIs specified via Configurations as well as vertical or market-specific APIs specified in Profiles. TV TV Screen Screen Car Profile Profile Phone Phone Profile Car Profile Profile Profile Personal Personal Profile Profile Mobile Information Mobile Device Information Profile Device Profile Java Java 22 Micro Micro Edition Edition Core Core APIs APIs Smart Card Smart Profile Card Profile Java Java Programming Language Java Java HotSpot HotSpot Java Java Virtual Virtual Maschine Maschine (JVM) (JVM) KVM KVM Card Card VM VM

Java Application Environments Desktop OS Enterprise Servers Mainframes RTOS Vendors Set-top boxes PDAs ScreenPhones Hi-end mobile phones Internet TV Car navigation Industrial Controllers Intrumentation Automotive Printers Hi-end Pagers Mid-range Phones SmartCards Java Ring Java AE Personal Java AE Embedded Java AE Java Card

Java 2 Platform Editions JavaCard Java Technology Enabled Devices Java Technology Enabled Desktop Workgroup Server High-End Server Micro Edition Standard Edition Enterprise Edition

Java Application Portability: 1. mechanism for executing Java bytecodes on any processor 2. common set of class libraries

Java Development Cycle Compile-time Environment Java Source (.java) Run-Time Environment (Java Platform)Environment Class Loader Bytecode Verifier Java Classes Libraries Java Compiler Java Interpreter Just-in-Time Compiler Virtual Java Machine Java Bytecode (.class) Run-Time System Operating System VM Hardware

Java Architecture Java Programming Language Compiled Byte Code The Java Architecture 1. Programming Language 2. Virtual Machine (VM) 3. API Java Runtime System Virtual Machine Java API Operating System Computer Hardware

Access Hardware using Java The basic idea of embedded control is to directly access hardware level properties: Registers, I/O-interfaces, sensors, actuators, etc. Problem Basic Properties of Java: Platform independent bytecode, No pointer programming, Automatic garbage collection,

Access Hardware using Java Solutions: Use dedicated hardware platform, dedicated OS and dedicated Java VM. Example: Snijder Embedded Java Controller (EJC). see: 1st Int. Workshop, Vaasa, 2002 Use native languages that allow access to hardware level functions.

Java - Jbed VM Glue Code VM Browser Glue Code VM OS OS Glue Code RTOS OS and VM Hardware Hardware Hardware Hardware Java in a WWW browser Java on a desktop OS Java on a RTOS Java on the bare metal

EJC - Embedded Java Controller I 2 C I 2 C RS485 COM 1 (RS232) RS485 COM 1 EJC System Bus COM 0 (TTL) Ethernet COM 0 ETH. Digital I/O LCD 1-Wire Boot Flash Digital I/O LCD 1-Wire PWR Switch Input LED Output Boot Flash EJC-SK1 carrier board block diagram

EJC - EW1A block diagram E 2 PROM Temp. Sensor CPU ARM7TDMI DRAM Flash ISA-like + memory bus COM 1 TTL COM 2 RS232 RS485 I 2 C master Digital I/O LCD Ethern. DIMM connector Embedded Java Controller block diagram

EJC Java Level User applications and servlets HTTP server FTP server Telnet server EJC class library + servlet framework JVM Intent JVM + PJAE + javax.comm EJC middleware and system software Kernel Drivers Elate RTOS kernel + low-level libraries (TCP/IP, file system architecture, graphic subsystem, etc.) Serial Ethernet I 2 C Dig I/O Flash NV RAM LCD Overview of the EJC software architecture.

EJC - Native Code Access to hardware or peripherals through native code: Special feature of the EJC (the intent JVM): Java classes can be directly written in VP assembler. VP assembler is a high-level assembler language which is targeted at a special Virtual Processor, and that is translated to native code either statically, at sysgen-time, or dynamically, when a class is loaded by the device (happens automatically). Access to hardware is possible without the runtime overhead of JNI or other similar mechanisms.

JNI JNI - The Java Native Interface Advantages: Support platform-dependent features. Integration: Make existing libraries or applications written in another programming language available to Java. Speed: Implement time-critical code.

JNI Application C Side Functions Libraries JNI Java Side Exceptions Classes VM

JNI JNI allows interaction in two directions: Java programs can use native methods written in other languages Native methods can use Java objects and methods out of Java applications

JNI Java Libraries C Program Java Classes Java Methods Java VM

JNI C Routines Assembly Rout. Java Program C++ Classes Exception Handler C Debugger C Runtime TypeChecker

JNI-Example Java-File: HelloWorld.java class HelloWorld { public native void displayhelloworld(); static { System.loadLibrary("hello"); } public static void main(string[] args) { new HelloWorld().displayHelloWorld(); } }

JNI-Example Java Code Compilation: javac HelloWorld.java Creating the C header file: javah jni HelloWorld

JNI-Example Name of native language function that implements the native methods: prefix + class name + _ + method name java_ + HelloWorld + _ + displayhelloworld JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld(JNIEnv *, jobject);

JNI-Example Native Methods (C code): #include <jni.h> #include "HelloWorld.h #include <stdio.h> JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld (JNIEnv *env, jobject obj) { printf("hello World!\n"); return; }

JNI-Example HelloWorldImp.c contains three header files: 1.jni.h This file contains information needed by the native language to exchange data with the Java runtime system. 2.HelloWorld.h The generated header file. 3.stdio.h Contains the printf function.

JNI-Example 1. Write Java Code HelloWorld.java 4. Write implementation of native method HelloWorldImp.c jni.h stdio.h 2. Compile with javac 5. Compile native code, load shared library HelloWorld.class 3. Generate header file with javah HelloWorld.h hello.dll 6. Run program using java interpreter "Hello World"

Java in Embedded Systems Why Embedded Java? Hardware Independence (greater than with C/C++) Downloading capabilities: Software downloaded into device Internet Connectivity Security Better Productivity

Application: CAN-Bus CAN-Bus Controller Area Network Serial 2-wire bus system aimed at autombile applications, developed by Bosch. International Standard (ISO 11898)

Field Bus Systems Field Bus Organizations Field Bus Systems Sensor/Actuator Bus Process Bus ASI INTERBUS-S PROFIBUS DP CAN DIN-Bus BITBUS PROFIBUS FMS P-NET

Field Bus Systems Virtual CAN Interface Control Functions Monitor Functions CAN Analyzer User Application Virtual CAN Interface PCI-card Port Adapter USB-CAN CAN

Java based CAN Program class: VCIJNI.java ** Function: VCI2_PrepareBoard ** Native method declaration public native int VCI2_PrepareBoard(CAN_Analyser myapp, int board_type, short board_no, String AddInfo, byte AddInfoLength, JCallback receive, byte [] m_callback_databytes);

Dynamic Link Libraries Code in class VCIJNI.java to load DLL (VCIJNI.dll) into memory Operating System Windows Unix Mac OS X Extension.dll.so.dylib ** JNI-function ** for loading of the VCIJNI.DLL static { System.loadLibrary("VCIJNI"); } public VCIJNI() { }

Dynamic Link Libraries Java Code Compilation: javac VCIJNI.java Creating the C header file: javah jni VCIJNI

Dynamic Link Libraries Generated Header File IXXAT_VCIJNI.h /* DO NOT EDIT THIS FILE - it is machine generated */ #include <jni.h> /* Header for class IXXAT_VCIJNI */ #ifndef _Included_IXXAT_VCIJNI #define _Included_IXXAT_VCIJNI #ifdef cplusplus extern "C" { #endif /* * Class: IXXAT_VCIJNI * Method: VCI2_PrepareBoard * Signature: (LIXXAT/CAN_Analyser;ISLjava/lang/String;BLIXXAT/JCallback;[B)I */ JNIEXPORT jint JNICALL Java_IXXAT_VCIJNI_VCI2_1PrepareBoard JNIEnv *, jobject, jobject, jint, jshort, jstring, jbyte, jobject, jbytearray);

Dynamic Link Libraries File VCIJNI.cpp implementeing the native code for function Java_IXXAT_VCIJNI_VCI2_1PrepareBoard JNIEXPORT jint JNICALL Java_IXXAT_VCIJNI_VCI2_1PrepareBoard ( JNIEnv * env, jobject jobj, jobject myapp, jint board_type, jshort board_no, jstring AddInfo, jbyte AddInfoLength, jobject JReceiveCallback, jbytearray callback_databytes) { int i_test; jboolean *iscopy = NULL; //Produce a new global reference to Object " JReceiveCallback " g_jobj_jcallback = env->newglobalref(jreceivecallback);

Dynamic Link Libraries Create Object: // Object with the Java Native Interface static VCIJNI vci = new VCIJNI(); // prepare board for further configuration i_test = vci.vci2_prepareboard( myapp, BoardConfStruct.board_type, BoardConfStruct.board_no, AddInfo, AddInfoLength, JReceiveCallback, JReceiveCallback.m_a_data);

Java/CAN - demo a) CAN Interface: USB-to-CAN Module Intelligent CAN module for the USB-Port

Java/CAN - demo b) Connected Device: Absolute Rotary Encoders Allows a direct read-out of the angular position

Java/CAN - demo Program Code: CAN Code: GUI: Java C++ Java Swing Future Expansion: Internet Connectivity: Java

Using Java to Control CAN Some more important applications CAN Bus CAN Device OFF ON Summer Cottage in Vaasa

The end Thank you!

The End Contact: Prof. Dr. Helmut Dispert University of Applied Sciences Kiel Faculty of Computer Science and Electrical Engineering Grenzstr. 3 24149 Kiel, Germany Tel.: +49-431-210-4114/4123 Fax.: +49-431-210-64114 E-Mail: helmut.dispert@fh-kiel.de