Upload
openidhh18ycsq
View
7.178
Download
4
Embed Size (px)
Citation preview
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
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
Mr. Biju V G HoD, Dept. of Electronics and
Communication Engineering
Mr. Shine N Das HoD, Dept. of Computer Science
and Engineering
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
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 Fleet Management System
1
Dept. of Computer Science & Engineering
College of Engineering, Munnar
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
Major Project ‘09 Fleet Management System
2
Dept. of Computer Science & Engineering
College of Engineering, Munnar
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)
Major Project ‘09 Fleet Management System
3
Dept. of Computer Science & Engineering
College of Engineering, Munnar
Major Project ‘09 Fleet Management System
4
Dept. of Computer Science & Engineering
College of Engineering, Munnar
ABSTRACT
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.
T
Major Project ‘09 Fleet Management System
5
Dept. of Computer Science & Engineering
College of Engineering, Munnar
INTRODUCTION
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.
T
1
Major Project ‘09 Fleet Management System
6
Dept. of Computer Science & Engineering
College of Engineering, Munnar
1.1 Background
In the current scenario, most small scale
fleet operators use manual methods of
fleet management and have no tracking
system at all. The medium and larger
enterprises on the contrary have some
levels of management integrated into
their operations. Most firms have now
deployed GPS based tracking units in
their mobile assets for better monitoring.
Such devices are widely available from
many vendors across the country, and
offer a web interface on their websites
for tracking. However these devices also
add to the inherent Indian problem of
'Lack of Integration' with existing
infrastructure.
Softwares in use by the medium players
of the industry are mostly limited to
spreadsheets or custom solutions
developed by regional software
developers. Lack of support, security
and synchronisation issues are few
drawbacks of such solutions. The giants
however have resorted to the use of
proprietary ERP solutions to increase
quality & efficiency. These solutions
with sky rocketing prices and longer
deployment times, in turn have an
overall impact of reducing efficiency
and increasing the cost of operation.
Hence these solutions are limited to a
few players who could afford the
investment and subsequent training of its
employees. These solutions also lack
integration with the existing tracking
hardware.
With the increased competition in the
industry, companies are now looking for
ways to improve their efficiency. FMS is
an umbrella term for applications that
aim at improving the overall
performance of a hauler‘s fleet in terms
of fuel economy, maintenance costs,
utilisation level, etc. FMS‘ main
advantages are better transport
coordination, better vehicle and driver
follow up, faster and more precise
invoicing, and faster assistance in case
of a road side breakdown2.
Considering the above facts, this project
introduces the use of latest hardware
systems and open source tools to build a
low cost Fleet Management System for
the South Asian market addressing the
problems discussed.
Major Project ‘09 Fleet Management System
7
Dept. of Computer Science & Engineering
College of Engineering, Munnar
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
development and hence the investigating
part consists of hardware platform reviews
and evaluation. Therefore much of the
resources have been data sheets and product
specifications.
Specifications of hardware components used
have been acquired from web pages of
respective manufacturers.
Notes have also been taken from blogs and
forums of active hobbyists involved in
development of M2M platforms.
The technologies used in the project are all
in wide use. They are themselves
extensively documented and a detailed study
of them is beyond the scope of this report
Major Project ‘09 Fleet Management System
8
Dept. of Computer Science & Engineering
College of Engineering, Munnar
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]
When data needs to be sent from a moving
target, or from remote locations, wireless
communication is desirable. There are a
number of techniques available with
different focuses regarding range and
bandwidth. The application of this project
has low demands on bandwidth, but requires
country wide coverage. For this type of
applications GSM/GPRS is the most suitable
candidate today.
2.1.1 GSM
The Global System for Mobile
telecommunications, GSM, standard was
developed in the eighties to address the
problem of compatibility between numerous
telecommunication systems that had
emerged. A first version of the standard was
completed in 1990. Since then, the system
has been adopted around the world, and new
versions of the standard have been released,
allowing higher data rates and new features
in the networks.
The basic GSM network is circuit switched,
just like an ordinary land line telephone
network. When a call is established between
two nodes, the link in-between is busy,
regardless of anything is being
2
Major Project ‘09 Fleet Management System
9
Dept. of Computer Science & Engineering
College of Engineering, Munnar
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,
TDMA to further increase the number of
parallel lines. TDMA means that a channel
is chopped up into a set of repeating time
slots. Each (cell phone) connection has its
own repeating time slot in a channel. (see
figure 2.1) The cell phone samples some
speech,
compresses it and sends it in its next slot.
For this to work, the time to transmit one
second of compressed speech has to be
much shorter than one second.
The GSM network is divided into cells, with
each cell having its own Base Station
System, BSS. The BSS contains a radio
transceiver and a controller. The controller
handles the radio channels and forwards
calls in the cell to a switching centre in the
network. The switching centre in turn routes
the call onwards to the target BSS or to
another network. The GSM network also
contains a set of data bases which contains
information about attached cell phones, their
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
Major Project ‘09 Fleet Management System
10
Dept. of Computer Science & Engineering
College of Engineering, Munnar
internet need no special hardware to
communicate with a GPRS device.
Data to be sent is first divided into small
pieces, packets. The individual packets are
then sent as soon as there is a time slot
available in the network. Finally, transmitted
data is reconstructed from the packets at its
destination. See figure 2.3. No user ‗owns‘ a
repeating time slot, as in the basic GSM
network. This allows a more efficient use of
thebandwidth. When user A doesn‘t need
any time slots, user B can have them and
vice verse. Both users can still be constantly
attached to the base station, much like an
internet broadband connection, ready to send
or receive. Network operators often employ
a tariff scheme where users pay for the data
actually sent, not the time period he is
connected. The pay-per-byte nature of
GPRS makes it ideal to use with remote
devices that need to be constantly connected
to other devices, or to a central server, but
only exchanging small amounts of data
spread over long periods of time.
Figure 2.3: Time slot usage of a GPRS channel
A GPRS device can only send at one
frequency at a time (use one channel), but it
can use more than one slot in each time slot
cycle of that channel to increase its
bandwidth. GPRS devices are divided into
classes according to the number of time slots
they can make use of. Performances range
from utilising one slot in each direction in
class one, to four slots in one direction and
one in the other (4+1 or 1+4), in class 12.
See table 2.1.
The theoretical data rate, when using one
slot, is 13,400 bits per second, giving 53,600
bps for class 12. These 53,6 kbps is the ―raw
data‖ rate; up to 25 percent thereof is used
for error correction and redundancy, leaving
about 40 kbps for user data.
Table 2.1: Examples of GPRS classes.
‘Active slots’ gives the maximum number of
simultaneously utilized
slots. For example class 11 supports up to
four slots for the uplink and up to three slots
for the downlink,
but it can only use a total of five slots
simultaneously.
GPRS Class Uplink Slots Downlink
Slots
Active Slots
2 2 1 3
4 3 1 4
6 3 2 4
8 4 1 5
11 4 3 5
12 4 4 5
Major Project ‘09 Fleet Management System
11
Dept. of Computer Science & Engineering
College of Engineering, Munnar
A GSM network needs new software and
hardware to handle GPRS. For example, the
base station controller needs software to
manage new coding schemes. GPRS data is
sent from the BSS to GPRS support nodes in
the network. They have roughly the same
functionality as the switching centre in
GSM. The routing to and from other IP
based networks (internet) is done through
gateways. See figure 2.4.
Figure 2.4: Rough structure of GPRS network
Assignment of an IP address to a unit is
done dynamically by the network operator,
i.e. A unit‘s IP address will change over
time. This means that there is no way for a
server that wants to contact a unit to know
its IP address for sure. Lately specialised
operators utilize a Domain Name System,
DNS, to give a unit a static public IP
address. The operator then routes incoming
requests to the public IP address through the
DNS server to the unit‘s current dynamic IP
address.
2.2 Internet Protocol
[Paragraph 2.2 is based on ref 4]
The Internet Protocol Suit, IPS, has been
used since the beginning of the eighties for
communication between remote computer
systems. With the introduction of GPRS in
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
destination. An application sending data
usually needs not to worry about all this.
The required functionality is provided at a
lower level by the IPS. IPS has a layered
architecture. The bottom layer handles the
physical link; sending and receiving of raw
bits. The top layer provides an interface that
applications can use. Each layer in between
handles its own part of the transmission. A
layer only serves the layer immediately
above and only makes requests to the layer
Major Project ‘09 Fleet Management System
12
Dept. of Computer Science & Engineering
College of Engineering, Munnar
immediately below. With well defined
interfaces between the layers, this makes for
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
of either TCP or UDP. TCP provides a
controlled channel to the target. It makes
sure that everything that is sent is delivered
to the recipient, and that it is delivered in the
right order and without errors. To handle
this, TCP contains sequence numbers and
timers to control sent data and retransmit
when data get lost. UDP lacks all this. There
are no guarantees that data sent by UDP
arrives correct at the destination, or that it
arrives at all. The control mechanisms of
TCP create a lot of overhead to the ‗useful‘
data. In some applications, the security of
TCP can be traded for the lower bandwidth
demanded by UDP. The choice here is TCP.
Some data integrity and flow control checks
are usually implemented in higher level
protocols when using UDP.
Figure 2.5: IP-Stack Layers
2.3 Global Positioning System
[Paragraph 2.3 is based on ref 5]
The Global Positioning System, GPS, was
developed by the United States Department
of Defence during the seventies and eighties
and became operational in 1993. The system
works in two parallel modes; one with
higher precision that is encrypted and
reserved for US military, and one with less
precision that is free to use by the public. An
ordinary civilian GPS has an accuracy of
about 15 meters. The core of the GPS
infrastructure consists of 24 satellites in
orbit (plus three used for backup) and a set
of satellite tracking stations around the
Major Project ‘09 Fleet Management System
13
Dept. of Computer Science & Engineering
College of Engineering, Munnar
world. The satellites send positioning data
and system information to users on earth.
Each satellite transmits at two frequencies,
one for civil and one for military use.
2.3.1 Triangulation
GPS positioning is based on triangulation. A
GPS receiver on earth first measures its
distance, R1, to one of the GPS satellites,
S1. The receiver has then pinned its position
down to a sphere with radius R1 around S1.
By repeating this procedure for two more
satellites the receiver has three spheres that
intercepts in two points. One of these two
points can be discarded as being to far from
the earth; the other interception point is the
receiver‘s location. There is a fourth
variable added to the three ‗room‘ dittos:
relative time of the clocks in the satellites
and receivers. Therefore a fourth satellite is
required to solve the equation. The reason
for is described in more detail in the next
paragraph.
2.3.2 Technical issues
For the positioning to have a meaning, the
receiver must know where the satellites are
relative to the earth. The receiver also has to
have some accurate way to measure
distance. The first problem is not so hard.
Orbits of the satellites are stabile and can be
predicted with high accuracy by
mathematical formulas. In addition to this,
tracking stations around the world monitor
the satellites positions and update them
when they are off course. The satellites in
turn, send correction data to the GPS
receivers. The receivers store the positions
of the satellites and can then calculate
satellite positions for the coming time
intervals, until the satellites send the next
position update.
To measure distance, a given predefined
pseudo random code is transmitted by the
satellite starting at a given time. At the same
time, the receiver starts to generate the same
code. By correlation, the receiver then
measurers the time offset between its own
code and that received from the satellite.
The signal from the satellite is an
electromagnetic wave with finite speed, c.
Multiplying the time offset, ∆t, of the two
codes with c gives the distance between
satellite and receiver. Additional techniques,
including measuring the phase of the signal
carrier, can be used to enhance precision.
The critical part of the distance
measurement is timing, which must be
Major Project ‘09 Fleet Management System
14
Dept. of Computer Science & Engineering
College of Engineering, Munnar
extraordinarily precise. If the two clocks of a
satellite and a receiver are off by just 1
microsecond, the error in distance
measurement will be 300 m. The satellites
use highly accurate atomic clocks that keep
the system ‗GPS-time‘. To equip a receiver
with an atomic clock would make it very
expensive. Instead, the receiver hosts an
ordinary quartz clock which is continuously
set by the atomic clocks of the satellites. As
mentioned above, three dimensional
positioning requires three ‗visible‘ satellites,
if all parts keep the same time.
In practice, there is a fourth variable; the
offset between the receiver clock and GPS-
time. To solve the equation, a total of four
visible satellites are required. Four variables
and four equations, one for each satellite,
gives a definite solution. The requirement of
four visible satellites is fulfilled 95 % of the
time in all places around the world. The
probability is better in populated areas
where usually six to eight satellites can be
spotted. Each satellite is called a channel.
―Number of channels‖ is a marketing feature
for GPS- receivers. A 6-channel receiver can
monitor six satellites simultaneously,
making more precise positioning possible.
2.3.3 Error sources
The main limitation of GPS accuracy used
to be the Selective Availability, SA. This
was a random bias applied to the civilian
satellite signal by the US Department of
Defence to limit non-military accuracy. The
SA was turned off in the year 2000,
enhancing GPS accuracy by a factor of 10.
The main limiting factors of GPS accuracy
today are path errors. The satellite signal
bounces on atmosphere and items in the
receiver‘s vicinity, making the path travelled
longer then the straight line assumed. A
more severe limitation is that the satellite
signal can be completely blocked by
buildings in ―city canyons‖ or in tunnels.
The GPS signal, coming form a satellite in
orbit, is very weak compared to, for
example, a GSM signal, making it very
sensitive to blocking. This error can be
partly worked around with ―dead reckoning‖
by use of accelerometers.
2.3.4 NMEA Protocol
[Paragraph 2.3.4 is based on ref 6]
The de facto standard communication
protocol to get positioning data from a GPS
receiver is developed and controlled by the
US National Marine Electronics
Major Project ‘09 Fleet Management System
15
Dept. of Computer Science & Engineering
College of Engineering, Munnar
Association, NMEA. The standard is aimed
at marine electronics, and GPS
communications is a subset of it. The most
common version, NMEA 0183, is quite
simple and allows one talker (in this case the
GPS receiver) to send ASCII character
‗sentences‘ to one or more passive listeners,
for example a navigation device. Apart from
the physical matters the standard defines a
set of sentences to declare, for example;
position, current time, system status, etc.
These are transmitted in a loop by the talker.
The sentences can be decoded by a
compatible listener, (computer, PDA) which
can then process the data further. Below is
an example of the NMEA sentence GLL,
Geographic Position – Latitude/Longitude.
1 2 3 4 5 6 7 8
| | | | | | | |
$--
GLL,llll.ll,a,yyyyy.yy,a,hhmmss.ss,a,m,*hh
Field Number:
1) Latitude
2) N or S (North or South)
3) Longitude
4) E or W (East or West)
5) Universal Time Coordinated (UTC)
6) Status A - Data Valid, V - Data Invalid
7) FAA mode indicator (NMEA 2.3 and
later)
8) Checksum
2.3.5 Competing positioning
systems
A global navigation system similar to GPS
was developed in Russia in parallel with the
US development. The Russian system is
called GLONASS, Global'naya
Navigatsionnaya Sputnikovaya Sistema. It
was fully operational for a while in the mid
nineties, but declined along with Russian
economy. The system is again gaining
momentum, with planned world coverage by
2010.
The European Union is developing their
own navigation system, Galileo, with
partners including China and Israel. Galileo
is planned to be operational in 2008. Both of
these systems provide roughly the same
accuracy as GPS, but it will be some time
after their launch dates before the market for
receivers is as developed as that for GPS.
Because of this, these systems will not be
real competitors to GPS for a long time.
A different approach to positioning which is
under development, is through GSM-
networks. It is based on a number of
techniques involving radio frequency signal
Major Project ‘09 Fleet Management System
16
Dept. of Computer Science & Engineering
College of Engineering, Munnar
strength from different GSM base stations.
Coverage of the system is limited to GSM-
network coverage, and accuracy today is
about 200 m in urban areas, decreasing to 4
km in rural zones, compared to about 15
meters for an ordinary GPS.
The conclusion is that as of today and
coming years, there are no real competitors
to GPS.
2.4 Input/Output
The following paragraphs gives a
description of different input and output, IO,
standards supported by the module Telit
GM862 GPS.
2.4.1 RS232
[Paragraph 2.4.1 is based on ref 7]
The EIA232 standard, generally called RS-
232, defines electrical and mechanical
properties of a serial data link. The standard
does not define character encoding or bit
rates; these can be chosen by the application.
Feasible bit rates do not exceed 256 kBit/s
due to the large voltage swing requirements
of the signal. The first version of the
standard was released in 1969, and an RS-
232 port was standard equipment on PCs
until the nineties. USB8 has now replaced
RS-232 in the PC area because of its higher
bit rate and ability to supply current to the
peripheral unit. An advantage of RS-232 is
that it requires less software support than
USB, making it a good option for devices
with limited resources, where it is still in
wide use. One case could for example be to
connect a GPS
to a PDA. As mentioned above, a set back
of the standard is that it defines a large
voltage swing. -15 ÷ -3 V for logic one and
3 ÷ 15 V for logic zero. This large swing
limits the maximum bit rate due to limited
slew of the signal generator. Also, an
ordinary TTL9 or CMOS10 circuit can not
produce these levels, so external level
converters are required to such a circuit. The
standard defines 20 signals, but more
common is a four signal plus ground subset.
It allows a full duplex link with flow
control. A two signal plus ground full
duplex link without flow control is also
common. The remaining signals are defined
for, for example, common clock and
secondary data lines.
For historical reasons, the signals of the
standard are labelled by a Data Terminal
Equipment, DTE, sending data to a Data
Communicator Equipment, DCE. The DTE
is referring to a computer and the DCE is
Major Project ‘09 Fleet Management System
17
Dept. of Computer Science & Engineering
College of Engineering, Munnar
referring to a modem, which was the set up
that the standard was originally intended for.
The 4 +1 signal sub set is:
TD Transmitted Data from DTE to DCE
RD Received Data from DCE to DTE
RTS Request To Send.
CTS Clear To Send.
In half duplex mode, RTS and CTS make a
full handshake. In full duplex mode, DCE
transmits whenever RTS is high and DTE
transmits whenever CTS is high. GND
Common Ground (this might not be true if
the signalling cable is long). The two plus
one signal implementation consists of TD,
RD and GND.
2.4.2 Buses
Telit GM862 GPS supports Inter Integrated
Circuit, I2C, and Serial Peripheral Interface,
SPI, buses. These buses are mainly intended
for on-PCB, Printed Circuit Board, use.
They could come into practice in a design
with a dedicated PCB to connect e.g. a GPS
receiver to the GSM-module and will
therefore be describe briefly.
I2C is a multi-master bus invented by
Philips. It features a simple flow
controlmechanism. Signalling is done over
two bidirectional wires for clock and data,
and can in the latest revision transfer data in
rates up to 3.4 Mbit/s, with 100 and 400
Kbit/s being more common. The standard
uses 10 bit addressing, enabling up to 1000
unique nodes to be pointed out on the bus, as
long as the total bus capacitances don‘t
exceed 400 pF. Since capacitance of a wire
is proportional to its width and length, 1000
nodes might not be possible in practice. The
capacitance restriction also shows that the
bus is not optimal for off PCB
communication, since cables tend to have
relatively large capacitance.
SPI is another simple serial bus intended for
use on PCB. It is a single master bus with
chip select instead of addressing. This
makes it suitable for longer data streams
from one or a few slaves, rather then reading
and writing many addressed nodes. SPI
allows higher data rates than I2C, 10 Mbit/s
and more. SPI does not specify any
acknowledgement or flow control, so
higher-level protocols have to be
implemented by the user.
2.4.3 General input/output pins
Telit GM862 GPS has a range of pins that
can be used as either digital inputs or
Major Project ‘09 Fleet Management System
18
Dept. of Computer Science & Engineering
College of Engineering, Munnar
outputs. The direction of the pins can be
configured in application software. Hence
they are called General Purpose Input
Output, GPIO. Digital pins could for
example be used to connect an alarm button
to the module, or some indication Light
Emitting Diodes, LED‘s. An output pin, in
general, does not supply much current, so
additional driving is needed to drive the
external item, e.g. LED.Telit GM862 GPS
has one input pin, an output pin and 11
GPIO pins.
2.5 Python Programming
The first version of Python was released in
the early nineties. It is now developed by
The Python Software Foundation as an Open
Source project. Although used for some
popular programs like the original
BitTorrent tracker, Python is not as widely
adopted as the other languages in this
review. Python is an interpreted language,
meaning that it is compiled at runtime.
Unlike most mainstream languages, it is
dynamically typed with no predefinition of
variables. Therefore, values, not variables
carry type. This enables shorter code, but is
also a great error source. The feature takes
some time to get used to if one is used to for
example Java programming. Python is
designed with the intention of being highly
readable. To attain this it has a simple visual
layout, English keywords instead of
punctuation, and fewer syntactic constructs
than for example C.
White space is used as delimiter instead of
brackets. Python is the only major language
with this approach. This enforces the
indentation convention used in many other
languages with the motivation of making the
language more readable. This can be seen in
Appendix B,‗Source Code‘. Space and tab
indentations are interpreted differently at
runtime. If they are mixed they will generate
errors.Since space and tab are visually
similar, these errors can be hard to detect
when debugging.The Python language is
multi-paradigm, permitting several
programming styles; object-,functional- or
structural-orientated. Exception handling is
supported.
Major Project ‘09 Fleet Management System
19
Dept. of Computer Science & Engineering
College of Engineering, Munnar
HARDWARE PLATFORM
3.1 GSM Module
SM-modems have been around
for some 10 years. A GSM-
modem is simply speaking a
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-
phone networks and onwards to the internet
During the past three-four years, an
enhanced type of GSM-modem has
emerged. They will be called GSM-modules
in this project. The difference to an ordinary
modem is that the module allows the
running of third party application code
within the unit, eliminating the need of an
external controller. The GSM-modules also
host internal IP-stacks, making Internet
access very easy. As of today there are
modules available from half a
dozen producers. An example of what a
GSM-module looks like is shown in figure
3.1.
3.1.1 General applications
GSM modules allow highly integrated
embedded systems with Internet
connectivity, where component count can be
kept to a minimum. They target products
that need connectivity with each other or a
central server from remote locations. The
main property to keep in mind when
designing a system where the intelligence is
G
Figure 3.1: Telit GM 862 GPS
3
Major Project ‘09 Fleet Management System
20
Dept. of Computer Science & Engineering
College of Engineering, Munnar
embedded into a GSM-module is the limited CPU power and memory. Since the
modules have limited resources, their tasks
should be kept simple and non-time-critical.
Possible applications include collecting and
sending positioning information from a
vehicle,
reporting stock of a vending machine,
weather data from a weather station, etc. In
addition to the stand-alone mode, all
modules evaluated in this report can also be
controlled by an external CPU, like a
traditional GSM-terminal. The two different
architectures are shown in figure 3.2.
Figure 3.2: Comparison of architectures
3.1.2 Hardware
A GSM module contains a baseband CPU
that maintains the GSM/GPRS protocols.
The CPU communicates with a high
frequency radio transceiver that modulates
the signal from the baseband CPU and
transmits it into the ether. In difference to a
GSM-terminal, the module also provides
means to execute third party application
code. The application could either be run on
spare capacity in the module‘s baseband
CPU, or in a dedicated application CPU.
The target applications of GSM-modules
often include positioning. To meet this
demand, GSM-modules with internal GPS
have been released. The GPS receiver chip
is fitted into the module and connected to
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
Board, PCB, is then needed to use the
module. The PCB should contain proper IO
connectors, peripheral circuitry such as RS-
232 level converters, and power supply. A
GSM device has some particular powering
demands. Though its average power
consumption is rather low, the unit can need
up to two ampere when transmitting in its
Major Project ‘09 Fleet Management System
21
Dept. of Computer Science & Engineering
College of Engineering, Munnar
time slot. This should be accounted for in
the power supply design.
Developing a PCB takes time. To speed up
prototyping, and to allow parallel hardware
and software development, all GSM-module
producers provide test boards for their
models. These boards offer complete
support for a module, so that the application
programmer can start to work at once.
However the EVK2 board combatible with
the Telit GM862 GPS being as expensive as
the module itself was ruled out.
3.2 Remote Update
Remote update is a way to update
application code from a remote location by
downloading new code and replacing the old
one. In the case of GSM-modules, this is
also called Over The Air, OTA update, since
the new code is downloaded wirelessly.
Most modules of the review of this report
support remote update of application code.
An update could be required to change the
use of the module, or to correct a bug in the
application code. To update a large fleet of
trucks spread over a vast geographical area
by ‗cable‘ is very costly. Remote update
could be risky though, if the device
accidentally ends up in some deadlock state
and can‘t be accessed. Mechanism for the
remote update in the FMS is using the FTP
feature of Telit GM862 GPS. Appendix B
has the detailed code for the purpose.
3.3 Telit GM862 GPS
Telit is based in Trieste, Italy, with Arrow
and Round Solutions as Swedish sales
agents. Telit has developed cellular based
products since the mid eighties. Their
product ranges today include both GSM
handsets and modules. Their most suitable
module for this project is the GM862-GPS.
It has an embedded Python script interpreter
for embedded applications and a GPS
receiver.
3.3.1 Overview
The application code of the Telit modules is
run as a single thread in the baseband CPU.
This is a cost efficient solution, but
decreases performance since the baseband
CPU‘s main priority is to keep the GSM
protocol. For example IO operations of an
application, that need not to interfere with
the radio unit at all, now has to compete
with it for resources.
Major Project ‘09 Fleet Management System
22
Dept. of Computer Science & Engineering
College of Engineering, Munnar
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
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
levels.
3.3.3 Antenna Requirements
3.3.4 Software
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
Major Project ‘09 Fleet Management System
23
Dept. of Computer Science & Engineering
College of Engineering, Munnar
interpreter engine takes less resources than a
Java engine. The script and the interpreter
have 1.5 MB of RAM available. Script and
data files can be written and read on a single
level file system with a total size of 3 MB.
Figure 3.3 shows the software environment
of the module. The Python script is run as a
thread in the baseband CPU. It has the
lowest priority, allowing all other tasks to
interrupt it. This ensures proper operation of
the GSM/GPRS protocol but reduces the
application performance. Telit has removed
substantial parts of the Python API to ease
the requirements of the interpreter engine.
Some specific features have also been added
for control of the hardware in the module:
GPS, serial port, timers and IP connectivity.
The module can only keep a single IP socket
open at a time. Most of the Telit added API
is based on AT-commands which are sent to
the GSM baseband CPU through a virtual
serial link. The CPU in turn, handles the
hardware. Software can be debugged either
in an emulator or directly on the module
when it‘s connected to the serialport of a
PC. All Python outputs and error messages
can then be viewed in a Terminal window.
Minicom was used for this purpose.
Figure 3.3: Software Environment of the Telit GM862 GPS
Major Project ‘09 Fleet Management System
24
Dept. of Computer Science & Engineering
College of Engineering, Munnar
HARDWARE DEVELOPMENT
or the developement of hardware, the
block diagram was first formulated and
then each block was designed and made
functional.The developement approach chosen
was an agile methodology called 'Scrum'
4.1 Block Diagram
The prototype is designed using the 'Telit
GM862 GPS' as the basic module and
additional hardware is incorporated to
realise the functionalities desired.
The 'Ignition Block' determines whether the
ignition of the vehicle is on/off and feeds the
corresponding signal to the GPIO pin of the
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
F
4
Major Project ‘09 Fleet Management System
25
Dept. of Computer Science & Engineering
College of Engineering, Munnar
of the module.The input data is then
processed within the module.
The 'Call Control Logic' defines the manner
in which the 'Call Block' functions.The call
block consists of a microphone and speaker
used in conjunction so as to implement a
'primitive' mobile phone.The 'Call Control
Logic' is implemented for the following
reasons:
i. Misuse of Phone
ii. Cost reduction
iii. Avoid distractions
The tasks involved are:
i. Disconnect unwanted calls without
user knowledge
ii. Button association with control
centre numbers
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.
4.2 Control Flow Diagram
4.2.1 Flow Chart
Once the module is powered on ,the
initialisation procedure is carried out. A
continuous check is for incoming or
outgoing calls is done and if the condition is
met the control is passed on to the call
control centre. Else a variable engaged is set
to false and the routine task of reading the
GPIO pins and logging data to the web
server is performed.
Start of Device
Perform Routine Tasks
If Engaged=False
Initiate Call Handler
Ring=Tru
e
Perform Initialisation process
false
Y Y
Major Project ‘09 Fleet Management System
26
Dept. of Computer Science & Engineering
College of Engineering, Munnar
Initialisation :
The initialisation procedure is as follows:
1. The Baud Rate for communication is
set to 115200
2. The variable engaged is set to true so
as to avoid the passing of control to
the call control centre
3. The GPIO pins are set as input pins
with a dummy value zero
4. The Format of calling is set to the
international format of +91
5. The caller ID feature is turned on to
distinguish calls
6. The speaker and microphone
volumes are muted
7. The internal clock of the module is
set to the UTC value extracted from
the GPS string
8. A string with remarks set as ―live‖ is
then sent to the web server
9. The engaged variable is then to set to
false and the control is then
transferred to the routine loop
Initialisation Start
Set SER Baud rate=115200
Set ENGAGED=True
Set Port Directions
Set International Format
Set CLID to True
Mute SPKR & RING
Set RTC time from GPS
Report Live Status
Set ENGAGED=False
Initialisation Stop
Major Project ‘09 Fleet Management System
27
Dept. of Computer Science & Engineering
College of Engineering, Munnar
Routine Loop :
The routine loop of the program consists of
the following functions:
1 The GPIO pins are scanned and the
read values are stored in a dictionary
variable
2 The GPS data is extracted and the
Latitude,Longitude,Time,Velocity
information is stored in a dictionary
variable
3 The current battery status of the
module is checked using AT
commands and the value updated in
the specific variable
4 The ADC input is read and converted
to a percentage value
5 The server URL is then created using
these values and the GPRS function
is called.
5.1 The GPRS function sets the
module to the GPRS mode.
5.2 The socket timeout is set
5.3 Checksum is computed and
hexdigest is appended to 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
not successful the data is
warehoused. Any updates are
also checked for.(The
warehoused data is resent at a
later stage and the entry deleted
if transfer is successful )
5.6 The socket is then closed.
6 The loop is exited only if a call has
to be handled
Enter Loop
Make Port status dictionary
Make GPS status dictionary
Extract Velocity
Log Fuel:ADC conversion
Return From Loop
Generate Server URL
Log battery status
Major Project ‘09 Fleet Management System
28
Dept. of Computer Science & Engineering
College of Engineering, Munnar
Call Control Flow :
The incoming call is identified and if a
valid number, the speaker and microphone
volumes are maximised and the user allowed
to attend the call by the press of a switch.
The outgoing calls are limited to two
control numbers,the calls are initiated at the
press of the respective switches.
Initiate Call Handler
Identify CLID
Set Volume high,Eng=true
Set Volume low,Eng=False
Stop Call Handling
CLID in list
Y
Wait for Call Aceptance
Call Disc ?
Y
Major Project ‘09 Fleet Management System
29
Dept. of Computer Science & Engineering
College of Engineering, Munnar
4.3 Sound System
The Base Band Chip of the GM862-GPS
Telit Module provides two different audio
blocks; both in transmit (Uplink) and in
receive (Downlink) direction:
―MT lines‖ should be used for handset
function, ―HF lines‖ is suited for hands -free
function (car kit).
These two blocks can be active only one at a
time, selectable by AXE hardware line or by
AT command. The audio characteristics are
equivalent in transmit blocks, but are
different in the receive ones.
The nominal sensitivity of the microphone
lines indicates the voltage level on the
GM862-GPS pins present during "normal
spoken" conditions. For a handset , the
"normal spoken‖ conditions take place when
the talker mouth is 7cm far from the
microphone ; under these conditions the
voice will produce an acoustic pressure of -
4,7dBPa @1kHz on the microphone
membrane .
At "normal spoken" conditions, a
microphone having the suggested nominal
sensitivity of -45dBVrms/Pa,will produce
the electrical equivalent signal :
MicLevel = ( -45) + (-4.7) = -49.7
dBVrms
that means :
MicVoltage = 10 ( -49.7 / 20 ) = 3.3* 10 -3
Vrms
During a call, this level varies according to
the volume of the talker voice; usually the
following rough thumb rule for the dynamic
range may be used :
1) The talker is screaming . This is
the strongest voice level condition:
the signal increases by +20dB
2)The talker is whispering. This is
the lowest voice level condition: the
voice level decreases by – 50dB .
These changes were considered for
designing the external microphone
amplifier.
For hands-free/car kit microphone, the voice
attenuation, due to the distance between the
microphone itself and the talker, when
designing the external microphone amplifier
must be taken into account. The microphone
will also pick up ambient noise; to overcome
this problem it is preferable to set the gain of
the microphone 10dB lower with respect to
the calculated value for a nominal
sensitivity. The corresponding reduction in
signal level will be compensated by an
increased voice volume of the talker which
Major Project ‘09 Fleet Management System
30
Dept. of Computer Science & Engineering
College of Engineering, Munnar
will speak louder because of the ambient
noise.
The handsfree mode was chosen while
designing the Audio Section. A THAT audio
amplifier circuit was used to provide the
requisite gain.
Audio Paths In The 'Telit GM862 GPS'
Figure 4.1 AudioPaths in Telit GM862 GPS
The THAT audio amplifier was wired up in
the configuration as shown
below:Depending on the gain required the
value of the resistance RG was varied. The
equation being the same as that of a simple
differential amplifier.
Figure 4.2 THAT Audio Amplifier
Major Project ‘09 Fleet Management System
31
Dept. of Computer Science & Engineering
College of Engineering, Munnar
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.
Major Project ‘09 Fleet Management System
32
Dept. of Computer Science & Engineering
College of Engineering, Munnar
WEB RESOURCE DEVELOPMENT
5.1 Google Maps API
he Google Maps API was used to
embed Maps in the web pages
with JavaScript. The API provides
a number of utilities for manipulating maps
and adding content to the map through a
variety of services, allowing the creation of
robust maps applications on the website.
The Maps API is a free service, available for
any web site that is free to consumers. The
Google Maps API is now integrated with the
Google AJAX API loader, which creates a
common namespace for loading and using
multiple Google AJAX APIs. This
framework allows you to use the optional
google.maps.* namespace for all
classes, methods and properties currently
used in the 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
extensive documentation is available with
the google documentation site for google
maps, which was used in the development
process.
5.2 MySQL
MySQL is the world's most popular open
source database software, with over 100
million copies of its software downloaded or
distributed throughout its history. With its
superior speed, reliability, and ease of use,
MySQL has become the preferred choice for
Web, Web 2.0, SaaS, ISV, Telecom
T
5
The pages were hosted as a subdomain in
the official website of the college, as
http://maraudersmap.cemunnar.ac.in
Major Project ‘09 Fleet Management System
33
Dept. of Computer Science & Engineering
College of Engineering, Munnar
companies and forward-thinking corporate
IT Managers because it eliminates the major
problems associated with downtime,
maintenance and administration for modern,
online applications.
Many of the world's largest and fastest-
growing organizations use MySQL to save
time and money powering their high-volume
Web sites, critical business systems, and
packaged software — including industry
leaders such as Yahoo!, Alcatel-Lucent,
Google, Nokia, YouTube, Wikipedia, and
Booking.com.
The flagship MySQL offering is MySQL
Enterprise, a comprehensive set of
production-tested software, proactive
monitoring tools, and premium support
services available in an affordable annual
subscription.
MySQL is a key part of LAMP (Linux,
Apache, MySQL, PHP / Perl / Python), the
fast-growing open source enterprise
software stack. More and more companies
are using LAMP as an alternative to
expensive proprietary software stacks
because of its lower cost and freedom from
platform lock-in.
The same software stack was used in the
development of this project. The web
programming was mostly done using the
PHP language.
5.3 PHP
PHP is a scripting language originally
designed for producing dynamic web pages.
It has evolved to include a command line
interface capability and can be used in
standalone graphical applications.
While PHP was originally created by
Rasmus Lerdorf in 1995, the main
implementation of PHP is now produced by
The PHP Group and serves as the de facto
standard for PHP as there is no formal
specification. PHP is free software released
under the PHP License, however it is
incompatible with the GNU General Public
License (GPL), due to restrictions on the
usage of the term PHP.
PHP is a widely-used general-purpose
scripting language that is especially suited
for web development and can be embedded
into HTML. It generally runs on a web
server, taking PHP code as its input and
creating web pages as output. It can be
deployed on most web servers and on almost
every operating system and platform free of
charge.PHP is installed on more than 20
million websites and 1 million web servers.
Major Project ‘09 Fleet Management System
34
Dept. of Computer Science & Engineering
College of Engineering, Munnar
5.4 Software Requirement Specifications
5.4.1 Overall Description
The purpose of the software section of the
project is to provide an interface to log the
data into a database, to retrieve it in the
format required for various applications, plot
the data on a map and also to configure the
vehicle mounted unit remotely.
5.4.2 User Classes and Characteristics
The access to the website is closely linked
with the hardware unit described in the
previous sections. The current prototype
includes the user class ‗Client‘ which will
refer to the owner of the fleet or any
authorized representative of the owner, like
the fleet manager, with administrative
privileges.
5.4.3 Operating Environment
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.
5.4.4 Design and Implementation
constraints
The design and implementation of the web
resources is constrained by the design of the
hardware unit and the availability of the
specifications in the previous section and
also the Google Maps.
5.4.5 Assumptions and Dependencies
It is assumed that prior to the use of the web
module, the Google Maps API Key is
obtained from
It is also required that the Hardware unit is
up and running. The browser used by the
client must be capable of displaying google
maps
http://code.google.com/apis/maps
/signup.html
Major Project ‘09 Fleet Management System
35
Dept. of Computer Science & Engineering
College of Engineering, Munnar
5.4.4 Product Description
The Web-side of the project has the
following pages
serverlog.php
index.html
top.html
right.php
mapArea.html
mapplot.php
loginValidation.php
setCuky.php
home.html
moduleconfig.php
processModuleUpdate.php
The Hardware Unit accesses the
serverlog.php via GPRS and sends the
following data.
• Device Id
• Password
• Latitude
• Longitude
• Time
• Velocity
• Fuel
• Ignition
• Tamper
• Remark
• Check Sum
The data received at the serverlog.php page
is processed by that page as follows
Initially, it concatenates all the data received
at the serverside and computes its MD5
Hash. This is then compared with the check
Sum sent by the unit. Any disparity signals
the DBU:INTEGRITYERROR.
Then the latitude and longitude values are
converted into the geographical coordinates
required by the Google Maps to plot the
data. This is followed by the Data validation
procedures and rejects null data.
After that the Password Sent by the unit is
compared with the data from the database. If
there is any disparity a DBU:AUTHERROR
is signaled. Once the authenticity and
integrity of the data is ensured, it is logged
into the ‗mapping‘ table in the
‗cemunnar_marauders‘ database. On success
‗DBU:SUCCESS‘ is signaled and if it fails
‗DBU:ERROR‘ is signaled. Whenever there
is an update available for the unit, as
signaled by the corresponding Boolean true
value from the table
‗cemunnar_marauders‘.‗credentials‘, a
‗DBU:UPDATE‘ is signaled. So is the case
with Alert:OVERSPEED and
Alert:GEOFENCEVIOLATION.
Major Project ‘09 Fleet Management System
36
Dept. of Computer Science & Engineering
College of Engineering, Munnar
5.4.5 Page Hierarchy
Major Project ‘09 Fleet Management System
37
Dept. of Computer Science & Engineering
College of Engineering, Munnar
Major Project ‘09 Fleet Management System
38
Dept. of Computer Science & Engineering
College of Engineering, Munnar
OPENERP INTEGRATION
nformation Systems have played an
increasingly visible role over the past
several years in improving the
competitiveness of business. More than just
tools for handling repetitive tasks, they‘re
used to guide and advance all of a
company‘s‗ daily activities. Integrated
management software is today very often a
key source of significant competitive
advantage.
The standard response to a need for
responsiveness, reliability, and rapidly
increasing expectations is to create an
organization based on departments with a
clear linear structure, integrated around your
operating processes. To increase efficiency
amongst salespeople, accountants, logistics
staff and everyone else you should have a
common understanding of your problems.
For this you need a common language for
shared references, policies and
communication. An ERP (Enterprise
Resource Planning) system makes the ideal
platform for this common reference point.
6.1 Open Source Software at the
Service of Management
Risks and integration costs are important
barriers to all the advantages you gain from
such systems. That‘s why, today, few small-
and medium-sized companies use ERP. In
addition, the larger ERP vendors such as
SAP, Microsoft and Oracle haven‘t been
able to reconcile the power and
comprehensive cover of an ERP system with
the simplicity and flexibility wanted by the
users. But this is exactly what small and
medium enterprises are looking for.
The development processes of open
source software, and the new business
models adopted by their developers, provide
a new way of resolving such problems of
cost and quality for this kind of enterprise
software.
I
6
Major Project ‘09 Fleet Management System
39
Dept. of Computer Science & Engineering
College of Engineering, Munnar
To make an ERP system fully available to
small and medium enterprise, cost reduction
is the first priority. Open source software
makes it possible to greatly reduce
development costs by aggressive reuse of
open source software libraries; to eliminate
intermediaries (the distributors), with all of
their expensive sales overhead; to cut out
selling costs by free publication of the
software; and to considerably reduce the
marketing overhead.
Since there is open interaction among
thousands of contributors and partners
working on the same project, the quality of
the resulting software benefits greatly from
the scrutiny. And you can‘t be everything at
once: accountant, software developer,
salesperson, ISO 9001 quality professional,
specialist in agricultural products, expert in
the customs and habits of pharmaceutical
vendors, just as a start.
Faced with these wide-ranging
requirements, what could be better than a
world network of partners and contributors?
Everyone adds their own contribution
according to their professional competence.
Throughout this book you‘ll see that the
results exceed any reasonable expectations
when such work is well organized.
But the real challenge of development is
to make this solution simple and flexible, as
well as complete. And to reach this level of
quality you need a leader and co-ordinator
who can organize all of these activities. So
the development team of Tiny ERP, today
called Open ERP, is responsible for most of
the organization, synchronization and
coherence of the software.
And Open ERP offers great performance
in all these areas!
6.2 The OpenERP Solution
Because of its modularity, collaborative
developments in Open ERP have been
cleanly integrated, enabling any company to
choose from a large list of available
functions. As with most open source
software, accessibility, flexibility, and
simplicity are important keywords for
development. Experience has shown that
there‘s no need to train users for several
months on the system, because they can just
download it and use it directly.
Major Project ‘09 Fleet Management System
40
Dept. of Computer Science & Engineering
College of Engineering, Munnar
So you‘ll find the modules for all types of
needs, allowing your company to build its
customized system by simply grouping and
configuring the most suitable modules.
Hundreds of modules are available.
They range from specific modules like the
EDI interface for agricultural products,
which has been used to interface with Match
and Leclerc stores, up to the generic
demonstration automation module for
ordering sandwiches, which can take care of
the eating preference of your staff.
The results are quite impressive. Open
ERP (once called Tiny ERP when it started
out) is management software that is
downloaded more than any other in the
world, with over 600 downloads per day.
It‘s available today in 18 languages and has
a world network of partners and
contributors. More than 800 developers
participate in the projects on the
collaborative development system of Tiny
Forge.
To our knowledge, Open ERP is the only
management system which is routinely used
not only by big companies but also by very
small companies and independent
companies. This diversity is an illustration
of the software‘s flexibility: a rather elegant
coordination between people‘s functional
expectations of the software and great
simplicity in its use.
And this diversity is also found in the
various sectors and trades which use the
software, including agricultural products,
textiles, public auctions, IT, and trade
associations.
Lastly, such software has arisen from the
blend of high code quality, well-judged
architecture and use of free technologies. In
fact, you may be surprised (if you‘re an IT
person) to find that the size of Open ERP is
less than 4 MB when you‘ve installed the
software. Implementation of IT has moved a
long way from the days when the only
people who could be expected to benefit
from ERP were the owners of a widget
factory on some remote industrial estate.
6.3 Fleet Management Module
Inspite of the popularity and expertise in
various verticals, Open ERP still lacks the
fleet management functionality. Hence this
Major Project ‘09 Fleet Management System
41
Dept. of Computer Science & Engineering
College of Engineering, Munnar
project incorporates a fleet_manager module
for Open ERP.
The features of the module are:
Vehicle Management:
1. Vehicle Details
2. Vehicle Records & Documentation
3. Purchase, Insurance, Dues etc.
4. Loan Payment Scheduler
5. Asset Management
6. Depreciation
Fuel Master
1. Fuelling Information
2. Fuel/Vendor wise mileage
3. Fuel Card Manager
Partner Management
1. Customer Relationship Management
2. Supplier Relationship Management
3. Automatic Invoicing on Shipping
4. Order Management with GPS
integration
Fleet Maintainance
1. Preventive Maintainance
2. Scheduled Maintainance
3. Work Order management
4. Repair Cost tracker
Spares Management
1. Spares/Tyre serialised management
2. Stock management
3. Warranty tracking
GPS Integration
1. GPS based order management
2. GPS based tracking and predictive
movement
3. GPS based tracking for customer
The module is version controlled at the
Launchpad. Launchpad is a unique
collaboration and hosting platform for
software projects. Most open source projects
including the popular Linux Distribution
Ubuntu is hosted at the launchpad.
Launchpad integrates the Bazaar version
control system and makes release
management, bug tracking and community
building easier than ever. The bazaar branch
for the project is
Branch
lp:~sharoonthomas/openobject
-addons/fleetmanagement
The bazaar version control system is an
easy to use open source tool.
.
Major Project ‘09 Fleet Management System
42
Dept. of Computer Science & Engineering
College of Engineering, Munnar
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
Major Project ‘09 Fleet Management System
43
Dept. of Computer Science & Engineering
College of Engineering, Munnar
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
Major Project ‘09 Fleet Management System
44
Dept. of Computer Science & Engineering
College of Engineering, Munnar
A
AT command, 26
AUTHERROR, 32
B
battery, 24
C
Call Control Logic, 22
Check Sum, 32
Checksum, 12, 24
Control Flow, 22, 25
D
Domain Name System, 8
E
ERROR, 32
F
Fleet Management System, 1, 2, 3
Fuel Block, 21
G
General Purpose Input Output, 15,
21, 22, 23, 24, 28
GEOFENCEVIOLATION, 32
Global Positioning System, 3, 9, 10,
11, 12, 13, 14, 15, 17, 18, 19, 20,
23, 24, 26, 38
Google Maps API, 29
Google Maps API Key, 31
GPRS, 5, 6, 7, 8, 17, 20, 24, 32
GSM, 1, 5, 6, 7, 8, 11, 12, 14, 16, 17,
18, 20
H
home.html, 32
I
Ignition Block, 21
index.html, 32
INTEGRITYERROR, 32
IP address, 8
L
Latitude, 12, 24, 32
loginValidation.php, 32
Longitude, 12, 24, 32
M
mapArea.html, 32
mapplot.php, 32
moduleconfig.php, 32
MySQL, 29, 30, 31
N
NMEA, 11, 12
O
OpenERP, 4, 35
OVERSPEED, 32
P
PHP, 30, 31
processModuleUpdate.php, 32
Project Marauders Map, 1
Python, 1, 15, 18, 19, 20, 30
R
Remote Update, 18
right.php, 32
RS232, 13, 19
S
serverlog.php, 24, 32
setCuky.php, 32
SUCCESS, 32
T
Tampering Block, 21
Telit GM862 GPS, 1, 13, 14, 18, 20,
21, 27
Time Division Multiple Access, 6
top.html, 32
U
UPDATE, 32
Index
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&v=2&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('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&',$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 ?> </td>
</tr>
<tr>
<td>Longitude</td>
<td><?php echo $lon ?> </td>
</tr>
<tr>
<td>Time</td>
<!-- <td><input type="submit" onClick="history.go(0)"
VALUE="Refresh"></td>-->
<td><?php echo $dtime ?> </td>
</tr>
<tr>
<td>Velocity</td>
<td><?php echo $velocity ?> </td>
</tr>
<tr>
<td>Fuel</td>
<td><?php echo $fuel ?> </td>
</tr>
<tr>
<td>Ignition</td>
<td><?php if($ign==0) echo "Off"; else echo "On"; ?> </td>
</tr>
<tr>
<td>Tamper</td>
<td><?php if($tamper==0) echo "No Threat"; else echo "Tamper
Attempt!";?> </td>
</tr>
<tr>
<td>TimeStamp</td>
<td><?php echo $tstamp?> </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
right.php mapArea.html
top.html
Screenshot 3 : home.html with moduleConfig.php
Screenshot 4 : mapplot.php [?deviceId=U01]
Screenshot 5 : OpenERP : fleet_manager