You are on page 1of 79

Fleet Management System

Major project report


by

Jithin V Mohan & Minu Balan


Dept. of Computer Science and Engineering

Sharoon Thomas & Lynn Mariette Mendonza


Dept. of Electronics and Communication Engineering

Under the guidance of

Mr. Shine N Das Mr. Biju V G


HoD, Dept. of Computer Science HoD, Dept. of Electronics and
and Engineering Communication Engineering

MARCH 2009

Submitted in partial fulfillment of the requirements for the award of B.Tech Degree in
Computer Science and Engineering of Cochin University of Science & Technology

Department of Computer Science and Engineering


College of Engineering, Munnar
College of Engineering, Munnar
Munnar, Idukki, Kerala 685612
Department of Computer Science and Engineering

Certificate

This is to certify that the Major Project entitled

FLEET MANAGEMENT SYSTEM

submitted by Jithin V Mohan, 10262611 for the award of Degree of Bachelor of


technology in Computer Science & Engineering of the Cochin University of Science and
Technology is a bona-fide account of the work carried out by him in this department during
the academic year 2008-2009 under our supervision

Head of the Department


Fleet
Management
System
GPS Vehicle Tracking and
development of a fleet
management module for
OpenERP

Jithin V Mohan
Minu Balan
[Dept. of Computer Science]

Sharoon Thomas
Lynn Mariette Mendonza
[Dept. of Electronics & Communication]

College of Engineering, Munnar


Jithin V Mohan#
Minu Balan#
Sharoon Thomas*
Lynn Mariette Mendonza*

#
Dept. of Computer Science and Engineering
*
Dept. of Electronics and Communication Engineering

College of Engineering, Munnar

jithinvmohan@gmail.com
minu.frnds@gmail.com
sharoonthomas@teagarden.in
lmmendonza@gmail.com
Acknowledgements

We are grateful to the Principal & Staff of College of


Engineering, Munnar for their support in the proceedings
of this project, especially our Head of the Departments,
Mr. Shine N Das of the Department of Computer Science
& Engineering and Mr. Biju V.G of The Department of
Electronics & Communication. We would also like to
thank our lab technicians who provided us with the
required equipments round the clock.
Major Project ‘09 1
Fleet Management System

Table of Contents

ABSTRACT 4
INTRODUCTION 5
1.1 Background 6
Project Requirements 7
1.2 Resources 7
UNDERLYING TECHNOLOGIES 8
2.1 Wireless communication 8
2.1.1 GSM 8
2.1.2 GPRS 9
2.2 Internet Protocol 11
2.3 Global Positioning System 12
2.3.1 Triangulation 13
2.3.2 Technical issues 13
2.3.3 Error sources 14
2.3.4 NMEA Protocol 14
2.3.5 Competing positioning systems 15
2.4 Input/Output 16
2.4.1 RS232 16
2.4.2 Buses 17
2.4.3 General input/output pins 17
2.5 Python Programming 18
HARDWARE PLATFORM 19
3.1 GSM Module 19
3.1.1 General applications 19
3.1.2 Hardware 20
3.2 Remote Update 21
3.3 Telit GM862 GPS 21

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 2
Fleet Management System

3.3.1 Overview 21
3.3.2 Logic Levels 22
3.3.3 Antenna Requirements 22
3.3.4 Software 22
HARDWARE DEVELOPMENT 24
4.1 Block Diagram 24
4.2 Control Flow Diagram 25
4.2.1 Flow Chart 25
4.3 Sound System 29
4.4 Tamper System 31
WEB RESOURCE DEVELOPMENT 32
5.1 Google Maps API 32
5.2 MySQL 32
5.3 PHP 33
5.4 Software Requirement Specifications 34
5.4.1 Overall Description 34
5.4.2 User Classes and Characteristics 34
5.4.3 Operating Environment 34
5.4.4 Design and Implementation constraints 34
5.4.5 Assumptions and Dependencies 34
5.4.4 Product Description 35
5.4.5 Page Hierarchy 36
OPENERP INTEGRATION 38
6.1 Open Source Software at the Service of Management 38
6.2 The OpenERP Solution 39
6.3 Fleet Management Module 40
Appendices

A Telit GM862GPS Datasheet

B Source Code (Web Side)

C Source Code (Device Side)

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 3
Fleet Management System

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 4
Fleet Management System

ABSTRACT

T
his project, code named 'Project Marauders Map' is an Enterprise Fleet
Management System for large and medium fleets (Trucks, Cars, Buses).
The project consists of a hardware platform which manages Vehicle data,
Global Positioning and Wireless Communication, and a software platform to
provide integration into real-time mapping, costing, inventory, asset status and HR
processes.

The hardware platform uses a GSM module, a stripped down version of the mobile
that allows Python scripts to run as third party applications. This report reviews the
development of the Fleet Management System, its feasibility and presents
experiences from implementation of a prototype based on the Telit GM862 GPS.

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 5
Fleet Management System

INTRODUCTION

T
he Fleet operation industry has been an area of heavy investment since
Independence and the progress has been significant. But the task is so
gigantic that it would require many years and large doses of investment to
bring about the desired improvement in the country's transportation system. India‘s
transport sector being large and diverse; caters to the needs of 1.1 billion people. In
1997, the sector contributed 4.4 percent to the nation‘s GDP, with road
transportation contributing the lion‘s share. Good physical connectivity in the
urban and rural areas is essential for economic growth. Since the early 1990s,
India's growing economy has witnessed a rise in demand for transport
infrastructure and services by around 10 percent a year. However, the sector has
not been able to keep pace with rising demand and is proving to be a drag on the
economy. Major improvements in the sector are therefore required to support the
country's continued economic growth1.

Fleet Management System, aims at improving the quality and efficiency of the
industry by identifying & tackling major roadblocks in the day to day operations of
a typical enterprise.

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 6
Fleet Management System

1.1 Background
In the current scenario, most small scale overall impact of reducing efficiency
fleet operators use manual methods of and increasing the cost of operation.
fleet management and have no tracking Hence these solutions are limited to a
system at all. The medium and larger few players who could afford the
enterprises on the contrary have some investment and subsequent training of its
levels of management integrated into employees. These solutions also lack
their operations. Most firms have now integration with the existing tracking
deployed GPS based tracking units in hardware.
their mobile assets for better monitoring. With the increased competition in the
Such devices are widely available from industry, companies are now looking for
many vendors across the country, and ways to improve their efficiency. FMS is
offer a web interface on their websites an umbrella term for applications that
for tracking. However these devices also aim at improving the overall
add to the inherent Indian problem of performance of a hauler‘s fleet in terms
'Lack of Integration' with existing of fuel economy, maintenance costs,
infrastructure. utilisation level, etc. FMS‘ main
Softwares in use by the medium players advantages are better transport
of the industry are mostly limited to coordination, better vehicle and driver
spreadsheets or custom solutions follow up, faster and more precise
developed by regional software invoicing, and faster assistance in case
developers. Lack of support, security of a road side breakdown2.
and synchronisation issues are few Considering the above facts, this project
drawbacks of such solutions. The giants introduces the use of latest hardware
however have resorted to the use of systems and open source tools to build a
proprietary ERP solutions to increase low cost Fleet Management System for
quality & efficiency. These solutions the South Asian market addressing the
with sky rocketing prices and longer problems discussed.
deployment times, in turn have an

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 7
Fleet Management System

Project Requirements
The project was divided into five parts.

i. Identification of industry requirements and ideal tools to address them.


ii. Evaluation of possible hardware platforms.
iii. Development of Hardware prototype
iv. Web resources development
v. OpenERP integration

The aforesaid goals had to be achieved and documented in a report including review of the
hardware platform used, feasibility in the South Asian region, future prospects and
implementation of a prototype.

1.2 Resources

This project focuses on prototype Notes have also been taken from blogs and
development and hence the investigating forums of active hobbyists involved in
part consists of hardware platform reviews development of M2M platforms.
and evaluation. Therefore much of the The technologies used in the project are all
resources have been data sheets and product in wide use. They are themselves
specifications. extensively documented and a detailed study
Specifications of hardware components used of them is beyond the scope of this report
have been acquired from web pages of
respective manufacturers.

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 8
Fleet Management System

UNDERLYING TECHNOLOGIES

This chapter will explain the fundamentals of technologies used by the project prototype. It is not
meant to be a complete description, but rather an orientation to help the reader understand
possibilities and limitations of the studied task. For a more thorough study, see the references at
the end of the report.

2.1 Wireless communication


[Paragraph 2.1 is based on ref 3] bandwidth. The application of this project
When data needs to be sent from a moving
has low demands on bandwidth, but requires
target, or from remote locations, wireless
country wide coverage. For this type of
communication is desirable. There are a
applications GSM/GPRS is the most suitable
number of techniques available with
candidate today.
different focuses regarding range and

2.1.1 GSM
The Global System for Mobile versions of the standard have been released,
telecommunications, GSM, standard was allowing higher data rates and new features
developed in the eighties to address the in the networks.
problem of compatibility between numerous The basic GSM network is circuit switched,
telecommunication systems that had just like an ordinary land line telephone
emerged. A first version of the standard was network. When a call is established between
completed in 1990. Since then, the system two nodes, the link in-between is busy,
has been adopted around the world, and new regardless of anything is being

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 9
Fleet Management System

said/transmitted or not. To allow many


simultaneous calls over the radio link, GSM
uses multiple frequency channels around its
basic working
frequency, 900 MHz. One set of
frequencies is used for uplinks and one set
for downlinks. These frequency channels, in
turn, use Time Division Multiple Access, The GSM network is divided into cells, with
TDMA to further increase the number of each cell having its own Base Station
parallel lines. TDMA means that a channel System, BSS. The BSS contains a radio
is chopped up into a set of repeating time transceiver and a controller. The controller
slots. Each (cell phone) connection has its handles the radio channels and forwards
own repeating time slot in a channel. (see calls in the cell to a switching centre in the
figure 2.1) The cell phone samples some network. The switching centre in turn routes
speech, the call onwards to the target BSS or to
compresses it and sends it in its next slot. another network. The GSM network also
For this to work, the time to transmit one contains a set of data bases which contains
second of compressed speech has to be information about attached cell phones, their
much shorter than one second. rights and statuses. See figure 2.2.

Figure 2.2: Rough Structure of a GSM Network

2.1.2 GPRS
An extension to the GSM standard called
General Packet Radio Services, GPRS, was
released in 1997. GPRS allows packet based
data to be sent in the GSM network and
onwards through gateways to the internet
using standard internet protocols. This also
implies that computers connected to the

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 10
Fleet Management System

internet need no special hardware to A GPRS device can only send at one
communicate with a GPRS device. frequency at a time (use one channel), but it
Data to be sent is first divided into small can use more than one slot in each time slot
pieces, packets. The individual packets are cycle of that channel to increase its
then sent as soon as there is a time slot bandwidth. GPRS devices are divided into
available in the network. Finally, transmitted classes according to the number of time slots
data is reconstructed from the packets at its they can make use of. Performances range
destination. See figure 2.3. No user ‗owns‘ a from utilising one slot in each direction in
repeating time slot, as in the basic GSM class one, to four slots in one direction and
network. This allows a more efficient use of one in the other (4+1 or 1+4), in class 12.
thebandwidth. When user A doesn‘t need See table 2.1.
any time slots, user B can have them and The theoretical data rate, when using one
vice verse. Both users can still be constantly slot, is 13,400 bits per second, giving 53,600
attached to the base station, much like an bps for class 12. These 53,6 kbps is the ―raw
internet broadband connection, ready to send data‖ rate; up to 25 percent thereof is used
or receive. Network operators often employ for error correction and redundancy, leaving
a tariff scheme where users pay for the data about 40 kbps for user data.
actually sent, not the time period he is Table 2.1: Examples of GPRS classes.
connected. The pay-per-byte nature of ‘Active slots’ gives the maximum number of
GPRS makes it ideal to use with remote simultaneously utilized
devices that need to be constantly connected slots. For example class 11 supports up to
four slots for the uplink and up to three slots
to other devices, or to a central server, but
for the downlink,
only exchanging small amounts of data but it can only use a total of five slots
simultaneously.

GPRS Class Uplink Slots Downlink Active Slots


Slots
2 2 1 3
4 3 1 4
6 3 2 4
8 4 1 5
spread over long periods of time. 11 4 3 5
Figure 2.3: Time slot usage of a GPRS channel 12 4 4 5

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 11
Fleet Management System

address. The operator then routes incoming


A GSM network needs new software and
requests to the public IP address through the
hardware to handle GPRS. For example, the
DNS server to the unit‘s current dynamic IP
base station controller needs software to
address.
manage new coding schemes. GPRS data is
2.2 Internet Protocol
sent from the BSS to GPRS support nodes in
[Paragraph 2.2 is based on ref 4]
the network. They have roughly the same The Internet Protocol Suit, IPS, has been
functionality as the switching centre in used since the beginning of the eighties for
GSM. The routing to and from other IP communication between remote computer
based networks (internet) is done through systems. With the introduction of GPRS in
gateways. See figure 2.4. the GSM network, GSM devices could
adopt the same suit of protocols to
communicate with computers on the
internet.
Data to be sent from a device over the
internet faces an elaborate 2.2 scheme. It
needs to be packed and wrapped before it
can be transmitted, and control mechanisms
are needed to make sure it reaches its

Figure 2.4: Rough structure of GPRS network destination. An application sending data
usually needs not to worry about all this.
The required functionality is provided at a
Assignment of an IP address to a unit is lower level by the IPS. IPS has a layered
done dynamically by the network operator, architecture. The bottom layer handles the
i.e. A unit‘s IP address will change over physical link; sending and receiving of raw
time. This means that there is no way for a bits. The top layer provides an interface that
server that wants to contact a unit to know applications can use. Each layer in between
its IP address for sure. Lately specialised handles its own part of the transmission. A
operators utilize a Domain Name System, layer only serves the layer immediately
DNS, to give a unit a static public IP above and only makes requests to the layer

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 12
Fleet Management System

immediately below. With well defined are usually implemented in higher level
interfaces between the layers, this makes for protocols when using UDP.
a flexible and easily maintained architecture.
This approach is promoted in the more
general Open Standards Interconnect, OSI,
model and is often called a protocol stack, in
this case an Internet Protocol stack, IP-stack.
The layers of the IP-stack are a subset of
those defined in the OSI. The IP-stack layers
are outlined in figure 2.5.
The main option for the application
programmer when configuring an IP-stack
is, apart from the targets addresses, the use Figure 2.5: IP-Stack Layers
of either TCP or UDP. TCP provides a
controlled channel to the target. It makes
sure that everything that is sent is delivered 2.3 Global Positioning System
to the recipient, and that it is delivered in the [Paragraph 2.3 is based on ref 5]

right order and without errors. To handle


The Global Positioning System, GPS, was
this, TCP contains sequence numbers and
developed by the United States Department
timers to control sent data and retransmit
of Defence during the seventies and eighties
when data get lost. UDP lacks all this. There
and became operational in 1993. The system
are no guarantees that data sent by UDP
works in two parallel modes; one with
arrives correct at the destination, or that it
higher precision that is encrypted and
arrives at all. The control mechanisms of
reserved for US military, and one with less
TCP create a lot of overhead to the ‗useful‘
precision that is free to use by the public. An
data. In some applications, the security of
ordinary civilian GPS has an accuracy of
TCP can be traded for the lower bandwidth
about 15 meters. The core of the GPS
demanded by UDP. The choice here is TCP.
infrastructure consists of 24 satellites in
Some data integrity and flow control checks
orbit (plus three used for backup) and a set
of satellite tracking stations around the

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 13
Fleet Management System

world. The satellites send positioning data have some accurate way to measure
and system information to users on earth. distance. The first problem is not so hard.
Each satellite transmits at two frequencies, Orbits of the satellites are stabile and can be
one for civil and one for military use. predicted with high accuracy by
mathematical formulas. In addition to this,
2.3.1 Triangulation tracking stations around the world monitor
the satellites positions and update them

GPS positioning is based on triangulation. A when they are off course. The satellites in

GPS receiver on earth first measures its turn, send correction data to the GPS

distance, R1, to one of the GPS satellites, receivers. The receivers store the positions

S1. The receiver has then pinned its position of the satellites and can then calculate

down to a sphere with radius R1 around S1. satellite positions for the coming time

By repeating this procedure for two more intervals, until the satellites send the next

satellites the receiver has three spheres that position update.

intercepts in two points. One of these two To measure distance, a given predefined

points can be discarded as being to far from pseudo random code is transmitted by the

the earth; the other interception point is the satellite starting at a given time. At the same

receiver‘s location. There is a fourth time, the receiver starts to generate the same

variable added to the three ‗room‘ dittos: code. By correlation, the receiver then

relative time of the clocks in the satellites measurers the time offset between its own

and receivers. Therefore a fourth satellite is code and that received from the satellite.

required to solve the equation. The reason The signal from the satellite is an

for is described in more detail in the next electromagnetic wave with finite speed, c.

paragraph. Multiplying the time offset, ∆t, of the two


codes with c gives the distance between

2.3.2 Technical issues satellite and receiver. Additional techniques,


including measuring the phase of the signal
carrier, can be used to enhance precision.
For the positioning to have a meaning, the
The critical part of the distance
receiver must know where the satellites are
measurement is timing, which must be
relative to the earth. The receiver also has to

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 14
Fleet Management System

extraordinarily precise. If the two clocks of a 2.3.3 Error sources


satellite and a receiver are off by just 1
microsecond, the error in distance The main limitation of GPS accuracy used
measurement will be 300 m. The satellites to be the Selective Availability, SA. This
use highly accurate atomic clocks that keep was a random bias applied to the civilian
the system ‗GPS-time‘. To equip a receiver satellite signal by the US Department of
with an atomic clock would make it very Defence to limit non-military accuracy. The
expensive. Instead, the receiver hosts an SA was turned off in the year 2000,
ordinary quartz clock which is continuously enhancing GPS accuracy by a factor of 10.
set by the atomic clocks of the satellites. As The main limiting factors of GPS accuracy
mentioned above, three dimensional today are path errors. The satellite signal
positioning requires three ‗visible‘ satellites, bounces on atmosphere and items in the
if all parts keep the same time. receiver‘s vicinity, making the path travelled
In practice, there is a fourth variable; the longer then the straight line assumed. A
offset between the receiver clock and GPS- more severe limitation is that the satellite
time. To solve the equation, a total of four signal can be completely blocked by
visible satellites are required. Four variables buildings in ―city canyons‖ or in tunnels.
and four equations, one for each satellite, The GPS signal, coming form a satellite in
gives a definite solution. The requirement of orbit, is very weak compared to, for
four visible satellites is fulfilled 95 % of the example, a GSM signal, making it very
time in all places around the world. The sensitive to blocking. This error can be
probability is better in populated areas partly worked around with ―dead reckoning‖
where usually six to eight satellites can be by use of accelerometers.
spotted. Each satellite is called a channel.
―Number of channels‖ is a marketing feature 2.3.4 NMEA Protocol
for GPS- receivers. A 6-channel receiver can [Paragraph 2.3.4 is based on ref 6]

monitor six satellites simultaneously,


The de facto standard communication
making more precise positioning possible.
protocol to get positioning data from a GPS
receiver is developed and controlled by the
US National Marine Electronics

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 15
Fleet Management System

Association, NMEA. The standard is aimed 7) FAA mode indicator (NMEA 2.3 and
at marine electronics, and GPS later)
communications is a subset of it. The most 8) Checksum
common version, NMEA 0183, is quite
simple and allows one talker (in this case the 2.3.5 Competing positioning
GPS receiver) to send ASCII character systems
‗sentences‘ to one or more passive listeners,
A global navigation system similar to GPS
for example a navigation device. Apart from
was developed in Russia in parallel with the
the physical matters the standard defines a
US development. The Russian system is
set of sentences to declare, for example;
called GLONASS, Global'naya
position, current time, system status, etc.
Navigatsionnaya Sputnikovaya Sistema. It
These are transmitted in a loop by the talker.
was fully operational for a while in the mid
The sentences can be decoded by a
nineties, but declined along with Russian
compatible listener, (computer, PDA) which
economy. The system is again gaining
can then process the data further. Below is
momentum, with planned world coverage by
an example of the NMEA sentence GLL,
2010.
Geographic Position – Latitude/Longitude.
The European Union is developing their
own navigation system, Galileo, with
1 2 3 4 5 67 8
partners including China and Israel. Galileo
| | | | | || |
is planned to be operational in 2008. Both of
$--
these systems provide roughly the same
GLL,llll.ll,a,yyyyy.yy,a,hhmmss.ss,a,m,*hh
accuracy as GPS, but it will be some time
Field Number:
after their launch dates before the market for
1) Latitude
receivers is as developed as that for GPS.
2) N or S (North or South)
Because of this, these systems will not be
3) Longitude
real competitors to GPS for a long time.
4) E or W (East or West)
A different approach to positioning which is
5) Universal Time Coordinated (UTC)
under development, is through GSM-
6) Status A - Data Valid, V - Data Invalid
networks. It is based on a number of
techniques involving radio frequency signal

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 16
Fleet Management System

strength from different GSM base stations. bit rate and ability to supply current to the
Coverage of the system is limited to GSM- peripheral unit. An advantage of RS-232 is
network coverage, and accuracy today is that it requires less software support than
about 200 m in urban areas, decreasing to 4 USB, making it a good option for devices
km in rural zones, compared to about 15 with limited resources, where it is still in
meters for an ordinary GPS. wide use. One case could for example be to
The conclusion is that as of today and connect a GPS
coming years, there are no real competitors to a PDA. As mentioned above, a set back
to GPS. of the standard is that it defines a large
voltage swing. -15 ÷ -3 V for logic one and
2.4 Input/Output 3 ÷ 15 V for logic zero. This large swing

The following paragraphs gives a limits the maximum bit rate due to limited

description of different input and output, IO, slew of the signal generator. Also, an

standards supported by the module Telit ordinary TTL9 or CMOS10 circuit can not

GM862 GPS. produce these levels, so external level

2.4.1 RS232 converters are required to such a circuit. The


[Paragraph 2.4.1 is based on ref 7] standard defines 20 signals, but more
common is a four signal plus ground subset.
The EIA232 standard, generally called RS- It allows a full duplex link with flow
232, defines electrical and mechanical control. A two signal plus ground full
properties of a serial data link. The standard duplex link without flow control is also
does not define character encoding or bit common. The remaining signals are defined
rates; these can be chosen by the application. for, for example, common clock and
Feasible bit rates do not exceed 256 kBit/s secondary data lines.
due to the large voltage swing requirements For historical reasons, the signals of the
of the signal. The first version of the standard are labelled by a Data Terminal
standard was released in 1969, and an RS- Equipment, DTE, sending data to a Data
232 port was standard equipment on PCs Communicator Equipment, DCE. The DTE
until the nineties. USB8 has now replaced is referring to a computer and the DCE is
RS-232 in the PC area because of its higher

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 17
Fleet Management System

referring to a modem, which was the set up two bidirectional wires for clock and data,
that the standard was originally intended for. and can in the latest revision transfer data in
rates up to 3.4 Mbit/s, with 100 and 400
The 4 +1 signal sub set is: Kbit/s being more common. The standard
TD Transmitted Data from DTE to DCE uses 10 bit addressing, enabling up to 1000
RD Received Data from DCE to DTE unique nodes to be pointed out on the bus, as

RTS Request To Send. long as the total bus capacitances don‘t


exceed 400 pF. Since capacitance of a wire
CTS Clear To Send.
is proportional to its width and length, 1000
In half duplex mode, RTS and CTS make a
nodes might not be possible in practice. The
full handshake. In full duplex mode, DCE
capacitance restriction also shows that the
transmits whenever RTS is high and DTE
bus is not optimal for off PCB
transmits whenever CTS is high. GND
communication, since cables tend to have
Common Ground (this might not be true if
relatively large capacitance.
the signalling cable is long). The two plus
SPI is another simple serial bus intended for
one signal implementation consists of TD,
use on PCB. It is a single master bus with
RD and GND.
chip select instead of addressing. This
makes it suitable for longer data streams
2.4.2 Buses
from one or a few slaves, rather then reading
and writing many addressed nodes. SPI
Telit GM862 GPS supports Inter Integrated
allows higher data rates than I2C, 10 Mbit/s
Circuit, I2C, and Serial Peripheral Interface,
and more. SPI does not specify any
SPI, buses. These buses are mainly intended
acknowledgement or flow control, so
for on-PCB, Printed Circuit Board, use.
higher-level protocols have to be
They could come into practice in a design
implemented by the user.
with a dedicated PCB to connect e.g. a GPS
receiver to the GSM-module and will
2.4.3 General input/output pins
therefore be describe briefly.
I2C is a multi-master bus invented by
Telit GM862 GPS has a range of pins that
Philips. It features a simple flow
can be used as either digital inputs or
controlmechanism. Signalling is done over

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 18
Fleet Management System

outputs. The direction of the pins can be variables. Therefore, values, not variables
configured in application software. Hence carry type. This enables shorter code, but is
they are called General Purpose Input also a great error source. The feature takes
Output, GPIO. Digital pins could for some time to get used to if one is used to for
example be used to connect an alarm button example Java programming. Python is
to the module, or some indication Light designed with the intention of being highly
Emitting Diodes, LED‘s. An output pin, in readable. To attain this it has a simple visual
general, does not supply much current, so layout, English keywords instead of
additional driving is needed to drive the punctuation, and fewer syntactic constructs
external item, e.g. LED.Telit GM862 GPS than for example C.
has one input pin, an output pin and 11 White space is used as delimiter instead of
GPIO pins. brackets. Python is the only major language
with this approach. This enforces the
2.5 Python Programming indentation convention used in many other
languages with the motivation of making the

The first version of Python was released in language more readable. This can be seen in

the early nineties. It is now developed by Appendix B,‗Source Code‘. Space and tab

The Python Software Foundation as an Open indentations are interpreted differently at

Source project. Although used for some runtime. If they are mixed they will generate

popular programs like the original errors.Since space and tab are visually

BitTorrent tracker, Python is not as widely similar, these errors can be hard to detect

adopted as the other languages in this when debugging.The Python language is

review. Python is an interpreted language, multi-paradigm, permitting several

meaning that it is compiled at runtime. programming styles; object-,functional- or

Unlike most mainstream languages, it is structural-orientated. Exception handling is

dynamically typed with no predefinition of supported.

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 19
Fleet Management System

HARDWARE PLATFORM

3.1 GSM Module access very easy. As of today there are


modules available from half a
dozen producers. An example of what a

G
SM-modems have been around
for some 10 years. A GSM- GSM-module looks like is shown in figure
modem is simply speaking a 3.1.
mobile phone that has been stripped of its
display and keyboard, leaving only the
actual radio device, control circuits and IO.
The device can then be embedded into a
product as a communication link to cell-
Figure 3.1: Telit GM 862 GPS
phone networks and onwards to the internet
During the past three-four years, an 3.1.1 General applications
enhanced type of GSM-modem has
emerged. They will be called GSM-modules
GSM modules allow highly integrated
in this project. The difference to an ordinary
embedded systems with Internet
modem is that the module allows the
connectivity, where component count can be
running of third party application code
kept to a minimum. They target products
within the unit, eliminating the need of an
that need connectivity with each other or a
external controller. The GSM-modules also
central server from remote locations. The
host internal IP-stacks, making Internet
main property to keep in mind when
designing a system where the intelligence is

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 20
Fleet Management System

embedded into a GSM-module is the limited CPU power and memory. Since the
modules have limited resources, their tasks GSM-terminal, the module also provides
should be kept simple and non-time-critical. means to execute third party application
Possible applications include collecting and code. The application could either be run on
sending positioning information from a spare capacity in the module‘s baseband
vehicle, CPU, or in a dedicated application CPU.
reporting stock of a vending machine,
weather data from a weather station, etc. In The target applications of GSM-modules
addition to the stand-alone mode, all often include positioning. To meet this
modules evaluated in this report can also be demand, GSM-modules with internal GPS
controlled by an external CPU, like a have been released. The GPS receiver chip
traditional GSM-terminal. The two different is fitted into the module and connected to
architectures are shown in figure 3.2. the application CPU. In all released
implementations, the link in between the
CPU and GPS is a RS-232 line and it
decreases the number of external serial ports
of the module by one, compared to the
respective models without GPS.
The connector of the modules is either a ball
grid array, BGA, or a multi pin board-to-
board connector. A dedicated Printed Circuit
Figure 3.2: Comparison of architectures Board, PCB, is then needed to use the
module. The PCB should contain proper IO
3.1.2 Hardware
connectors, peripheral circuitry such as RS-
232 level converters, and power supply. A
A GSM module contains a baseband CPU
GSM device has some particular powering
that maintains the GSM/GPRS protocols.
demands. Though its average power
The CPU communicates with a high
consumption is rather low, the unit can need
frequency radio transceiver that modulates
up to two ampere when transmitting in its
the signal from the baseband CPU and
transmits it into the ether. In difference to a

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 21
Fleet Management System

time slot. This should be accounted for in and can‘t be accessed. Mechanism for the
the power supply design. remote update in the FMS is using the FTP
Developing a PCB takes time. To speed up feature of Telit GM862 GPS. Appendix B
prototyping, and to allow parallel hardware has the detailed code for the purpose.
and software development, all GSM-module
producers provide test boards for their 3.3 Telit GM862 GPS
models. These boards offer complete
support for a module, so that the application
Telit is based in Trieste, Italy, with Arrow
programmer can start to work at once.
and Round Solutions as Swedish sales
However the EVK2 board combatible with
agents. Telit has developed cellular based
the Telit GM862 GPS being as expensive as
products since the mid eighties. Their
the module itself was ruled out.
product ranges today include both GSM
handsets and modules. Their most suitable
3.2 Remote Update module for this project is the GM862-GPS.
It has an embedded Python script interpreter

Remote update is a way to update for embedded applications and a GPS

application code from a remote location by receiver.

downloading new code and replacing the old


one. In the case of GSM-modules, this is 3.3.1 Overview
also called Over The Air, OTA update, since
the new code is downloaded wirelessly. The application code of the Telit modules is
Most modules of the review of this report run as a single thread in the baseband CPU.
support remote update of application code. This is a cost efficient solution, but
An update could be required to change the decreases performance since the baseband
use of the module, or to correct a bug in the CPU‘s main priority is to keep the GSM
application code. To update a large fleet of protocol. For example IO operations of an
trucks spread over a vast geographical area application, that need not to interfere with
by ‗cable‘ is very costly. Remote update the radio unit at all, now has to compete
could be risky though, if the device with it for resources.
accidentally ends up in some deadlock state

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 22
Fleet Management System

The GM862-GPS has only one external


RS232 port. With RS232 being the preferred
link to a CAN-bus interface, this single port
will be dedicated to CAN. The port is a
‗full‘ 9- pin RS-232, but no flow control is
available when the module is in the Python
script mode, and the hardware buffer of the
port is only 256 bytes. The module features
3.3.3 Antenna Requirements
an internal SIM-card reader. This eliminates
the need for an external one, but gives
constraints on module placement in a
housing box, so that the SIM-card slot can
be accessed. The module is connected to the
PCB trough a 50 pin board to board
connector. The module is also available in a
version with ball grid array connector, and
no internal SIM-card reader.
If the module is installed in accordance with
Telit instructions, no further approvals on
EMC or radio spectrum are needed.

3.3.2 Logic Levels

Where not specifically stated, all the


interface circuits work at 2.8V CMOS logic 3.3.4 Software
levels.

The GM862-GPS supports Python Scripts.


Telit chose the Python language because it is
high level and open source, i.e. no royalties
to be included in the module price, and the

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 23
Fleet Management System

interpreter engine takes less resources than a


Java engine. The script and the interpreter Some specific features have also been added
have 1.5 MB of RAM available. Script and for control of the hardware in the module:
data files can be written and read on a single GPS, serial port, timers and IP connectivity.
level file system with a total size of 3 MB. The module can only keep a single IP socket
Figure 3.3 shows the software environment open at a time. Most of the Telit added API
of the module. The Python script is run as a is based on AT-commands which are sent to
thread in the baseband CPU. It has the the GSM baseband CPU through a virtual
lowest priority, allowing all other tasks to serial link. The CPU in turn, handles the
interrupt it. This ensures proper operation of hardware. Software can be debugged either
the GSM/GPRS protocol but reduces the in an emulator or directly on the module
application performance. Telit has removed when it‘s connected to the serialport of a
substantial parts of the Python API to ease PC. All Python outputs and error messages
the requirements of the interpreter engine. can then be viewed in a Terminal window.
Minicom was used for this purpose.
Figure 3.3: Software Environment of the Telit GM862 GPS

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 24
Fleet Management System

HARDWARE DEVELOPMENT

The prototype is designed using the 'Telit

F
or the developement of hardware, the
GM862 GPS' as the basic module and
block diagram was first formulated and
additional hardware is incorporated to
then each block was designed and made
functional.The developement approach chosen
realise the functionalities desired.

was an agile methodology called 'Scrum' The 'Ignition Block' determines whether the
ignition of the vehicle is on/off and feeds the
corresponding signal to the GPIO pin of the
4.1 Block Diagram module.
The 'Tampering Block' is so designed to
alert the control room in case of any tamper,
incident to the module by sending a high
priority SMS to the control number specified
in the configuration file.
The 'Fuel Block' is used to calculate the
percentage of fuel in the vehicle.The output
voltage from the float sensor in the fuel tank
of the vehicle is dropped using suitable
resistance circuits and then fed to the ADC

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 25
Fleet Management System

of the module.The input data is then


processed within the module. 4.2.1 Flow Chart
The 'Call Control Logic' defines the manner
in which the 'Call Block' functions.The call Once the module is powered on ,the
block consists of a microphone and speaker initialisation procedure is carried out. A
used in conjunction so as to implement a continuous check is for incoming or
'primitive' mobile phone.The 'Call Control outgoing calls is done and if the condition is
Logic' is implemented for the following met the control is passed on to the call
reasons: control centre. Else a variable engaged is set
i. Misuse of Phone to false and the routine task of reading the
ii. Cost reduction GPIO pins and logging data to the web
iii. Avoid distractions server is performed.

The tasks involved are:


i. Disconnect unwanted calls without
user knowledge Start of
ii. Button association with control Device

centre numbers
Perform Initialisation
process
Once the block diagram was
designed, a control flow diagram was drawn
up to characterise the work flow and then
each block's working was specified using a
flow chart.
If Ring
4.2 Control Flow Diagram Enga fals =Tru
ged= e e
False
Y Y

Perform Initiate Call


Routine Tasks Handler

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 26
Fleet Management System

The initialisation procedure is as follows:

Initialisation : 1. The Baud Rate for communication is


set to 115200
2. The variable engaged is set to true so
Initialisation Start
as to avoid the passing of control to
the call control centre
Set SER Baud rate=115200
3. The GPIO pins are set as input pins

Set ENGAGED=True with a dummy value zero


4. The Format of calling is set to the
Set Port Directions international format of +91
5. The caller ID feature is turned on to
Set International Format
distinguish calls

Set CLID to True 6. The speaker and microphone


volumes are muted
Mute SPKR & RING 7. The internal clock of the module is
set to the UTC value extracted from
Set RTC time from GPS
the GPS string
Report Live Status 8. A string with remarks set as ―live‖ is
then sent to the web server
Set ENGAGED=False 9. The engaged variable is then to set to
false and the control is then
transferred to the routine loop
Initialisation Stop

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 27
Fleet Management System

information is stored in a dictionary


Routine Loop : variable
3 The current battery status of the
Enter Loop module is checked using AT
commands and the value updated in
the specific variable
Make Port status dictionary
4 The ADC input is read and converted
to a percentage value
Make GPS status dictionary
5 The server URL is then created using
these values and the GPRS function
Extract Velocity is called.
5.1 The GPRS function sets the
Log battery status module to the GPRS mode.
5.2 The socket timeout is set
Log Fuel:ADC conversion 5.3 Checksum is computed and
hexdigest is appended to server
URL
Generate Server URL
5.4 The socket is then dialled and
the serverlog.php page is called
passing arguments in GET.
5.5 The result is analysed and if
Return From Loop
not successful the data is
The routine loop of the program consists of warehoused. Any updates are
the following functions: also checked for.(The
1 The GPIO pins are scanned and the warehoused data is resent at a
read values are stored in a dictionary later stage and the entry deleted
variable if transfer is successful )
2 The GPS data is extracted and the 5.6 The socket is then closed.
Latitude,Longitude,Time,Velocity 6 The loop is exited only if a call has
to be handled

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 28
Fleet Management System

Call Control Flow : The incoming call is identified and if a


valid number, the speaker and microphone

Initiate Call Handler


volumes are maximised and the user allowed
to attend the call by the press of a switch.
The outgoing calls are limited to two
Identify CLID
control numbers,the calls are initiated at the
press of the respective switches.

CLID in list

Y
Set Volume high,Eng=true

Wait for Call Aceptance

Call Disc ?

Y
Set Volume low,Eng=False

Stop Call Handling

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 29
Fleet Management System

MicLevel = ( -45) + (-4.7) = -49.7


4.3 Sound System dBVrms
that means :

The Base Band Chip of the GM862-GPS MicVoltage = 10 ( -49.7 / 20 ) = 3.3* 10 -3

Telit Module provides two different audio Vrms

blocks; both in transmit (Uplink) and in During a call, this level varies according to

receive (Downlink) direction: the volume of the talker voice; usually the

―MT lines‖ should be used for handset following rough thumb rule for the dynamic

function, ―HF lines‖ is suited for hands -free range may be used :

function (car kit). 1) The talker is screaming . This is

These two blocks can be active only one at a the strongest voice level condition:

time, selectable by AXE hardware line or by the signal increases by +20dB

AT command. The audio characteristics are 2)The talker is whispering. This is

equivalent in transmit blocks, but are the lowest voice level condition: the

different in the receive ones. voice level decreases by – 50dB .

The nominal sensitivity of the microphone These changes were considered for

lines indicates the voltage level on the designing the external microphone

GM862-GPS pins present during "normal amplifier.

spoken" conditions. For a handset , the For hands-free/car kit microphone, the voice

"normal spoken‖ conditions take place when attenuation, due to the distance between the

the talker mouth is 7cm far from the microphone itself and the talker, when

microphone ; under these conditions the designing the external microphone amplifier

voice will produce an acoustic pressure of - must be taken into account. The microphone

4,7dBPa @1kHz on the microphone will also pick up ambient noise; to overcome

membrane . this problem it is preferable to set the gain of

At "normal spoken" conditions, a the microphone 10dB lower with respect to

microphone having the suggested nominal the calculated value for a nominal

sensitivity of -45dBVrms/Pa,will produce sensitivity. The corresponding reduction in

the electrical equivalent signal : signal level will be compensated by an


increased voice volume of the talker which

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 30
Fleet Management System

will speak louder because of the ambient below:Depending on the gain required the
noise. value of the resistance RG was varied. The
The handsfree mode was chosen while equation being the same as that of a simple
designing the Audio Section. A THAT audio differential amplifier.
amplifier circuit was used to provide the
requisite gain.

Audio Paths In The 'Telit GM862 GPS'

Figure 4.2 THAT Audio Amplifier

Figure 4.1 AudioPaths in Telit GM862 GPS


The THAT audio amplifier was wired up in
the configuration as shown

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 31
Fleet Management System

The output from the module was fed to an


amplifier and speaker circuitry in order to
hear the voice with clarity. The amplifier
circuit was wired up in the following
manner using a D6283 IC

Figure 4.3 Speaker Amplifier Circuit

4.4 Tamper System

The tamper system is so designed that if the


box is opened the input at a specific GPIO
pin becomes high and a SMS is sent to the
control number.The message settings are
configured and a high priority SMS is sent.

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 32
Fleet Management System

WEB RESOURCE DEVELOPMENT

5.1 Google Maps API The google maps API requires one to
initially register for an API key, before one
can start putting maps on a site. An

T
he Google Maps API was used to
embed Maps in the web pages extensive documentation is available with

with JavaScript. The API provides the google documentation site for google

a number of utilities for manipulating maps maps, which was used in the development

and adding content to the map through a process.

variety of services, allowing the creation of 5.2 MySQL


robust maps applications on the website. MySQL is the world's most popular open
The Maps API is a free service, available for source database software, with over 100
any web site that is free to consumers. The million copies of its software downloaded or
Google Maps API is now integrated with the distributed throughout its history. With its
Google AJAX API loader, which creates a superior speed, reliability, and ease of use,
common namespace for loading and using MySQL has become the preferred choice for
multiple Google AJAX APIs. This Web, Web 2.0, SaaS, ISV, Telecom
framework allows you to use the optional
google.maps.* namespace for all
The pages were hosted as a subdomain in
classes, methods and properties currently the official website of the college, as
used in the Google Maps API. http://maraudersmap.cemunnar.ac.in

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 33
Fleet Management System

companies and forward-thinking corporate programming was mostly done using the
IT Managers because it eliminates the major PHP language.
problems associated with downtime,
maintenance and administration for modern, 5.3 PHP
online applications.
PHP is a scripting language originally
designed for producing dynamic web pages.
Many of the world's largest and fastest-
It has evolved to include a command line
growing organizations use MySQL to save
interface capability and can be used in
time and money powering their high-volume
standalone graphical applications.
Web sites, critical business systems, and
While PHP was originally created by
packaged software — including industry
Rasmus Lerdorf in 1995, the main
leaders such as Yahoo!, Alcatel-Lucent,
implementation of PHP is now produced by
Google, Nokia, YouTube, Wikipedia, and
The PHP Group and serves as the de facto
Booking.com.
standard for PHP as there is no formal
The flagship MySQL offering is MySQL
specification. PHP is free software released
Enterprise, a comprehensive set of
under the PHP License, however it is
production-tested software, proactive
incompatible with the GNU General Public
monitoring tools, and premium support
License (GPL), due to restrictions on the
services available in an affordable annual
usage of the term PHP.
subscription.
PHP is a widely-used general-purpose
MySQL is a key part of LAMP (Linux,
scripting language that is especially suited
Apache, MySQL, PHP / Perl / Python), the
for web development and can be embedded
fast-growing open source enterprise
into HTML. It generally runs on a web
software stack. More and more companies
server, taking PHP code as its input and
are using LAMP as an alternative to
creating web pages as output. It can be
expensive proprietary software stacks
deployed on most web servers and on almost
because of its lower cost and freedom from
every operating system and platform free of
platform lock-in.
charge.PHP is installed on more than 20
The same software stack was used in the
million websites and 1 million web servers.
development of this project. The web

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 34
Fleet Management System

5.4 Software Requirement Specifications


5.4.1 Overall Description 5.4.4 Design and Implementation
The purpose of the software section of the constraints
project is to provide an interface to log the The design and implementation of the web
data into a database, to retrieve it in the resources is constrained by the design of the
format required for various applications, plot hardware unit and the availability of the
the data on a map and also to configure the specifications in the previous section and
vehicle mounted unit remotely. also the Google Maps.

5.4.2 User Classes and Characteristics 5.4.5 Assumptions and Dependencies


The access to the website is closely linked It is assumed that prior to the use of the web
with the hardware unit described in the module, the Google Maps API Key is
previous sections. The current prototype obtained from
includes the user class ‗Client‘ which will
refer to the owner of the fleet or any http://code.google.com/apis/maps
/signup.html
authorized representative of the owner, like
the fleet manager, with administrative
It is also required that the Hardware unit is
privileges.
up and running. The browser used by the
client must be capable of displaying google
5.4.3 Operating Environment
maps
The operating environment will include two
parts –the server side and the client side.
The server should have PHP, MySQL and
JavaScript to be installed and enabled. The
client side requirement would be a web
browser capable of displaying Google Maps.

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 35
Fleet Management System

5.4.4 Product Description The data received at the serverlog.php page


is processed by that page as follows
The Web-side of the project has the
following pages Initially, it concatenates all the data received
serverlog.php at the serverside and computes its MD5
index.html Hash. This is then compared with the check
top.html Sum sent by the unit. Any disparity signals

right.php the DBU:INTEGRITYERROR.

mapArea.html Then the latitude and longitude values are

mapplot.php converted into the geographical coordinates


required by the Google Maps to plot the
loginValidation.php
data. This is followed by the Data validation
setCuky.php
procedures and rejects null data.
home.html
moduleconfig.php
After that the Password Sent by the unit is
processModuleUpdate.php
compared with the data from the database. If
The Hardware Unit accesses the
there is any disparity a DBU:AUTHERROR
serverlog.php via GPRS and sends the
is signaled. Once the authenticity and
following data.
integrity of the data is ensured, it is logged
• Device Id
into the ‗mapping‘ table in the
• Password
‗cemunnar_marauders‘ database. On success
• Latitude
‗DBU:SUCCESS‘ is signaled and if it fails
• Longitude
‗DBU:ERROR‘ is signaled. Whenever there
• Time
is an update available for the unit, as
• Velocity
signaled by the corresponding Boolean true
• Fuel
value from the table
• Ignition
‗cemunnar_marauders‘.‗credentials‘, a
• Tamper
‗DBU:UPDATE‘ is signaled. So is the case
• Remark
with Alert:OVERSPEED and
• Check Sum
Alert:GEOFENCEVIOLATION.

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 36
Fleet Management System

5.4.5 Page Hierarchy

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 37
Fleet Management System

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 38
Fleet Management System

OPENERP INTEGRATION

Resource Planning) system makes the ideal

I
nformation Systems have played an
platform for this common reference point.
increasingly visible role over the past
several years in improving the
competitiveness of business. More than just 6.1 Open Source Software at the
tools for handling repetitive tasks, they‘re Service of Management
used to guide and advance all of a
company‘s‗ daily activities. Integrated Risks and integration costs are important
management software is today very often a barriers to all the advantages you gain from
key source of significant competitive such systems. That‘s why, today, few small-
advantage. and medium-sized companies use ERP. In
addition, the larger ERP vendors such as
The standard response to a need for SAP, Microsoft and Oracle haven‘t been
responsiveness, reliability, and rapidly able to reconcile the power and
increasing expectations is to create an comprehensive cover of an ERP system with
organization based on departments with a the simplicity and flexibility wanted by the
clear linear structure, integrated around your users. But this is exactly what small and
operating processes. To increase efficiency medium enterprises are looking for.
amongst salespeople, accountants, logistics
staff and everyone else you should have a The development processes of open
common understanding of your problems. source software, and the new business
models adopted by their developers, provide
For this you need a common language for a new way of resolving such problems of
shared references, policies and cost and quality for this kind of enterprise
communication. An ERP (Enterprise software.

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 39
Fleet Management System

To make an ERP system fully available to results exceed any reasonable expectations
small and medium enterprise, cost reduction when such work is well organized.
is the first priority. Open source software
makes it possible to greatly reduce But the real challenge of development is
development costs by aggressive reuse of to make this solution simple and flexible, as
open source software libraries; to eliminate well as complete. And to reach this level of
intermediaries (the distributors), with all of quality you need a leader and co-ordinator
their expensive sales overhead; to cut out who can organize all of these activities. So
selling costs by free publication of the the development team of Tiny ERP, today
software; and to considerably reduce the called Open ERP, is responsible for most of
marketing overhead. the organization, synchronization and
coherence of the software.
Since there is open interaction among And Open ERP offers great performance
thousands of contributors and partners in all these areas!
working on the same project, the quality of
the resulting software benefits greatly from 6.2 The OpenERP Solution
the scrutiny. And you can‘t be everything at
once: accountant, software developer, Because of its modularity, collaborative
salesperson, ISO 9001 quality professional, developments in Open ERP have been
specialist in agricultural products, expert in cleanly integrated, enabling any company to
the customs and habits of pharmaceutical choose from a large list of available
vendors, just as a start. functions. As with most open source
software, accessibility, flexibility, and
Faced with these wide-ranging simplicity are important keywords for
requirements, what could be better than a development. Experience has shown that
world network of partners and contributors? there‘s no need to train users for several
Everyone adds their own contribution months on the system, because they can just
according to their professional competence. download it and use it directly.
Throughout this book you‘ll see that the

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 40
Fleet Management System

So you‘ll find the modules for all types of companies. This diversity is an illustration
needs, allowing your company to build its of the software‘s flexibility: a rather elegant
customized system by simply grouping and coordination between people‘s functional
configuring the most suitable modules. expectations of the software and great
Hundreds of modules are available. simplicity in its use.

They range from specific modules like the And this diversity is also found in the
EDI interface for agricultural products, various sectors and trades which use the
which has been used to interface with Match software, including agricultural products,
and Leclerc stores, up to the generic textiles, public auctions, IT, and trade
demonstration automation module for associations.
ordering sandwiches, which can take care of
the eating preference of your staff. Lastly, such software has arisen from the
blend of high code quality, well-judged
The results are quite impressive. Open architecture and use of free technologies. In
ERP (once called Tiny ERP when it started fact, you may be surprised (if you‘re an IT
out) is management software that is person) to find that the size of Open ERP is
downloaded more than any other in the less than 4 MB when you‘ve installed the
world, with over 600 downloads per day. software. Implementation of IT has moved a
It‘s available today in 18 languages and has long way from the days when the only
a world network of partners and people who could be expected to benefit
contributors. More than 800 developers from ERP were the owners of a widget
participate in the projects on the factory on some remote industrial estate.
collaborative development system of Tiny
Forge. 6.3 Fleet Management Module

To our knowledge, Open ERP is the only Inspite of the popularity and expertise in
management system which is routinely used various verticals, Open ERP still lacks the
not only by big companies but also by very fleet management functionality. Hence this
small companies and independent

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 41
Fleet Management System

project incorporates a fleet_manager module Spares Management


for Open ERP. 1. Spares/Tyre serialised management
The features of the module are: 2. Stock management
Vehicle Management: 3. Warranty tracking
1. Vehicle Details
2. Vehicle Records & Documentation GPS Integration
3. Purchase, Insurance, Dues etc. 1. GPS based order management
4. Loan Payment Scheduler 2. GPS based tracking and predictive
5. Asset Management movement
6. Depreciation 3. GPS based tracking for customer

Fuel Master The module is version controlled at the


1. Fuelling Information Launchpad. Launchpad is a unique
2. Fuel/Vendor wise mileage collaboration and hosting platform for
3. Fuel Card Manager software projects. Most open source projects
including the popular Linux Distribution
Partner Management Ubuntu is hosted at the launchpad.
1. Customer Relationship Management Launchpad integrates the Bazaar version
2. Supplier Relationship Management control system and makes release
3. Automatic Invoicing on Shipping management, bug tracking and community
4. Order Management with GPS building easier than ever. The bazaar branch
integration for the project is
Branch
Fleet Maintainance lp:~sharoonthomas/openobject
1. Preventive Maintainance -addons/fleetmanagement

2. Scheduled Maintainance
3. Work Order management The bazaar version control system is an

4. Repair Cost tracker easy to use open source tool.

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 42
Fleet Management System

Conclusion

The project was successfully completed and the


prototype was implemented using Telit GM862 GPS. The
web interface was implemented and hosted in the college
subdomain 'maraudersmap.cemunnar.ac.in'. The Fleet
Management System is a feasible concept which we
believe would be answer to most of the problems
discussed in the initial study of this project.

The lack of integration in Indian fleet industry can be


completely addressed by this solution. Future
enhancements for the project include
1. Accelerometer based accident detector
2. Geofencing
3. Route mapping & predictive path algorithm.

Thus the project achieved its goals not to be terminated at


this stage, but to be developed as a future gadget
automating auto-mobiles and the Indian fleet industry

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 43
Fleet Management System

References

[1.] The World Bank., Transport in South Asia


Permanent URL:http://go.worldbank.org/FUE8JM6E40
[2.] Nils Hellström., Fleet Management Services in
GSM-modules, Master thesis in Electronics Dept. of
Electrical Engineering at Linköpings Universitet
[3.] Magnus Ewert, 2001, GPRS 1:st ed.,
Studentlitteratur Lund
[4.] Miller Philip, 1997, TCP/IP Explained,
Butterworth-Heinmann, Newton MA
[5.] Hofmann-Wellenhof Bernard et al., 2001, Global
positioning system : theory and practice. 5:th ed.,
Springer Wien
[6.] Markku Mikael Hautamäki, USING GPRS AS A
WIRELESS CORE NETWORK FOR WIRELESS
LOCAL AREA NETWORKS
[7.] 'Open ERP Book' By Fabien Pinckaers

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Major Project ‘09 44
Fleet Management System

Index

Global Positioning System, 3, 9, 10,


A 11, 12, 13, 14, 15, 17, 18, 19, 20, O
23, 24, 26, 38
AT command, 26 Google Maps API, 29 OpenERP, 4, 35
AUTHERROR, 32 Google Maps API Key, 31 OVERSPEED, 32
GPRS, 5, 6, 7, 8, 17, 20, 24, 32
B GSM, 1, 5, 6, 7, 8, 11, 12, 14, 16, 17, P
18, 20
battery, 24 PHP, 30, 31

H processModuleUpdate.php, 32
C Project Marauders Map, 1
home.html, 32 Python, 1, 15, 18, 19, 20, 30
Call Control Logic, 22
Check Sum, 32
I R
Checksum, 12, 24
Control Flow, 22, 25 Ignition Block, 21 Remote Update, 18
index.html, 32 right.php, 32
D INTEGRITYERROR, 32 RS232, 13, 19
IP address, 8
Domain Name System, 8
S
L
E serverlog.php, 24, 32
Latitude, 12, 24, 32 setCuky.php, 32
ERROR, 32 loginValidation.php, 32 SUCCESS, 32
Longitude, 12, 24, 32
F T
Fleet Management System, 1, 2, 3
M Tampering Block, 21
Fuel Block, 21 mapArea.html, 32 Telit GM862 GPS, 1, 13, 14, 18, 20,
mapplot.php, 32 21, 27
G moduleconfig.php, 32 Time Division Multiple Access, 6
MySQL, 29, 30, 31 top.html, 32
General Purpose Input Output, 15,
21, 22, 23, 24, 28
GEOFENCEVIOLATION, 32
N U
NMEA, 11, 12 UPDATE, 32

Dept. of Computer Science & Engineering


College of Engineering, Munnar
Telit GM862 GPS
Datasheet
Appendix A

This is the Datasheet of the Telit GM862 GPS as available from www.telit.com
Source Code -1
Appendix B

This appendix contains the source code of the web part of the project. The page hierarchy and
organization is detailed in the chapter 5 of this report. The source code of the homepage is exempted.
serverlog.php

<!--DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Server Log</title>
</head>

<body>
<?php
$devId= $_GET['devId'];
$pass= $_GET['pass'];
$lat= $_GET['lat'];
$lon= $_GET['lon'];
$tim= $_GET['tim'];
$vel= $_GET['vel'];
$fuel= $_GET['fuel'];
$ign= $_GET['ign'];
$tamper= $_GET['tamper'];
$remark= $_GET['remark'];
$csum= $_GET['csum'];

$validate=$devId.$lat.$lon.$tim.$vel.$fuel.$ign.$tamper.$remark;

if(strcmp(md5($validate),$csum)!=0)
{
echo $validate." ".md5($validate)." ".$csum."\n";
die("DBU:INTEGRITYERROR");
}

if(strstr($lat,"N"))
{
$lat=str_replace("N","",$lat);
}
if(strstr($lon,"E"))
{
$lon=str_replace("E","",$lon);
}
if(strstr($lat,"S"))
{
$lat=str_replace("S","",$lat);
$lat=-1*$lat;
}
if(strstr($lon,"W"))
{
$lon=str_replace("W","",$lon);
$lon=-1*$lon;
}

if($lat=='' and $lon=='' and $vel=='') die("DBU:SUCCESS");

$lat=$lat/100;
$lon=$lon/100;

mysql_connect("cemunnar.ac.in","cemunnar_madmin","iamuptonogood") or
die ('I cannot connect to database because : '. mysql_error());
mysql_select_db("cemunnar_marauders");
$query2="select passw from credentials where devId='".$devId."' limit
1;";
$ps=mysql_query($query2) or die(mysql_error());
$pswd=mysql_fetch_row($ps);
echo mysql_affected_rows()." ";

if(strcmp($pswd[0],$pass)!=0)
{
die("DBU:AUTHERR");
}

$query="insert into mapping values('NULL', '".$devId."', '".$pass."',


'".$lat."', '".$lon."', '".$tim."', '".$vel."', '".$fuel."', '".$ign."',
'".$tamper."', '".$remark."', NULL);";

mysql_query($query) or die("DBU:ERROR ".mysql_error());


echo "Database Updated : ".$devId." ".$pass." ".$lat." ".$lon." ";
echo "DBU:SUCCESS";

$query2="select * from deviceAlert where devId='".$devId."' limit 1;";


$da=mysql_query($query2) or die(mysql_error());
$devAlert=mysql_fetch_row($da);

$upd=$devAlert["upd"];
$oAlert=$devAlert["oalert"];
$gfAlert=$devAlert["gfalert"];

if($upd==1)
echo "DBU:UPDATE";
if($oAlert==1)
echo "Alert:OVERSPEED";
if($gfAlert==1)
echo "Alert:GEOFENCEVIOLATION";

?>
</body>
</html>

End of serverlog.php
cnxn.php

<?
$username="cemunnar_madmin";
$password="iamuptonogood";
$database="cemunnar_marauders";
?>

End of cnxn.php

loginValidation.php

<html>
<head>
<title>Login Verification</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
$clientId=$_REQUEST["loginClientId"];
$loginPswd=$_REQUEST["loginPswd"];
$pswdHash=md5($loginPswd);

// Opens a connection to a MySQL server


$connection=mysql_connect("cemunnar.ac.in","cemunnar_madmin","iamuptono
good");
if (!$connection) {
die('Not connected : ' . mysql_error());
}

// Set the active MySQL database


$db_selected = mysql_select_db("cemunnar_marauders", $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}

$query = "SELECT passw FROM credentials WHERE


clientid='".$clientId."'";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
$row = mysql_fetch_array($result, MYSQL_ASSOC);
if(strcmp($row["passw"],$loginPswd)!=0)
{
//echo "<script type=\"text/javascript\"> alert(\"Authentication
Failure\"); history.go(-1);<\script>";
echo "<script> history.go(-1)</script>";die();
}
else
{
echo "Success";

//header("Location:http://maraudersmap.cemunnar.ac.in/setCuky.php?c=".$
clientid);*/
echo "<script
type=\"text/javascript\">location.replace(\"http://maraudersmap.cemunnar.ac.i
n/setCuky.php?c=".$clientId."\");</script>";
}

?>
</body>
</html>

End of loginValidation.php

mapArea.html

<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD


XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Project Marauders Map</title>
<script
src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA7eNAFmGdfrH
A6udKO8tiehRabvw7QOXmJw-C3n4r9VIzvHtdHRRo_xk3KixgoswICIZKx6c0Wg9mHw"
type="text/javascript"></script>

<script type="text/javascript">
//<![CDATA[

var iconBlue = new GIcon();


iconBlue.image =
'http://labs.google.com/ridefinder/images/mm_20_blue.png';
iconBlue.shadow =
'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
iconBlue.iconSize = new GSize(12, 20);
iconBlue.shadowSize = new GSize(22, 20);
iconBlue.iconAnchor = new GPoint(6, 20);
iconBlue.infoWindowAnchor = new GPoint(5, 1);

var iconRed = new GIcon();


iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png';
iconRed.shadow =
'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
iconRed.iconSize = new GSize(12, 20);
iconRed.shadowSize = new GSize(22, 20);
iconRed.iconAnchor = new GPoint(6, 20);
iconRed.infoWindowAnchor = new GPoint(5, 1);

var customIcons = [];


customIcons["restaurant"] = iconBlue;
customIcons["bar"] = iconRed;

function load(devId) {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
var bounds = new GLatLngBounds();
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(10.074671,77.13501), 10);

GDownloadUrl("mapplot.php?deviceId="+devId, function(data) {
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var devId = markers[i].getAttribute("devId");
var point = new
GLatLng(parseFloat(markers[i].getAttribute("lat")),

parseFloat(markers[i].getAttribute("lng")));
var marker = createMarker(point, devId);
bounds.extend(point);
map.setZoom(map.getBoundsZoomLevel(bounds));
map.addOverlay(marker);
map.setCenter(bounds.getCenter());
}
});
}
}

function createMarker(point, devId) {


var marker = new GMarker(point, iconRed);
var html = "<b>" + devId + "</b> <br/>";
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
//]]>
</script>
<style type="text/css">
<!--
body {
margin-top: 20px;
}
-->
</style></head>

<body leftmargin="0" marginwidth="0" onload="load()" onunload="GUnload()">


<div id="map" style="width: 750px; height: 350px">
<div align="center"></div>
</div>
</body>
</html>

End of mapArea.html
mapplot.php

<?php
require("cnxn.php");
$deviceId=@$_REQUEST['deviceId'];
function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','&lt;',$htmlStr);
$xmlStr=str_replace('>','&gt;',$xmlStr);
$xmlStr=str_replace('"','&quot;',$xmlStr);
$xmlStr=str_replace("'",'&#39;',$xmlStr);
$xmlStr=str_replace("&",'&amp;',$xmlStr);
return $xmlStr;
}

// Opens a connection to a MySQL server


$connection=mysql_connect("cemunnar.ac.in","cemunnar_madmin","iamuptonogood")
;
if (!$connection) {
die('Not connected : ' . mysql_error());
}

// Set the active MySQL database


$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}

// Select all the rows in the markers table


$query = "SELECT * FROM mapping WHERE devId='".$deviceId."'";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
header("Content-type: text/xml");
// Start XML file, echo parent node
echo '<markers>';

// Iterate through the rows, printing XML nodes for each


while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
echo '<marker ';
echo 'devId="' . parseToXML($row['devId']) . '" ';
echo 'lat="' . $row['lat'] . '" ';
echo 'lng="' . $row['lon'] . '" ';
echo '/>';
}

// End XML file


echo '</markers>';
?>

End of mapplot.php
moduleconfig.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


<html>
<head>
<title>Module Configuration Utility</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
$clientid=$_COOKIE["clientid"];
require("cnxn.php");
// Opens a connection to a MySQL server
$connection=mysql_connect("cemunnar.ac.in","cemunnar_madmin",$password);
if (!$connection) {
die('Not connected : ' . mysql_error());
}

// Set the active MySQL database


$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}

// Select all the rows in the markers table


$query = "SELECT devId from credentials WHERE clientid='".$clientid."'";
$query2 = "SELECT provide from serviceProvider";
$resultDevId = mysql_query($query);
if (!$resultDevId) {
die('Invalid query: ' . mysql_error());
}
?>
<form name="customerConfig" action="processModuleUpdate.php">
<table width="48%" border="1">
<tr>
<td width="34%">Unit ID</td>
<td width="66%"><select name="cmbUnitId" id="cmbUnitId">
<?php if(mysql_num_rows($resultDevId)) {
// we have at least one user, so show all users as options in select
form
while($rowDevId = mysql_fetch_row($resultDevId))
{
if(strcmp($rowDevId[0],$dev)!=0)
print("<option
value=\"$rowDevId[0]\">$rowDevId[0]</option>");
else
print("<option value=\"$rowDevId[0]\"
selected>$rowDevId[0]</option>");
}
} else {
print("<option value=\"\">No Devices Assigned</option>");
}?>
</select></td>
</tr>
<tr>
<td>Control No 1</td>
<td><input name="cn1" type="text" id="cn1"></td>
</tr>
<tr>
<td>Control No 2</td>
<td><input name="cn2" type="text" id="cn2"></td>
</tr>
<tr>
<td>Valid Nos +91</td>
<td><p>
<input name="validNos" type="text" id="validNos"><br>
(separate each number by commas)</p>

</td>
</tr>
<tr>
<td>Service Provider</td>
<td><select name="cmbService" id="cmbService">
<?php
$resultService=mysql_query($query2);
if(mysql_num_rows($resultDevId)) {
while($rowService = mysql_fetch_row($resultService))
{
print("<option
value=\"$rowService[0]\">$rowService[0]</option>");
}
}
else {
print("<option value=\"\">No Service
Provider</option>");
}
?>
</select></td>
</tr>
<tr>
<td><input type="reset" name="Submit2" value="Reset"></td>
<td>
<input type="submit" name="Submit" value="Update Module"></td>
</tr>
</table>

</form>
</body>
</html>

End of moduleconfig.php
processModuleUpdate.php

<?php

$cmbUnitId=$_REQUEST["cmbUnitId"];
$cn1=$_REQUEST["cn1"];
$cn2=$_REQUEST["cn2"];
$validNos=$_REQUEST["validNos"];
$cmbService=$_REQUEST["cmbService"];
$clientid=$_COOKIE["clientid"];

require("cnxn.php");

// Opens a connection to a MySQL server


$connection=mysql_connect("cemunnar.ac.in","cemunnar_madmin",$password);
if (!$connection) {
die('Not connected : ' . mysql_error());
}

// Set the active MySQL database


$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}

$query = "SELECT apn,usname,pasw from serviceProvider where


provide='".$cmbService."'";
$result= mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}

$row = mysql_fetch_array($result, MYSQL_ASSOC);


$apn=$row["apn"];
$un=$row["usname"];
$passw=$row["pasw"];

$replace=array('[',']',',');
$replaceby=array('[\'','\']','\',\'');
$validNos="[".$validNos."]";
$validNos = str_replace($replace, $replaceby, $validNos);

$myFile = "updates/config".$cmbUnitId.".py";
$fh = fopen($myFile, 'w') or die("Can't open file");
$stringData = "import SER\n#This is the config file\ndef main():\n
SER.send(\"\\r\\nConfig file import success\\r\\n\")\n return\n#This is
the config
file\nunitid=\"".$cmbUnitId."\"\ncontrolno1=\"".$cn1."\"\ncontrolno2=\"".$cn2
."\"\nvalidnos=".$validNos."\nrepeatunit=15\ntimeoffset=\"+22\"\napn='".$apn.
"'\npassw='".$passw."'\nui='".$un."'\ndi='sl12'\npas='sl12'\nmain()\n
# I am forced to put some dumb code here also. Please bear with me all those
who read this code.\n";
fwrite($fh, $stringData);
//echo $stringData;
fclose($fh);
$query2="UPDATE deviceAlert SET upd=1 where devid='".$cmbUnitId."'";
$da=mysql_query($query2) or die(mysql_error());
echo "<script
type=\"text/javascript\">location.replace(\"http://maraudersmap.cemunnar.ac.i
n/right.php\");</script>";
?>

End of processModuleUpdate.php

right.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 20px;
margin-right: 5px;
margin-bottom: 0px;
}
-->
</style></head>
<body>
<form name="recompute" action="right.php">
<?php

if(isset($selectDevice))
{
$dev=$_REQUEST["selectDevice"];
echo "<script>parent.mainFrame.load('".$dev."')</script>";
}
if(isset($config))
{
echo "<script
type=\"text/javascript\">location.replace(\"http://maraudersmap.cemunnar.ac.i
n/moduleconfig.php\");</script>";
}
$connection=mysql_connect("cemunnar.ac.in","cemunnar_madmin","iamuptono
good");
if (!$connection) {
die('Not connected : ' . mysql_error());
}
// Set the active MySQL database
$db_selected = mysql_select_db('cemunnar_marauders', $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
?>
<table width="26%" border="1" cellpadding="2">
<tr>
<td width="14%">Unit ID</td>
<td width="86%">
<?php $query2 = "SELECT DISTINCT devId FROM credentials where
clientid='".$_COOKIE["clientid"]."'";
$resultDevId = mysql_query($query2);
// echo "<select name=\"selectDevice\" onChange=\"this.form.submit()\">";
echo "<select name=\"selectDevice\">";
if(mysql_num_rows($resultDevId)) {
// we have at least one user, so show all users as options in select
form
while($rowDevId = mysql_fetch_row($resultDevId))
{
if(strcmp($rowDevId[0],$dev)!=0)
print("<option
value=\"$rowDevId[0]\">$rowDevId[0]</option>");
else
print("<option value=\"$rowDevId[0]\"
selected>$rowDevId[0]</option>");
}
} else {
print("<option value=\"\">No Devices Assigned</option>");
}
echo "</select>";
$query = "SELECT * FROM mapping WHERE devId='".$selectDevice."' order
by rid desc LIMIT 1";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$lat=$row['lat'];
$lon=$row['lon'];
$dtime=$row['time'];
$velocity=$row['vel'];
$fuel=$row['fuel'];
$ign=$row['ign'];
$tamper=$row['tamper'];
$tstamp=$row['tstamp'];
?> </td>
</tr>
<tr>
<td>Latitude</td>
<td><?php echo $lat ?>&nbsp;</td>
</tr>
<tr>
<td>Longitude</td>
<td><?php echo $lon ?>&nbsp;</td>
</tr>
<tr>
<td>Time</td>
<!-- <td><input type="submit" onClick="history.go(0)"
VALUE="Refresh"></td>-->
<td><?php echo $dtime ?>&nbsp;</td>
</tr>
<tr>
<td>Velocity</td>
<td><?php echo $velocity ?>&nbsp;</td>
</tr>
<tr>
<td>Fuel</td>
<td><?php echo $fuel ?>&nbsp;</td>
</tr>
<tr>
<td>Ignition</td>
<td><?php if($ign==0) echo "Off"; else echo "On"; ?>&nbsp;</td>
</tr>
<tr>
<td>Tamper</td>
<td><?php if($tamper==0) echo "No Threat"; else echo "Tamper
Attempt!";?>&nbsp;</td>
</tr>
<tr>
<td>TimeStamp</td>
<td><?php echo $tstamp?>&nbsp;</td>
</tr>
<tr>
<td><input type="submit" name="geofence" value="GeoFence"></td>
<td><input name="submit" type="submit" value="Refresh"></td>
</tr>
<tr>
<td><input type="submit" name="config" value="Configure"></td>
<td><input type="submit" name="logout" value="Log out"></td>
</tr>
</table>
</form>
<?php mysql_free_result($result);
unset($selectDevice);
?>
<p>
</p>
</body>
</html>

End of right.php

setCuky.php

<?php
$clientid=$_REQUEST["c"];
setcookie("clientid",$clientid,time()+3600,"/","maraudersmap.cemunnar.a
c.in");
echo "<script
type=\"text/javascript\">location.replace(\"http://maraudersmap.cemunnar.ac.i
n/home.html\");</script>";
?>

End of setCuky.php
Source Code -2
Appendix C

This appendix contains the source code of the hardware part of the project. The source code is written
in Python. The configXXX.py is the configuration file obtained from the /updates folder of web server
and XXX is the unitid
mod14.py

import SER
import MOD
import MDM
import GPIO
import config
import md5
############### Modules / Functions ####################
def debugmsg(msgtext):
msgtext = msgtext.replace('\r','\\r')
msgtext = msgtext.replace('\n','\\n')
SER.send(msgtext + '\r\n')

def setports():
GPIO.setIOdir(8,0,0) #Call Button 1
GPIO.setIOdir(9,0,0) #Call Button 2
GPIO.setIOdir(10,0,0) #Tamper Alert
GPIO.setIOdir(13,0,0) #Ignition
GPIO.setIOdir(7,0,0) #Answer call

def doread(timout):
res = str(MDM.receive(timout))
debugmsg('Read MDM as:'+res)
if ((res.find("RING")==-1)or(res.find("CLIP")==-1)):
debugmsg('There is no ring in it!')
return res
else:
debugmsg('There is a ring! Bypassing existing loop')
s=res.find('+CLIP:')
inno=res[s+8:s+8+13]
debugmsg('Incoming no recognised as:'+inno)
callhandler(inno)
return res
return res

def callhandler(inno):
debugmsg('About to handle calls')
if inno in (config.validnos):
engaged=1
MDM.send('AT+CRSL=4\r',0)
MDM.send('AT+CLVL=14\r',0)
ringcount=0
while(1):
debugmsg('Waiting for call to be answered')
MDM.send('AT#GPIO=7,2\r',0)
res=MDM.receive(10)
if (res.find('#GPIO: 0,1')!=-1):
MDM.send('ATA\r',0)
debugmsg('Call Answered')
while(1):
res=MDM.receive(10)
if ((res.find('\r\nNO CARRIER')!=-1)):
debugmsg('Call Disconnected')
engaged=0
break
elif (res.find("RING")==-1):
ringcount=ringcount+1
debugmsg("Absence of ring count:" + str(ringcount))
if (ringcount==40):
stat['remark']='Call not answered' + inno
engaged=0
break
else:
debugmsg('Number not valid')
MDM.send('ATH\r',0)
MDM.receive(10)
stat['remark']='Inv IP Call:' + inno
debugmsg('Call Disconnected')

def makecall(tonum):
debugmsg('Setting Class for Voice')
MDM.send('AT+FCLASS=8\r',0)
debugmsg('Calling No:' + tonum)
MDM.send('ATD'+tonum+'\r',0)
engaged=1
res = doread(50)
debugmsg(res)
while ((res.find('\r\nNO CARRIER')==-1)and(res.find('\r\nBUSY')==-1)):
res = MDM.receive(50)
debugmsg(res)
if ((res.find('\r\nNO CARRIER')!=-1)or(res.find('\r\nBUSY')!=-1)):
debugmsg('Call Disconnected')
break
debugmsg('setting engaged as false')
engaged=0

def sendsms(message,tonum):
debugmsg("Sending message to" + tonum)
MDM.send('AT+CMGS=' + tonum + '\r',0)
res = doread(50)
debugmsg("Wait for SMS prompt")
if (res.find('\r\n> ')!=-1):
debugmsg("Prompt Received")
MDM.send(message,0)
MDM.sendbyte(0x1A,0)
res = doread(100)
if (res.find('\r\nOK\r\n')!=-1):
debugmsg("Hopefully the message is sent")
else:
debugmsg("Prompt was not received. Please increase the delay")

def scanports():
MDM.send('AT#GPIO=8,2\r',0)
res = doread(50)
if (res.find('#GPIO: 0,1')==-1):
stat['call1']=0
else:
stat['call1']=1
makecall(config.controlno1)
MDM.send('AT#GPIO=9,2\r',0)
res = doread(50)
if (res.find('#GPIO: 0,1')==-1):
stat['call2']=0
else:
stat['call2']=1
makecall(config.controlno2)
MDM.send('AT#GPIO=10,2\r',0)
res = doread(50)
if (res.find('#GPIO: 0,1')==-1):
stat['tamp']=0
else:
stat['tamp']=1
stat['tc']=stat['tc']+1
if (stat['tc']==2):
debugmsg('sending tamper alert by SMS')
sendsms('Unit no:' + config.unitid + '\r\n Tamper Alert.
\r\nPlease respond.\r\n --\r\nSystem Generated
Warning:\r\n',config.controlno1)
if (stat['tc']==config.repeatunit):
stat['tc']=1
MDM.send('AT#GPIO=13,2\r',0)
res = doread(50)
if (res.find('#GPIO: 0,1')==-1):
stat['ignt']=0
else:
stat['ignt']=1
debugmsg('Call1:'+str(stat['call1']))
debugmsg('Call2:'+str(stat['call2']))
debugmsg('ignition:'+str(stat['ignt']))
debugmsg('tamper:'+str(stat['tamp']))

def batstat():
MDM.send('AT#CBC\r',0)
bat=doread(5)
debugmsg("Battery Status is:" + bat)
#sitedat['bat']=bat

def gpsextract():
debugmsg("Getting the GPS data")
doread(10)
MDM.send('AT$GPSACP\r',0)
res=doread(10)
a=res.find('$GPSACP: ')
if (a!=-1):
b=res[a:len(res)-1]
gps_str=b.split(',')
lat=gps_str[1]
debugmsg("Latitude is:" + lat)
sitedat['lat']=lat
lon=gps_str[2]
debugmsg("Longitude is:" + lon)
sitedat['lon']=lon
vel=gps_str[7]
debugmsg("Velocity is:" + vel)
sitedat['vel']=vel
else:
debugmsg("Unable to get GPS data")

def settime():
debugmsg("Getting the GPS data")
doread(10)
MDM.send('AT$GPSACP\r',0)
res=doread(10)
a=res.find('$GPSACP: ')
if (a!=-1):
b=res[a:len(res)-1]
gps_str=b.split(',')
dat=gps_str[9]
datf=dat[4:6] + '/' + dat[2:4] + '/' + dat[0:2]
debugmsg("Date in yy/mm/dd is:" + datf)
utc=gps_str[0][9:15]
debugmsg("UTC is:" + utc)
ist=utc[0:2] + ':' + utc[2:4] + ':' + utc[4:6] + config.timeoffset
debugmsg("IST is:" + ist)
sitedat['ist']=ist
res=doread(10)
debugmsg('command exec: AT+CCLK="' + datf +',' + ist + '"\r')
MDM.send('AT+CCLK="' + datf +',' + ist + '"\r',0)
res=doread(50)
debugmsg("Setting configured:" + res)
else:
debugmsg("Time not set")

def fuelmonit():
debugmsg('Monitoring fuel...')
MDM.send('AT#ADC=1,2\r',0)
res=doread(10)
f=res.find('#ADC: ')
if (f!=-1):
adc=res[f+6:f+15]
f=adc.find('\r\n')
adc=adc[0:f]
debugmsg('ADC Value is:' + adc)
fuel = int(adc)
debugmsg('Fuel Value is:' + str(fuel))
fuel=fuel/20
debugmsg('Fuel Value is:' + str(fuel))
sitedat['fuel']=fuel
else:
debugmsg("Error Reading ADC:" + res)

def timef():
MDM.send('AT+CCLK?\r',0)
res=doread(10)
debugmsg('The RTC is:' + res)
a=res.find('+CCLK: ')
debugmsg('The value of a is:' + str(a))
if (a!=-1):
sitedat['ist']=res[a+16:a+24]
debugmsg('The IST is:' + sitedat['ist'])
else:
debugmsg('Time was never recorded')
def gprsset():
debugmsg("Setting GPRS")
MDM.send('AT+CGDCONT=1,"IP","' + config.apn + '"\r',0)
res=doread(50)
debugmsg("GPRS setting status:" + res)
debugmsg("Setting userid:")
MDM.send('AT#USERID="' + config.ui + '"\r',0)
res=doread(1)
debugmsg(res)
debugmsg("Setting password:")
MDM.send('AT#PASSW="' + config.passw + '"\r',0)
res=doread(1)
MDM.send('AT#SKTTO=120\r',0)
debugmsg(res)
res=doread(1)
debugmsg('SKTTO:' + res)
MDM.send('AT#SKTSAV\r',0)
res=doread(1)
debugmsg('SKTSAV status is:' + res)
debugmsg('Activating GPRS context')
MDM.send('AT#GPRS=1\r',0)
res=doread(50)
debugmsg(res)

def gprs(sitestring):
try:
debugmsg('sitestring Recd with length:' + str(len(sitestring)))
debugmsg('add login info in string')
sitelog='devId='+config.unitid+'&pass='+config.pas
debugmsg('add remaining info to ' + sitelog)
sitestring[7]=sitestring[7].replace('\r','')
sitestring[7]=sitestring[7].replace('\n','')
csum =
md5.new(config.unitid+sitestring[0]+sitestring[1]+sitestring[2]+sitestring[3]
+sitestring[4]+sitestring[5]+sitestring[6]+sitestring[7])
sitelog = sitelog + '&lat=' + sitestring[0] + '&lon='+sitestring[1] +
'&tim=' + sitestring[2] + '&vel=' + sitestring[3] + '&fuel=' + sitestring[4]
+ '&ign='+sitestring[5] + '&tamper=' + sitestring[6] + '&remark=' +
sitestring[7] + '&csum=' + csum.hexdigest()
debugmsg("Sending GPRS string")
debugmsg("Csum.digest is:" + str(csum.digest()))
callmsg = 'GET ' + config.logpage + '?' + sitelog + '
HTTP/1.1\r\nHost: www.' + config.server + '\r\nConnection: close\r\n\r\n\r'
MDM.send('AT#GPRS\r',0)
res=doread(50)
debugmsg("GPRS status:" + res)
if (res.find('#GPRS: 1')==-1):
debugmsg('There is no connection')
gprsset()
else:
MDM.send('AT#SKTD=0,80,"www.' + config.server + '"\r',0)
res = doread(50)
timer1=0
while (res.find('\r\nCONNECT\r\n')==-1):
res2=doread(10)
if (res2.find('\r\nCONNECT\r\n')!=-1):
break
timer1=timer1 + 1
if (timer1==2):
debugmsg('I had enough of checking')
return 0
#you have to reboot here
if(res.find('\r\nNO CARRIER\r\n')==-1):
debugmsg('I am gonna call:' + callmsg)
MDM.send(callmsg,0)
debugmsg('The page returned:')
timer1=0
res='Message:'
while(1):
res=res+doread(100)
if(res.find('\r\nNO CARRIER\r\n')!=-1):
debugmsg("Data Sent")
MDM.send('+++\r',0)
if (analyse(res)==0):
debugmsg('Analysis returned zero')
return 0
else:
return 1
timer1=timer1+1
if (timer1==5):
debugmsg('I had enough of checking')
return 0
else:
debugmsg("The connection died premature")
return 0
return 0
except:
return 0

def analyse(result):
debugmsg('Analyser received control')
#This module will analyse the result and take necessary steps
if (len(result)>0):
debugmsg('Beginning analysis of info:' + result)
if (result.find('DBU:AUTHERR')!=-1):
debugmsg('Authentication Error in DB')
return 0
elif (result.find('DBU:ERR')!=-1):
debugmsg('Error updating database')
return 0
elif ((result.find('DBU:SUCCESS')!=-
1)and(result.find('DBU:UPDATE')==-1)):
debugmsg('updating database SUCCESS')
return 1
elif (result.find('DBU:INTEGRITYERROR')!=-1):
debugmsg('Data Accessed By Unauthorised User!!')
return 0
elif ((result.find('DBU:SUCCESS')!=-
1)and(result.find('DBU:UPDATE')!=-1)):
debugmsg('Database updated,Updating config file !!')
getconf()
return 1
else:
debugmsg('Unknown Message:' + result)
return 0
return 0

def warehouse(sitestr):
#This module will push a data to text file and increment pending
debugmsg('Current Pending status:' + str(stat['pending']))
try:
f1 = open('warehouse.txt','a')
debugmsg('File opened with append')
except:
f1 = open('warehouse.txt','w')
debugmsg('File opened with fresh write')
f1.write(sitestr[0] + ',' + sitestr[1] + ',' + sitestr[2] + ',' +
sitestr[3] + ',' + sitestr[4] + ','+sitestr[5] + ',' + sitestr[6] + ',' +
sitestr[7] + '\r\n')
debugmsg('Write Operation Success')
f1.close
stat['pending']=stat['pending'] + 1
debugmsg('Pending status inc to:' + str(stat['pending']))

def reware():
#This module will try sending the data again to server from warehouse
debugmsg('Attempting resend of warehouse')
f2=open('warehouse.txt','r')
line = f2.readlines()
debugmsg('Length of lines is:' + str(len(line)))
debugmsg('Example Line 1 is' + line[0])
f2.close()
for log in line:
slog = log.split(',')
if (gprs(slog)==1):
line.remove(log)
else:
f3 = open('warehouse.txt','w')
for rwlog in line:
wlog=rwlog.split(',')
f3.write(wlog[0] + ',' + wlog[1] + ',' + wlog[2] + ',' +
wlog[3] + ',' + wlog[4] + ','+wlog[5] + ',' + wlog[6] + ',' + wlog[7])
stat['pending']=len(line)
f3.close()
break

def createconf(newconf):
debugmsg('create conf has control')
MDM.send('AT#LSCRIPT\r',10)
res = doread(10)
if ((res.find('config.pyo')!=-1)and(res.find('config.py ')==-1)):
debugmsg('Creating config.py')
f4 = open('config.py','w')
debugmsg('Opened config.py')
f4.write(newconf)
f4.write('\r\n#This is a system update')
debugmsg('Closing config.py')
f4.close()
debugmsg('Deleting config.pyo')
MDM.send('AT#DSCRIPT="config.pyo"\r',0)
res=doread(50)
debugmsg('Reboot now')
MDM.send('AT#REBOOT\r',0)
else:
debugmsg('The system seems messed up.Check config setting')

def getconf():
debugmsg('Beginning FTP transaction...')
MDM.send('AT#FTPOPEN="' + config.server + '","' + config.ftpuser + '","'
+ config.ftppass + '"\r',0)
res=doread(50)
if (res.find('\r\nOK\r\n')!=-1):
debugmsg('Setting working directory...')
MDM.send('AT#FTPCWD="' + config.updir + '"\r',0)
res=doread(50)
if (res.find('\r\nOK\r\n')!=-1):
debugmsg('Begin download of file...')
MDM.send('AT#FTPGET="config' + config.unitid + '.py"\r',0)
res=doread(100)
if ((res.find('CONNECT')!=-1)and(res.find('NO CARRIER')!=-1)):
strt = res.find('CONNECT\r\n')
stop = res.find('\r\nNO CARRIER')
debugmsg('The Update Message is:' + res[start+11:stop])
createconf(res[start+11:stop])
stat['remark'] = stat['remark']+'Config Updated'
else:
debugmsg("Received file is incomplete or corrupt")
else:
debugmsg("Could not set working directory")
else:
debugmsg("Could not open FTP Socket")

#The code starts here


stat = {
'call1':0,
'call2':0,
'tamp':0,
'ignt':0,
'tc':0,
'pending':0,
'remark':'nothing'
}
sitedat={
'lat':'none',
'lon':'none',
'ist':'none',
'vel':'none',
'fuel':'none',
#'bat':'none'
}
SER.set_speed('115200','8N1')
SER.send('\r\n---------------------\r\n\r\n')
debugmsg('Module Initialisation has started')
MDM.send('AT+CMEE=2\r',0)
MDM.receive(50)
MOD.sleep(1)
debugmsg('Setting engaged = True')
engaged = 1
setports()
MDM.send('AT+CLIP=1\r',0)
MDM.send('AT+CRSL=0\r',0)
MDM.send('AT+CLVL=0\r',0)
MDM.send('AT+CMGF=1\r',0)
debugmsg('Scan for warehouse')
try:
f = open('warehouse.txt','r')
line = f.readlines()
debugmsg('Length of lines is:' + str(len(line)))
debugmsg('Example Line 1 is' + line[0])
f.close()
stat['pending'] = len(line)
except:
debugmsg('Error in reading file')
f = open('warehouse.txt','w')
f.write('')
f.close()
stat['pending'] = 0
try:
MDM.send('AT#LSCRIPT\r',10)
res = doread(10)
if ((res.find('config.pyo')!=-1)and(res.find('config.py ')!=-1)):
debugmsg('Raw Config file present')
MDM.send('AT#DSCRIPT="config.py"\r',10)
debugmsg('Delete Raw Config File')
res = doread(10)
elif ((res.find('config.pyo')!=-1)and(res.find('config.py ')==-1)):
debugmsg('Raw Config file not present')
elif ((res.find('config.pyo')==-1)and(res.find('config.py ')!=-1)):
debugmsg('Only raw config file present,Compile Now')
MDM.send('AT#REBOOT\r',0)
else:
debugmsg('Its very unfortunate you dont give me a config file')
except:
debugmsg('Some exception occured in processing config files')
debugmsg('Setting Time')
settime()
gprsset()
debugmsg('Done with gprsset')
config.main()
debugmsg('Reporting Live Status')
debugmsg('Setting Engaged as true')
engaged=0
debugmsg('Module Initialisation has ended')
while(engaged==0):
debugmsg('Start Scan of ports')
scanports()
batstat()
debugmsg('Done with batstat')
gpsextract()
debugmsg('Done with gpsextract')
fuelmonit()
debugmsg('Done with fuelmonit')
timef()
debugmsg('Done with timef')
loginfo =
[sitedat['lat'],sitedat['lon'],sitedat['ist'],sitedat['vel'],str(sitedat['fue
l']),str(stat['ignt']),str(stat['tamp']),stat['remark']]
debugmsg('Loginfo was success: Ex Tim is' + loginfo[2])
scanports()
if (gprs(loginfo)==0):
debugmsg('Warehouse Data now')
scanports()
warehouse(loginfo)
else:
scanports()
if stat['pending']>0:
reware()
#hi i am putting this dumb lines of code just here to mislead the system
about the data size. I hope it gets fooled with these sets of lines.
Hopefully its working now

End of mod14.py

configXXX.py

import SER
#This is the config file
def main():
SER.send("\r\nConfig file import success\r\n")
return
#This is the config file
unitid="U01"
controlno1="+919447190498"
controlno2="+919447190498"
validnos=['+919447190498','+919946469741']
repeatunit=15
timeoffset="+22"
apn='grrssouth.cellone.in'
passw='ppp123'
ui='ppp'
di='sl12'
pas='sl12'
main()

# I am forced to put some dumb code here also. Please bear with me all those
who read this code.

End of configXXX.py
Screenshots
Appendix D

This appendix contains the screenshots of various modules of this project.


Screenshot 1 : index.html – Home page

Screenshot 2 : home.html

mapArea.html right.php

top.html
Screenshot 3 : home.html with moduleConfig.php

Screenshot 4 : mapplot.php [?deviceId=U01]


Screenshot 5 : OpenERP : fleet_manager

You might also like