Difference between revisions of "DT 8025 2016 Practical 3"

From CERES
Jump to: navigation, search
(Created page with "== Objectives == There are two objectives for this practical: * Get more insight into the working of the Raspberry Pi, particularly with respect to the interrupt controller...")
 
Line 1: Line 1:
 
== Objectives ==
 
== Objectives ==
  
There are two objectives for this practical:  
+
There are three main objectives for this practical:  
  
* Get more insight into the working of the Raspberry Pi, particularly with respect to the interrupt controller and the timer.
+
* Learn about and use the concept of service in Android
* Understand the issues involved in scheduling of real-time systems.
+
 
 +
* Learn about and use the concepts related to network programming in Android
 +
 
 +
* Integrated several concepts and techniques learned in this course to implement an Android application
  
  
 
== Instructions ==
 
== Instructions ==
  
In this pratical you will revise your program that displays the prime numbers and blinks the LED by using interrupt handlers
 
  
=== Part 1: Configure Interrupt Handling ===
+
Start with a list of scenarios (use-cases) that the following application should be able to deal with:
 +
the scenarios should specify what kind of interactions the app should support in which order so as to realize users' requirements.
 +
Subsequently make an architectural design (preferably, but necessarily, using notations such as UML Class Diagrams an Sequence Diagrams)
 +
to show how the application should be decomposed into a number of activities and services.
 +
For each activity design the layout beforehand.
 +
Then, start programming.
 +
After you are doing, update the scenarios and design to reflect what you have actually implemented;
 +
use the scenarios as test-cases and make sure that the app does what it is supposed to.
 +
 
 +
Submit a single .zip file on blackboard with two folders: the first containing a single pdf reporting on the scenarios, design, test-cases and their outcomes,
 +
and the other containing the Eclipse project.
 +
 
 +
 
 +
== ESPoodle for Android! ==
 +
 
 +
=== Overview ===
 +
 
 +
The goal of this project is to implement a simplified version of [http://doodle.com/ Doodle] app for Android.
 +
The only part of functionality that we adopt in our practical is to:
 +
 
 +
* Connect to an [[media:doodleServer.zip|ESPoodle server]],
 +
 
 +
* Specify a new meeting request, its participants and 3 options for its time-slot
 +
 
 +
* Fetch one of the meeting requests for the participant and choose a preferred time-slot,
 +
 
 +
* Close a meeting request by selecting one of the time slots if all participants have made their choices, and
 +
 
 +
* Viewing the closed meetings in which a participant is involved.
 +
 
 +
=== Starting up ===
 +
 
 +
To achieve this, you will be given an IP address of an [[media:doodleServer.zip|ESPoodle server]] implemented and installed on a computer.
 +
The server listens on port 4444.
 +
Your app should first allow the user to enter this IP address and a unique ID which is to be used in meeting requests;
 +
use your HH account login name as the unique ID throughout this practical.
 +
 
 +
Then the app tries to connect to the server; if unsuccessful it will make three attempts with a 10 second delay in between
 +
(while providing sufficient information as toast messages).
 +
If successful, the client will receive the following tag from the server
 +
 
 +
 
 +
<Accepted connection from  id +/>
 +
 
 +
 
 +
where id is the unique identifier (account name) provided by the client.
 +
Then, the app will provide three possible options:
 +
 
 +
* to create a new meeting request, 
 +
 
 +
* to check for open meeting requests, and
 +
 
 +
* to  check for closed meeting requests.
 +
 
 +
=== Creating a new request ===
 +
 
 +
The app shows a layout in which the user can enter a unique meeting Id, a number of time-slots (for simplicity we assume that all meetings take one hour and hence, it suffices to mention the starting time), and identifiers of three participants.
 +
When the user presses the submit button,
 +
the client sends the following structure to the server
 +
 
 +
<OpenMeeting>
 +
    <MeetingId "5"/>
 +
    <Message text = "Please select a time for the coming meeting."/>
 +
        <time = "8:00"/>
 +
        <time = "10:00"/>
 +
        <time = "9:00"/>
 +
    <Participant numberOfParticipant ="3">
 +
        <name = "clientParticipantA"/>
 +
        <name = "clientParticipantB"/>
 +
        <name = "clientParticipantC"/>
 +
      </Participant>
 +
<OpenMeeting/>
 +
 
 +
The serve will reply to the meeting scheduler
 +
 
 +
<Request to start meeting is accepted/>
 +
 
 +
This is shown by a toast message and the app will return to the main menu.
 +
 
 +
=== Checking for open requests ===
 +
 
 +
The user may ask whether there has been any meeting request in which the current user is mentioned as a participant.
 +
In this case, after this option is selected from the main menu, the client
 +
end open meeting request like
 +
 
 +
  <CheckOpenMeeting/>
 +
 
 +
The server send all open meetings for the participant one by one like
 +
 
 +
<OpenMeeting>
 +
      <For "+clientParticipant+"/>
 +
      <MeetingId "5"/>
 +
      <Message text = "Please select a time for the coming meeting."/>
 +
      <time = "8:00"/>
 +
      <time = "10:00"/>
 +
      <time = "13:00"/>
 +
<OpenMeeting/>
 +
 
 +
 
 +
 
 +
The participant fetches one of the meeting requests for the participant and chooses a preferred time-slot and send
 +
 +
  <SelectedTime>
 +
      <MeetingId "5"/>
 +
      <time = "10:00"/>
 +
  <SelectedTime/>
 +
 
 +
The server will store the selected time immediately and send
  
Download the interrupt_2016.zip and get familiar with raspberry's interrupt controller and timer peripheral using the [https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf BCM2835 ARM peripherals datasheet]
+
    <reply>
 +
        <SelectedTime>
 +
            <MeetingId "5"/>
 +
            <time = "10:00"/>
 +
        <SelectedTime/>
 +
    </reply>
  
First, map the registers of the interrupt controller memory in file interrupts.h, i.e.,
+
=== Closing meeting requests ===
  
typedef struct {
 
  /**
 
  * your mapping goes here
 
  **/
 
} interrupt_controller_t;
 
  
This will allows us to request timer interrupts as follows
+
When this option is selected, the app will first ask the user to fill in the meeting identifier and then will fetch the meetings to which all participants have responded.
 +
This is done by first sending the following message to the server:
  
Interrupt_Controller()->Enable_Basic_IRQs = RPI_BASIC_ARM_TIMER_IRQ;
+
  <CheckMeetingRespond>
 +
    <MeetingId "5"/>
 +
  <CheckMeetingRespond/>
  
Then, setup the ARM timer interval by specifying the countdown value within the Load register. This value is loaded into the Value register if the Load register has been written or the Value register has counted down to 0.
+
then the server will send the name of the participants and the selected times to the meeting scheduler one by one as
  
ArmTimer()->Load = /** your countdown value goes here**/
+
  <SelectedTime>  
 +
      <MeetingId "5"/>
 +
      <name = "ParticipantName"/>
 +
      <time = "10:00"/>
 +
  <SelectedTime/>
 +
    ...
 +
and the number of participants who respond for the meeting
  
The Value register hold the current timer value and counts it down each timer clock until value 0 is reached. Then the value register is re-loaded from the timer Load register and the interrupt pending bit is set. Consider specifying the pre-scale bit when configure the ARM timer using the Control register.
+
  <NumberOfRespond "No"/>
  
RPI_GetArmTimer()->Control =
+
Then user can select one of the time-slots and close the meeting by sending the following message:
  /**
+
  * your configuration goes here
+
  */
+
  
Enable interrupt requests clearing the respective bit 7 of the current program status register. This operation is available through the given function call:
+
  <CloseMeeting>
 +
    <MeetingId "5"/><SelectedTime time = "10:00">
 +
  <CloseMeeting/>
  
_enable_interrupts();
+
=== Checking for closed meeting requests ===
  
=== Part 2: Implement Interrupt Procedure ===
 
  
Your program should now periodically execute the following interrupt procedure for the specified time interval within the Load register.
+
Participants can check closed meetings by
 +
  <CheckClosedMeeting/>
  
void __attribute__((interrupt("IRQ"))) interrupt_vector(void)
+
the server will send
{
+
  /**
+
    * your interrupt procedure goes here
+
    **/
+
}
+
  
Modify this interrupt procedure to blink the LED while displaying the square roots on the monitor screen connected through the HDMI port.
+
  <ClosedMeeting>
 +
      <MeetingId "5"/>
 +
      <SelectedTime time = "10:00">
 +
    <ClosedMeeting/>
  
Experiment with the timing interval and the pre-scale bit.
+
===[[DT_8025_2016 |Back to Course Page]]===

Revision as of 21:08, 19 October 2016

Objectives

There are three main objectives for this practical:

  • Learn about and use the concept of service in Android
  • Learn about and use the concepts related to network programming in Android
  • Integrated several concepts and techniques learned in this course to implement an Android application


Instructions

Start with a list of scenarios (use-cases) that the following application should be able to deal with: the scenarios should specify what kind of interactions the app should support in which order so as to realize users' requirements. Subsequently make an architectural design (preferably, but necessarily, using notations such as UML Class Diagrams an Sequence Diagrams) to show how the application should be decomposed into a number of activities and services. For each activity design the layout beforehand. Then, start programming. After you are doing, update the scenarios and design to reflect what you have actually implemented; use the scenarios as test-cases and make sure that the app does what it is supposed to.

Submit a single .zip file on blackboard with two folders: the first containing a single pdf reporting on the scenarios, design, test-cases and their outcomes, and the other containing the Eclipse project.


ESPoodle for Android!

Overview

The goal of this project is to implement a simplified version of Doodle app for Android. The only part of functionality that we adopt in our practical is to:

  • Specify a new meeting request, its participants and 3 options for its time-slot
  • Fetch one of the meeting requests for the participant and choose a preferred time-slot,
  • Close a meeting request by selecting one of the time slots if all participants have made their choices, and
  • Viewing the closed meetings in which a participant is involved.

Starting up

To achieve this, you will be given an IP address of an ESPoodle server implemented and installed on a computer. The server listens on port 4444. Your app should first allow the user to enter this IP address and a unique ID which is to be used in meeting requests; use your HH account login name as the unique ID throughout this practical.

Then the app tries to connect to the server; if unsuccessful it will make three attempts with a 10 second delay in between (while providing sufficient information as toast messages). If successful, the client will receive the following tag from the server


<Accepted connection from  id +/>


where id is the unique identifier (account name) provided by the client. Then, the app will provide three possible options:

  • to create a new meeting request,
  • to check for open meeting requests, and
  • to check for closed meeting requests.

Creating a new request

The app shows a layout in which the user can enter a unique meeting Id, a number of time-slots (for simplicity we assume that all meetings take one hour and hence, it suffices to mention the starting time), and identifiers of three participants. When the user presses the submit button, the client sends the following structure to the server

<OpenMeeting>
    <MeetingId "5"/>
    <Message text = "Please select a time for the coming meeting."/>
       <time = "8:00"/>
       <time = "10:00"/>
       <time = "9:00"/>
    <Participant numberOfParticipant ="3">
        <name = "clientParticipantA"/>
        <name = "clientParticipantB"/>
        <name = "clientParticipantC"/>
     </Participant>
<OpenMeeting/>

The serve will reply to the meeting scheduler

<Request to start meeting is accepted/>

This is shown by a toast message and the app will return to the main menu.

Checking for open requests

The user may ask whether there has been any meeting request in which the current user is mentioned as a participant. In this case, after this option is selected from the main menu, the client end open meeting request like

 <CheckOpenMeeting/>

The server send all open meetings for the participant one by one like

<OpenMeeting>
     <For "+clientParticipant+"/>
     <MeetingId "5"/>
     <Message text = "Please select a time for the coming meeting."/>
     <time = "8:00"/>
     <time = "10:00"/>
     <time = "13:00"/>
<OpenMeeting/>


The participant fetches one of the meeting requests for the participant and chooses a preferred time-slot and send

  <SelectedTime> 
      <MeetingId "5"/>
      <time = "10:00"/>
  <SelectedTime/> 

The server will store the selected time immediately and send

   <reply>
       <SelectedTime> 
            <MeetingId "5"/>
            <time = "10:00"/>
       <SelectedTime/> 
   </reply>

Closing meeting requests

When this option is selected, the app will first ask the user to fill in the meeting identifier and then will fetch the meetings to which all participants have responded. This is done by first sending the following message to the server:

 <CheckMeetingRespond>
    <MeetingId "5"/>
 <CheckMeetingRespond/>

then the server will send the name of the participants and the selected times to the meeting scheduler one by one as

 <SelectedTime> 
      <MeetingId "5"/>
      <name = "ParticipantName"/>
      <time = "10:00"/>
  <SelectedTime/> 
    ...

and the number of participants who respond for the meeting

 <NumberOfRespond "No"/>

Then user can select one of the time-slots and close the meeting by sending the following message:

 <CloseMeeting>
    <MeetingId "5"/><SelectedTime time = "10:00">
 <CloseMeeting/>

Checking for closed meeting requests

Participants can check closed meetings by

  <CheckClosedMeeting/>

the server will send

  <ClosedMeeting>
      <MeetingId "5"/>
      <SelectedTime time = "10:00">
   <ClosedMeeting/>

Back to Course Page