Professional Documents
Culture Documents
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
Certificate
Jithin V Mohan
Minu Balan
[Dept. of Computer Science]
Sharoon Thomas
Lynn Mariette Mendonza
[Dept. of Electronics & Communication]
#
Dept. of Computer Science and Engineering
*
Dept. of Electronics and Communication Engineering
jithinvmohan@gmail.com
minu.frnds@gmail.com
sharoonthomas@teagarden.in
lmmendonza@gmail.com
Acknowledgements
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
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
ABSTRACT
T
his project, code named 'Project Marauders Map' is an Enterprise Fleet
Management System for large and medium fleets (Trucks, Cars, Buses).
The project consists of a hardware platform which manages Vehicle data,
Global Positioning and Wireless Communication, and a software platform to
provide integration into real-time mapping, costing, inventory, asset status and HR
processes.
The hardware platform uses a GSM module, a stripped down version of the mobile
that allows Python scripts to run as third party applications. This report reviews the
development of the Fleet Management System, its feasibility and presents
experiences from implementation of a prototype based on the Telit GM862 GPS.
INTRODUCTION
T
he Fleet operation industry has been an area of heavy investment since
Independence and the progress has been significant. But the task is so
gigantic that it would require many years and large doses of investment to
bring about the desired improvement in the country's transportation system. India‘s
transport sector being large and diverse; caters to the needs of 1.1 billion people. In
1997, the sector contributed 4.4 percent to the nation‘s GDP, with road
transportation contributing the lion‘s share. Good physical connectivity in the
urban and rural areas is essential for economic growth. Since the early 1990s,
India's growing economy has witnessed a rise in demand for transport
infrastructure and services by around 10 percent a year. However, the sector has
not been able to keep pace with rising demand and is proving to be a drag on the
economy. Major improvements in the sector are therefore required to support the
country's continued economic growth1.
Fleet Management System, aims at improving the quality and efficiency of the
industry by identifying & tackling major roadblocks in the day to day operations of
a typical enterprise.
1.1 Background
In the current scenario, most small scale overall impact of reducing efficiency
fleet operators use manual methods of and increasing the cost of operation.
fleet management and have no tracking Hence these solutions are limited to a
system at all. The medium and larger few players who could afford the
enterprises on the contrary have some investment and subsequent training of its
levels of management integrated into employees. These solutions also lack
their operations. Most firms have now integration with the existing tracking
deployed GPS based tracking units in hardware.
their mobile assets for better monitoring. With the increased competition in the
Such devices are widely available from industry, companies are now looking for
many vendors across the country, and ways to improve their efficiency. FMS is
offer a web interface on their websites an umbrella term for applications that
for tracking. However these devices also aim at improving the overall
add to the inherent Indian problem of performance of a hauler‘s fleet in terms
'Lack of Integration' with existing of fuel economy, maintenance costs,
infrastructure. utilisation level, etc. FMS‘ main
Softwares in use by the medium players advantages are better transport
of the industry are mostly limited to coordination, better vehicle and driver
spreadsheets or custom solutions follow up, faster and more precise
developed by regional software invoicing, and faster assistance in case
developers. Lack of support, security of a road side breakdown2.
and synchronisation issues are few Considering the above facts, this project
drawbacks of such solutions. The giants introduces the use of latest hardware
however have resorted to the use of systems and open source tools to build a
proprietary ERP solutions to increase low cost Fleet Management System for
quality & efficiency. These solutions the South Asian market addressing the
with sky rocketing prices and longer problems discussed.
deployment times, in turn have an
Project Requirements
The project was divided into five parts.
The aforesaid goals had to be achieved and documented in a report including review of the
hardware platform used, feasibility in the South Asian region, future prospects and
implementation of a prototype.
1.2 Resources
This project focuses on prototype Notes have also been taken from blogs and
development and hence the investigating forums of active hobbyists involved in
part consists of hardware platform reviews development of M2M platforms.
and evaluation. Therefore much of the The technologies used in the project are all
resources have been data sheets and product in wide use. They are themselves
specifications. extensively documented and a detailed study
Specifications of hardware components used of them is beyond the scope of this report
have been acquired from web pages of
respective manufacturers.
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.1 GSM
The Global System for Mobile versions of the standard have been released,
telecommunications, GSM, standard was allowing higher data rates and new features
developed in the eighties to address the in the networks.
problem of compatibility between numerous The basic GSM network is circuit switched,
telecommunication systems that had just like an ordinary land line telephone
emerged. A first version of the standard was network. When a call is established between
completed in 1990. Since then, the system two nodes, the link in-between is busy,
has been adopted around the world, and new regardless of anything is being
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
internet need no special hardware to A GPRS device can only send at one
communicate with a GPRS device. frequency at a time (use one channel), but it
Data to be sent is first divided into small can use more than one slot in each time slot
pieces, packets. The individual packets are cycle of that channel to increase its
then sent as soon as there is a time slot bandwidth. GPRS devices are divided into
available in the network. Finally, transmitted classes according to the number of time slots
data is reconstructed from the packets at its they can make use of. Performances range
destination. See figure 2.3. No user ‗owns‘ a from utilising one slot in each direction in
repeating time slot, as in the basic GSM class one, to four slots in one direction and
network. This allows a more efficient use of one in the other (4+1 or 1+4), in class 12.
thebandwidth. When user A doesn‘t need See table 2.1.
any time slots, user B can have them and The theoretical data rate, when using one
vice verse. Both users can still be constantly slot, is 13,400 bits per second, giving 53,600
attached to the base station, much like an bps for class 12. These 53,6 kbps is the ―raw
internet broadband connection, ready to send data‖ rate; up to 25 percent thereof is used
or receive. Network operators often employ for error correction and redundancy, leaving
a tariff scheme where users pay for the data about 40 kbps for user data.
actually sent, not the time period he is Table 2.1: Examples of GPRS classes.
connected. The pay-per-byte nature of ‘Active slots’ gives the maximum number of
GPRS makes it ideal to use with remote simultaneously utilized
devices that need to be constantly connected slots. For example class 11 supports up to
four slots for the uplink and up to three slots
to other devices, or to a central server, but
for the downlink,
only exchanging small amounts of data but it can only use a total of five slots
simultaneously.
Figure 2.4: Rough structure of GPRS network destination. An application sending data
usually needs not to worry about all this.
The required functionality is provided at a
Assignment of an IP address to a unit is lower level by the IPS. IPS has a layered
done dynamically by the network operator, architecture. The bottom layer handles the
i.e. A unit‘s IP address will change over physical link; sending and receiving of raw
time. This means that there is no way for a bits. The top layer provides an interface that
server that wants to contact a unit to know applications can use. Each layer in between
its IP address for sure. Lately specialised handles its own part of the transmission. A
operators utilize a Domain Name System, layer only serves the layer immediately
DNS, to give a unit a static public IP above and only makes requests to the layer
immediately below. With well defined are usually implemented in higher level
interfaces between the layers, this makes for protocols when using UDP.
a flexible and easily maintained architecture.
This approach is promoted in the more
general Open Standards Interconnect, OSI,
model and is often called a protocol stack, in
this case an Internet Protocol stack, IP-stack.
The layers of the IP-stack are a subset of
those defined in the OSI. The IP-stack layers
are outlined in figure 2.5.
The main option for the application
programmer when configuring an IP-stack
is, apart from the targets addresses, the use Figure 2.5: IP-Stack Layers
of either TCP or UDP. TCP provides a
controlled channel to the target. It makes
sure that everything that is sent is delivered 2.3 Global Positioning System
to the recipient, and that it is delivered in the [Paragraph 2.3 is based on ref 5]
world. The satellites send positioning data have some accurate way to measure
and system information to users on earth. distance. The first problem is not so hard.
Each satellite transmits at two frequencies, Orbits of the satellites are stabile and can be
one for civil and one for military use. predicted with high accuracy by
mathematical formulas. In addition to this,
2.3.1 Triangulation tracking stations around the world monitor
the satellites positions and update them
GPS positioning is based on triangulation. A when they are off course. The satellites in
GPS receiver on earth first measures its turn, send correction data to the GPS
distance, R1, to one of the GPS satellites, receivers. The receivers store the positions
S1. The receiver has then pinned its position of the satellites and can then calculate
down to a sphere with radius R1 around S1. satellite positions for the coming time
By repeating this procedure for two more intervals, until the satellites send the next
intercepts in two points. One of these two To measure distance, a given predefined
points can be discarded as being to far from pseudo random code is transmitted by the
the earth; the other interception point is the satellite starting at a given time. At the same
receiver‘s location. There is a fourth time, the receiver starts to generate the same
variable added to the three ‗room‘ dittos: code. By correlation, the receiver then
relative time of the clocks in the satellites measurers the time offset between its own
and receivers. Therefore a fourth satellite is code and that received from the satellite.
required to solve the equation. The reason The signal from the satellite is an
for is described in more detail in the next electromagnetic wave with finite speed, c.
Association, NMEA. The standard is aimed 7) FAA mode indicator (NMEA 2.3 and
at marine electronics, and GPS later)
communications is a subset of it. The most 8) Checksum
common version, NMEA 0183, is quite
simple and allows one talker (in this case the 2.3.5 Competing positioning
GPS receiver) to send ASCII character systems
‗sentences‘ to one or more passive listeners,
A global navigation system similar to GPS
for example a navigation device. Apart from
was developed in Russia in parallel with the
the physical matters the standard defines a
US development. The Russian system is
set of sentences to declare, for example;
called GLONASS, Global'naya
position, current time, system status, etc.
Navigatsionnaya Sputnikovaya Sistema. It
These are transmitted in a loop by the talker.
was fully operational for a while in the mid
The sentences can be decoded by a
nineties, but declined along with Russian
compatible listener, (computer, PDA) which
economy. The system is again gaining
can then process the data further. Below is
momentum, with planned world coverage by
an example of the NMEA sentence GLL,
2010.
Geographic Position – Latitude/Longitude.
The European Union is developing their
own navigation system, Galileo, with
1 2 3 4 5 67 8
partners including China and Israel. Galileo
| | | | | || |
is planned to be operational in 2008. Both of
$--
these systems provide roughly the same
GLL,llll.ll,a,yyyyy.yy,a,hhmmss.ss,a,m,*hh
accuracy as GPS, but it will be some time
Field Number:
after their launch dates before the market for
1) Latitude
receivers is as developed as that for GPS.
2) N or S (North or South)
Because of this, these systems will not be
3) Longitude
real competitors to GPS for a long time.
4) E or W (East or West)
A different approach to positioning which is
5) Universal Time Coordinated (UTC)
under development, is through GSM-
6) Status A - Data Valid, V - Data Invalid
networks. It is based on a number of
techniques involving radio frequency signal
strength from different GSM base stations. bit rate and ability to supply current to the
Coverage of the system is limited to GSM- peripheral unit. An advantage of RS-232 is
network coverage, and accuracy today is that it requires less software support than
about 200 m in urban areas, decreasing to 4 USB, making it a good option for devices
km in rural zones, compared to about 15 with limited resources, where it is still in
meters for an ordinary GPS. wide use. One case could for example be to
The conclusion is that as of today and connect a GPS
coming years, there are no real competitors to a PDA. As mentioned above, a set back
to GPS. of the standard is that it defines a large
voltage swing. -15 ÷ -3 V for logic one and
2.4 Input/Output 3 ÷ 15 V for logic zero. This large swing
The following paragraphs gives a limits the maximum bit rate due to limited
description of different input and output, IO, slew of the signal generator. Also, an
standards supported by the module Telit ordinary TTL9 or CMOS10 circuit can not
referring to a modem, which was the set up two bidirectional wires for clock and data,
that the standard was originally intended for. and can in the latest revision transfer data in
rates up to 3.4 Mbit/s, with 100 and 400
The 4 +1 signal sub set is: Kbit/s being more common. The standard
TD Transmitted Data from DTE to DCE uses 10 bit addressing, enabling up to 1000
RD Received Data from DCE to DTE unique nodes to be pointed out on the bus, as
outputs. The direction of the pins can be variables. Therefore, values, not variables
configured in application software. Hence carry type. This enables shorter code, but is
they are called General Purpose Input also a great error source. The feature takes
Output, GPIO. Digital pins could for some time to get used to if one is used to for
example be used to connect an alarm button example Java programming. Python is
to the module, or some indication Light designed with the intention of being highly
Emitting Diodes, LED‘s. An output pin, in readable. To attain this it has a simple visual
general, does not supply much current, so layout, English keywords instead of
additional driving is needed to drive the punctuation, and fewer syntactic constructs
external item, e.g. LED.Telit GM862 GPS than for example C.
has one input pin, an output pin and 11 White space is used as delimiter instead of
GPIO pins. brackets. Python is the only major language
with this approach. This enforces the
2.5 Python Programming indentation convention used in many other
languages with the motivation of making the
The first version of Python was released in language more readable. This can be seen in
the early nineties. It is now developed by Appendix B,‗Source Code‘. Space and tab
Source project. Although used for some runtime. If they are mixed they will generate
popular programs like the original errors.Since space and tab are visually
BitTorrent tracker, Python is not as widely similar, these errors can be hard to detect
HARDWARE PLATFORM
G
SM-modems have been around
for some 10 years. A GSM- GSM-module looks like is shown in figure
modem is simply speaking a 3.1.
mobile phone that has been stripped of its
display and keyboard, leaving only the
actual radio device, control circuits and IO.
The device can then be embedded into a
product as a communication link to cell-
Figure 3.1: Telit GM 862 GPS
phone networks and onwards to the internet
During the past three-four years, an 3.1.1 General applications
enhanced type of GSM-modem has
emerged. They will be called GSM-modules
GSM modules allow highly integrated
in this project. The difference to an ordinary
embedded systems with Internet
modem is that the module allows the
connectivity, where component count can be
running of third party application code
kept to a minimum. They target products
within the unit, eliminating the need of an
that need connectivity with each other or a
external controller. The GSM-modules also
central server from remote locations. The
host internal IP-stacks, making Internet
main property to keep in mind when
designing a system where the intelligence is
embedded into a GSM-module is the limited CPU power and memory. Since the
modules have limited resources, their tasks GSM-terminal, the module also provides
should be kept simple and non-time-critical. means to execute third party application
Possible applications include collecting and code. The application could either be run on
sending positioning information from a spare capacity in the module‘s baseband
vehicle, CPU, or in a dedicated application CPU.
reporting stock of a vending machine,
weather data from a weather station, etc. In The target applications of GSM-modules
addition to the stand-alone mode, all often include positioning. To meet this
modules evaluated in this report can also be demand, GSM-modules with internal GPS
controlled by an external CPU, like a have been released. The GPS receiver chip
traditional GSM-terminal. The two different is fitted into the module and connected to
architectures are shown in figure 3.2. the application CPU. In all released
implementations, the link in between the
CPU and GPS is a RS-232 line and it
decreases the number of external serial ports
of the module by one, compared to the
respective models without GPS.
The connector of the modules is either a ball
grid array, BGA, or a multi pin board-to-
board connector. A dedicated Printed Circuit
Figure 3.2: Comparison of architectures Board, PCB, is then needed to use the
module. The PCB should contain proper IO
3.1.2 Hardware
connectors, peripheral circuitry such as RS-
232 level converters, and power supply. A
A GSM module contains a baseband CPU
GSM device has some particular powering
that maintains the GSM/GPRS protocols.
demands. Though its average power
The CPU communicates with a high
consumption is rather low, the unit can need
frequency radio transceiver that modulates
up to two ampere when transmitting in its
the signal from the baseband CPU and
transmits it into the ether. In difference to a
time slot. This should be accounted for in and can‘t be accessed. Mechanism for the
the power supply design. remote update in the FMS is using the FTP
Developing a PCB takes time. To speed up feature of Telit GM862 GPS. Appendix B
prototyping, and to allow parallel hardware has the detailed code for the purpose.
and software development, all GSM-module
producers provide test boards for their 3.3 Telit GM862 GPS
models. These boards offer complete
support for a module, so that the application
Telit is based in Trieste, Italy, with Arrow
programmer can start to work at once.
and Round Solutions as Swedish sales
However the EVK2 board combatible with
agents. Telit has developed cellular based
the Telit GM862 GPS being as expensive as
products since the mid eighties. Their
the module itself was ruled out.
product ranges today include both GSM
handsets and modules. Their most suitable
3.2 Remote Update module for this project is the GM862-GPS.
It has an embedded Python script interpreter
HARDWARE DEVELOPMENT
F
or the developement of hardware, the
GM862 GPS' as the basic module and
block diagram was first formulated and
additional hardware is incorporated to
then each block was designed and made
functional.The developement approach chosen
realise the functionalities desired.
was an agile methodology called 'Scrum' The 'Ignition Block' determines whether the
ignition of the vehicle is on/off and feeds the
corresponding signal to the GPIO pin of the
4.1 Block Diagram module.
The 'Tampering Block' is so designed to
alert the control room in case of any tamper,
incident to the module by sending a high
priority SMS to the control number specified
in the configuration file.
The 'Fuel Block' is used to calculate the
percentage of fuel in the vehicle.The output
voltage from the float sensor in the fuel tank
of the vehicle is dropped using suitable
resistance circuits and then fed to the ADC
centre numbers
Perform Initialisation
process
Once the block diagram was
designed, a control flow diagram was drawn
up to characterise the work flow and then
each block's working was specified using a
flow chart.
If Ring
4.2 Control Flow Diagram Enga fals =Tru
ged= e e
False
Y Y
CLID in list
Y
Set Volume high,Eng=true
Call Disc ?
Y
Set Volume low,Eng=False
blocks; both in transmit (Uplink) and in During a call, this level varies according to
receive (Downlink) direction: the volume of the talker voice; usually the
―MT lines‖ should be used for handset following rough thumb rule for the dynamic
function, ―HF lines‖ is suited for hands -free range may be used :
These two blocks can be active only one at a the strongest voice level condition:
equivalent in transmit blocks, but are the lowest voice level condition: the
The nominal sensitivity of the microphone These changes were considered for
lines indicates the voltage level on the designing the external microphone
spoken" conditions. For a handset , the For hands-free/car kit microphone, the voice
"normal spoken‖ conditions take place when attenuation, due to the distance between the
the talker mouth is 7cm far from the microphone itself and the talker, when
microphone ; under these conditions the designing the external microphone amplifier
voice will produce an acoustic pressure of - must be taken into account. The microphone
4,7dBPa @1kHz on the microphone will also pick up ambient noise; to overcome
microphone having the suggested nominal the calculated value for a nominal
will speak louder because of the ambient below:Depending on the gain required the
noise. value of the resistance RG was varied. The
The handsfree mode was chosen while equation being the same as that of a simple
designing the Audio Section. A THAT audio differential amplifier.
amplifier circuit was used to provide the
requisite gain.
5.1 Google Maps API The google maps API requires one to
initially register for an API key, before one
can start putting maps on a site. An
T
he Google Maps API was used to
embed Maps in the web pages extensive documentation is available with
with JavaScript. The API provides the google documentation site for google
a number of utilities for manipulating maps maps, which was used in the development
companies and forward-thinking corporate programming was mostly done using the
IT Managers because it eliminates the major PHP language.
problems associated with downtime,
maintenance and administration for modern, 5.3 PHP
online applications.
PHP is a scripting language originally
designed for producing dynamic web pages.
Many of the world's largest and fastest-
It has evolved to include a command line
growing organizations use MySQL to save
interface capability and can be used in
time and money powering their high-volume
standalone graphical applications.
Web sites, critical business systems, and
While PHP was originally created by
packaged software — including industry
Rasmus Lerdorf in 1995, the main
leaders such as Yahoo!, Alcatel-Lucent,
implementation of PHP is now produced by
Google, Nokia, YouTube, Wikipedia, and
The PHP Group and serves as the de facto
Booking.com.
standard for PHP as there is no formal
The flagship MySQL offering is MySQL
specification. PHP is free software released
Enterprise, a comprehensive set of
under the PHP License, however it is
production-tested software, proactive
incompatible with the GNU General Public
monitoring tools, and premium support
License (GPL), due to restrictions on the
services available in an affordable annual
usage of the term PHP.
subscription.
PHP is a widely-used general-purpose
MySQL is a key part of LAMP (Linux,
scripting language that is especially suited
Apache, MySQL, PHP / Perl / Python), the
for web development and can be embedded
fast-growing open source enterprise
into HTML. It generally runs on a web
software stack. More and more companies
server, taking PHP code as its input and
are using LAMP as an alternative to
creating web pages as output. It can be
expensive proprietary software stacks
deployed on most web servers and on almost
because of its lower cost and freedom from
every operating system and platform free of
platform lock-in.
charge.PHP is installed on more than 20
The same software stack was used in the
million websites and 1 million web servers.
development of this project. The web
OPENERP INTEGRATION
I
nformation Systems have played an
platform for this common reference point.
increasingly visible role over the past
several years in improving the
competitiveness of business. More than just 6.1 Open Source Software at the
tools for handling repetitive tasks, they‘re Service of Management
used to guide and advance all of a
company‘s‗ daily activities. Integrated Risks and integration costs are important
management software is today very often a barriers to all the advantages you gain from
key source of significant competitive such systems. That‘s why, today, few small-
advantage. and medium-sized companies use ERP. In
addition, the larger ERP vendors such as
The standard response to a need for SAP, Microsoft and Oracle haven‘t been
responsiveness, reliability, and rapidly able to reconcile the power and
increasing expectations is to create an comprehensive cover of an ERP system with
organization based on departments with a the simplicity and flexibility wanted by the
clear linear structure, integrated around your users. But this is exactly what small and
operating processes. To increase efficiency medium enterprises are looking for.
amongst salespeople, accountants, logistics
staff and everyone else you should have a The development processes of open
common understanding of your problems. source software, and the new business
models adopted by their developers, provide
For this you need a common language for a new way of resolving such problems of
shared references, policies and cost and quality for this kind of enterprise
communication. An ERP (Enterprise software.
To make an ERP system fully available to results exceed any reasonable expectations
small and medium enterprise, cost reduction when such work is well organized.
is the first priority. Open source software
makes it possible to greatly reduce But the real challenge of development is
development costs by aggressive reuse of to make this solution simple and flexible, as
open source software libraries; to eliminate well as complete. And to reach this level of
intermediaries (the distributors), with all of quality you need a leader and co-ordinator
their expensive sales overhead; to cut out who can organize all of these activities. So
selling costs by free publication of the the development team of Tiny ERP, today
software; and to considerably reduce the called Open ERP, is responsible for most of
marketing overhead. the organization, synchronization and
coherence of the software.
Since there is open interaction among And Open ERP offers great performance
thousands of contributors and partners in all these areas!
working on the same project, the quality of
the resulting software benefits greatly from 6.2 The OpenERP Solution
the scrutiny. And you can‘t be everything at
once: accountant, software developer, Because of its modularity, collaborative
salesperson, ISO 9001 quality professional, developments in Open ERP have been
specialist in agricultural products, expert in cleanly integrated, enabling any company to
the customs and habits of pharmaceutical choose from a large list of available
vendors, just as a start. functions. As with most open source
software, accessibility, flexibility, and
Faced with these wide-ranging simplicity are important keywords for
requirements, what could be better than a development. Experience has shown that
world network of partners and contributors? there‘s no need to train users for several
Everyone adds their own contribution months on the system, because they can just
according to their professional competence. download it and use it directly.
Throughout this book you‘ll see that the
So you‘ll find the modules for all types of companies. This diversity is an illustration
needs, allowing your company to build its of the software‘s flexibility: a rather elegant
customized system by simply grouping and coordination between people‘s functional
configuring the most suitable modules. expectations of the software and great
Hundreds of modules are available. simplicity in its use.
They range from specific modules like the And this diversity is also found in the
EDI interface for agricultural products, various sectors and trades which use the
which has been used to interface with Match software, including agricultural products,
and Leclerc stores, up to the generic textiles, public auctions, IT, and trade
demonstration automation module for associations.
ordering sandwiches, which can take care of
the eating preference of your staff. Lastly, such software has arisen from the
blend of high code quality, well-judged
The results are quite impressive. Open architecture and use of free technologies. In
ERP (once called Tiny ERP when it started fact, you may be surprised (if you‘re an IT
out) is management software that is person) to find that the size of Open ERP is
downloaded more than any other in the less than 4 MB when you‘ve installed the
world, with over 600 downloads per day. software. Implementation of IT has moved a
It‘s available today in 18 languages and has long way from the days when the only
a world network of partners and people who could be expected to benefit
contributors. More than 800 developers from ERP were the owners of a widget
participate in the projects on the factory on some remote industrial estate.
collaborative development system of Tiny
Forge. 6.3 Fleet Management Module
To our knowledge, Open ERP is the only Inspite of the popularity and expertise in
management system which is routinely used various verticals, Open ERP still lacks the
not only by big companies but also by very fleet management functionality. Hence this
small companies and independent
2. Scheduled Maintainance
3. Work Order management The bazaar version control system is an
Conclusion
References
Index
H processModuleUpdate.php, 32
C Project Marauders Map, 1
home.html, 32 Python, 1, 15, 18, 19, 20, 30
Call Control Logic, 22
Check Sum, 32
I R
Checksum, 12, 24
Control Flow, 22, 25 Ignition Block, 21 Remote Update, 18
index.html, 32 right.php, 32
D INTEGRITYERROR, 32 RS232, 13, 19
IP address, 8
Domain Name System, 8
S
L
E serverlog.php, 24, 32
Latitude, 12, 24, 32 setCuky.php, 32
ERROR, 32 loginValidation.php, 32 SUCCESS, 32
Longitude, 12, 24, 32
F T
Fleet Management System, 1, 2, 3
M Tampering Block, 21
Fuel Block, 21 mapArea.html, 32 Telit GM862 GPS, 1, 13, 14, 18, 20,
mapplot.php, 32 21, 27
G moduleconfig.php, 32 Time Division Multiple Access, 6
MySQL, 29, 30, 31 top.html, 32
General Purpose Input Output, 15,
21, 22, 23, 24, 28
GEOFENCEVIOLATION, 32
N U
NMEA, 11, 12 UPDATE, 32
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
<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;
}
$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");
}
$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);
//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
<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[
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());
}
});
}
}
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;
}
End of mapplot.php
moduleconfig.php
<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());
}
</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");
$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
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")
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
Screenshot 2 : home.html
mapArea.html right.php
top.html
Screenshot 3 : home.html with moduleConfig.php