Warning: Don't Run These 8 Commands On Linux, Ever! | ||||||||||||
|
Omkar Kirpan
Monday, 11 August 2014
Location:
India
Sunday, 10 August 2014
100 Free Online Courses On Computer Science
Learning Computer Science has never been easier than it is today. Well, you will have to work hard, but you can find courses more easily. Here are 100 courses on Computer Science from the best universities across the globe. And, did we mention, they all are free! Have a dekko:
Learning Computer Science has never been easier than it is today. Well, you will have to work hard, but you can find courses more easily. Here are 100 courses on Computer Science from the best universities across the globe. And, did we mention, they all are free! Have a dekko:
Advanced Data Structures - Free Online Video, Free Course Info & Video - Erik Demaine, MIT |
Advanced Operating Systems Structures and Implementation - Free Online Video , Free iTunes Video , John Kubiatowicz, UC Berkeley |
Android Development - Free iTunes Video -David Fisher, UC Berkeley |
Artificial Intelligence – Free iTunes Video – Free Online Video & Course Info – Patrick Winston, MIT |
Artificial Intelligence - Free Online Video - Free iTunes Video - Pieter Abbeel, UC Berkeley |
Artificial Intelligence - Introduction to Robotics - Free Online Video , Free iTunes Video, Free Course in Multiple formats – Oussama Khatib, Stanford |
Artificial Intelligence - Natural Language Processing - Free Course in Multiple formats - Christopher Manning, Stanford |
Artificial Intelligence - Machine Learning - Free Online Video , Free iTunes Video , Free Course in Multiple formats - Andrew Ng, Stanford |
Artificial Intelligence - Free Online Video , Free Video Download - P.Dasgupta, IIT |
Basic Concepts of Operating Systems & System Programming - Free Online Video , Free iTunes Video - Anthony Stoica, Anthony Joseph, UC Berkeley |
Bits: The Computer Science of Digital Information - Free Course in Multiple Formats - Harry Lewis, Harvard |
Blender 3D Design - Free iTunes iOS Course , Course Info - Neal Hirsig, Tufts |
Building Dynamic Web Sites - Free iTunes Video & Audio , Free Course Video & Audio - David Malan, Harvard Extension |
Building Mobile Applications - Free iTunes Audio , Free Course Info & Video - David Malan, Harvard Extension |
Codecademy - Web Site |
Coding Together: Apps for iPhone and iPad (2012) - Free iTunes Video - Paul Hegarty, Stanford |
Coding Together: Apps for iPhone and iPad (2013) - Free iTunes Video - Paul Hegarty, Stanford |
Computational Camera and Photography - Free Online Audio , Course Info - Ramesh Raskar, MIT |
Computational Discrete Mathematics - Free Web Course - Carnegie Mellon |
Computer Architecture - Free Online Video , Free Video Download - Anshul Kumar, IIT Delhi |
Computer Graphics - Free Online Video - Free Video Download - Sukhendu Das, IIT |
Computer Language Engineering - Free Course Materials & Video - Martin Rinard, MIT |
Computer Networks - Free Online Video , Free Video Download - S.Ghosh, IIT |
Computer Systems - Free iTunes Video - Stan Warford, Pepperdine |
Computer System Engineering - Free Course Materials & Video - Robert Morris & Samuel Madden, MIT |
CS50, Harvard's Introductory Computer Science Course - Free Online Video , Free Course Materials & Video , Free iTunes iOS Course - David Malan, Harvard |
CS50, Harvard’s Introductory Computer Science Course (2013 Update) - Free iTunes Video , Free Online Video , Course Information (Background) - David Malan, Harvard |
Database Systems Design - Free iTunes Video - Rob Meredith, Monash University |
Data Structures - Free iTunes Video , Free Online Video - Paul Hilfinger, UC Berkeley |
Data Structures and Algorithms - Free Online Video - Richard Buckland, University of New South Wales |
Data Structures - Free iTunes Video - Stan Warford, Pepperdine |
Design in Computing - Free Online Video - Richard Buckland, University of New South Wales |
Developing Apps for iOS 5 (iPhone & iPad) - Free iTunes Video - Paul Hegarty, Stanford |
Developing iOS 7 Apps for iPhone and iPad - Free iTunes Video - Paul Hegarty, Stanford |
Developing iPad Applications for Visualization and Insight - Free iTunes Video - Niki Kittur, Carnegie Mellon |
Discrete Mathematical Structures - Free Online Video , Free Video Download - Kamala Krithivasan, IIT |
Discrete Mathematics and Probability Theory - Free Online Video , Free Online Video 2 - Umesh Vazirani, UC Berkeley |
Discrete Stochastic Processes - Free Online Video , Free iTunes Video , Free Course Materials & Video - Robert Gallagher, MIT |
Discrete Structures - Free iTunes Video - Sergio Dibiasi, Rutgers |
Discrete Structures - Free iTunes Video - Stan Warford, Pepperdine |
Efficient Algorithms and Intractable Problems - Free iTunes Video , Free Online Video , Free Online Video 2 - Christos Papadimitriou & Satish Rao, UC Berkeley |
Foundations of Computer Graphics - Free Online Video - Ravi Ramamoorthi, UC Berkeley |
Great Insights in Computing - Free iTunes Audio & Video - Rutgers |
Higher Computing - Free Online Video - Richard Buckland, University of New South Wales |
Human-Computer Interaction Seminar - Free Online Video , Free iTunes Video - Multiple Staff, Stanford |
Innovative Computing - Free Online Video - Multiple Profs, Harvard |
Intensive Introduction to Computer Science Using C, PHP, and JavaScript - Multiple Formats - Free Online Video , Free iTunes Video - David Malan, Harvard |
Introduction to Algorithms - Free iTunes Video , Free Online Video , Free Course Materials & Video - Prof. Charles Leiserson & Erik Demaine, MIT |
Introduction to Computer Graphics & GPU Programming - Free iTunes Video - Eric Chan & Hanspeter Pfister, Harvard |
Introduction to Computer Programming for Scientists and Engineers - Free iTunes Audio , Free iTunes Video - Roberto Horowitz, UC Berkeley |
Introduction to Computer Science and Programming - Free Online Video , Free iTunes Video , Free Courses Materials & Video - Eric Grimson, John Guttag, MIT |
Introduction to Computer Science: Programming Methodology - Free Online Video , Free iTunes Video , Free Course in Multiple formats - Mehran Sahami, Stanford |
Introduction to Computer Science: Programming Abstractions - Free Online Video , Free iTunes Video , Free Course in Multiple formats - Julie Zelenski, Stanford |
Introduction to Computer Science: Programming Paradigms - Free Online Video , Free iTunes Video , Free Course in Multiple formats - Jerry Cain, Stanford |
Introduction to Computer Architecture (2013) - Free Online Video , Course Info - Onur Mutlu, Carnegie Mellon |
Introduction to Computer Architecture (2012) - Free Online Video , Course Info - Onur Mutlu, Carnegie Mellon |
Introduction to Computer Graphics - Free Online Video , Free Video Download - Prem Kalra, IIT |
Introduction to Computing for Non-Majors - Free iTunes Video - JT Chirco, Rutgers |
Introduction to Computing - Free iTunes Video - JT Chirco, Rutgers |
Introduction to Electrical Engineering and Computer Science I - Free Online Video , Free iTunes Video , Free Courses Materials & Video - Multiple Professors, MIT |
Introduction to Embedded Systems - Free iTunes Video , Free Online Video - Professors Sanjit Seshia, Edward A. Lee, UC Berkeley |
Introduction to Formal Systems & Computation - Free iTunes Video - Multiple profs, Harvard |
Introduction to Information Studies - Free iTunes Audio - Robert Frost, University of Michigan |
Introduction to Problem Solving & Programming - Free Online Video , Free Video Download - Deepak Gupta, IIT |
iPhone Application Development in iOS5 (Fall 2011) - Free iTunes HD Video , Free iTunes Standard-Def Video |
iPhone Application Development (Spring 2009) - Free iTunes Video - Stanford |
iPhone Application Development (Winter 2010) - Free iTunes Video - Stanford |
Linux Implementation/Administration Practicum - Free iTunes Video - Tulio Llosa, U of Illinois, Springfield |
Logic & Proofs - Free Web Course - Carnegie Mellon |
Machine Structures - Free iTunes Video - David Culler, UC Berkeley |
Machine Learning - Free iTunes Video - Yaser S. Abu-Mostafa, CalTech |
Massively Parallel Computing - Free iTunes Video - Harvard |
Mathematics for Computer Science - Free Online Course Materials & Video - Tom Leighton, MIT |
Media Programming - Free Web Course - Carnegie Mellon |
Methods of Mathematics - Free Online Video - Free iTunes Video - Per-Olof Persson, UC Berkeley |
Mobile Software Engineering - Free Video + Courses Info - David Malan, Harvard |
Multicore Programming Primer - Free iTunes Video - Free Online Video & Course Materials - Saman Amarasinghe, MIT |
Online Graphics - Free Online Video - Ravi Ramamoorthi, UC Berkeley |
Operating Systems and System Programming - Free iTunes Video , Free Online Video , Multiple professors, UC Berkeley |
Performance Engineering of Software Systems - Free Online Video , Free Video & Course Info - Multiple Professors, MIT |
Principles of Computing - Free Web Course - Carnegie Mellon |
Principles of Digital Communications I - Free Online Video , Free iTunes Video , Free Online Video & Course Info - Profs Gallagher and Zheng, MIT |
Principles of Digital Communications II - Free Online Video , Free Online Video & Course Info - MIT |
Probabilistic Systems Analysis and Applied Probability - Free Online Video , Free Video & Course Info - John Tsitsiklis, MIT |
Programming Languages and Compilers - Free Online Video - Paul Hilfinger, UC Berkeley |
Programming Languages and Compilers - Free Online Video - Web - Ras Bodik, UC Berkeley |
Programming for Designers - Free Online Video - UNSW |
Python - Free Online Video - Nick Parlante, Google |
Quantum Computing for the Determined - Free Online Video - Michael Nielsen, The University of Queensland |
Responsible Computing - Free Web Course - Carnegie Mellon |
Search Engines: Technology, Society and Business - Free Online Video - Marti Hearst, UC Berkeley |
Software as a Service - Free Online Video - Armando Fox and David Patterson, UC Berkeley |
Software Engineering - Free Online Video , Free iTunes Audio , Free iTunes Video , Web - Multiple Professors, UC Berkeley |
The Beauty and Joy of Computing - Free iTunes Video , Free Online Video - Brian Harvey, UC Berkeley |
The Beauty and Joy of Computing - Free Online Video - Web - Dan Garcia, UC Berkeley |
The Future of the Internet - Free iTunes Audio - Ramesh Johari, Stanford |
The Society of Mind - Free Online Video , Free iTunes Video , Course Info - Marvin Minsky, MIT |
The Structure and Interpretation of Computer Programs - Free Online Video , Free iTunes Video , Web - Brian Harvey, UC Berkeley |
Understanding Computers and the Internet - Free iTunes Audio & Video , Free Course Info & Video , David Malan, Harvard University |
Visual Navigation for Flying Robots - Free Online Video - Juergen Sturm |
XML with Java - Free iTunes Audio , Free Course Info - David Malan, Harvard |
#OmkaR KirpaN#
Saturday, 15 February 2014
Thursday, 24 October 2013
GSM Module SIM300 Interface with AVR Amega32
A GSM/GPRS Module like SIM300 can be used for any embedded application that requires a long range communication, like a robot in Chennai controlled by a person sitting in New Delhi! Or simply a water pump in a rice field turned on in the morning by a farmer sitting in his house few kilometers away! You have few communication options depending on the application, they may be as follows.
- Simple SMS based communication
- Turn on/off loads using simple SMS commands, so the controlling device is a standard handset. You can use any mobile phone to control the device.
- A intruder alarm/fire alarm that informs about the panic situation to the house owner on his/her mobile via SMS.
- Call based communication
- A smart intruder alarm/fire alarm that calls the police or fire station and plays a pre recorded audio message to inform about the emergency.
- Internet Based Communication (GPRS)
- User can control the end application using any PC/Tablet/Mobile with internet connection. Example: LED Message Displays installed on highways/expressways controlled from a central control room to inform users or traffic conditions ahead.
- A robot controlled over internet. That means the robot can be accessed from any device having internet any where in the world.
- A portable device installed on vehicles that connects to internet using the GPRS Module SIM300 and uploads current position(using Global Position System) to a server. The server stores those location in a database with the ID of vehicle. Then a client(using a PC) can connect with the server using World Wide Web to see the route of the vehicle.
Advantage of using SIM300 Module.
The SIM300 KIT is a fully integrated module with SIM card holder, power supply etc. This module can be easily connected with low cost MCUs like AVR/PIC/8051. The basic communication is over asynchronous serial line. This is the most basic type of serial communication that's why it is very popular and hardware support is available in most MCUs. The data is transmitted bit by bit in a frame consisting a complete byte. Thus at high level it is viewed as a simple text stream. Their are only two streams one is from MCU to SIM300 and other is from SIM300 to MCU. Commands are sent as simple text. Their are several tutorials that describes how to send and receive strings over the serial line.If you have never heard of serial communication and never did it in practice then it is highly recommend to go and understand clearly using some thing simpler (experiments given in above links).
Communication with SIM300 Module using AVR UART.
The hardware(inside the AVR MCU Chip) that is used to to serial communication is called the UART, we use this UART to communicate with the SIM300 module (the UART can also be used to communicate with other devices like RFID Readers, GPS Modules, Finger Print Scanner etc.). Since UART is such a common method of communication in embedded world that we have made a clean and easy to use library that we use in all our UART based projects.Since a byte can arrive to MCU any time from the sender (SIM300), suppose if the MCU is busy doing something else, then what happens? To solve this, we have implemented a interrupt based buffering of incoming data. A buffer is maintained in the RAM of MCU to store all incoming character. Their is a function to inquire about the number of bytes waiting in this queue.
Following are the functions in AVR USART library
void USARTInit(uint16_t ubrrvalue)
Initializes the AVR USART Hardware. The parameter ubrrvalue is required to set desired baud rate for communication. By default SIM300 communicates at 9600 bps. For an AVR MCU running at 16MHz the ubrrvalue comes to be 103.
char UReadData()
Reads a single character from the queue. Returns 0 if no data is available in the queue.
void UWriteData(char data)
Writes a single byte of data to the Tx Line, used by UWriteString() function.
uint8_t UDataAvailable()
Tells you the amount of data available in the FIFO queue.
void UWriteString(char *str)
Writes a complete C style null terminated string to the Tx line.
Example #1:
Example #2:UWriteString("Hello World !");
char name[]="Avinash !"; UWriteString(name);
void UReadBuffer(void *buff,uint16_t len)
Copies the content of the fifo buffer to the memory pointed by buff, the amount of data to be copied is specified by len parameter. If UART incoming fifo buffer have fewer data than required (as per len parameter) then latter areas will contain zeros.
Example:
char gsm_buffer[128]; UReadBuffer(gsm_buffer,16);The above example will read 16 bytes of data (if available) from the incoming fifo buffer to the variable gsm_buffer. Please note that we have allocated gsm_buffer as 128 byte array because latter we may need to read more than 16 bytes. So the same buffer can be used latter to read data up to 128 bytes.
The above function is used generally along with UDataAvailable() function.
while(UDataAvailable()<16) { //Do nothing } char gsm_buffer[128]; UReadBuffer(gsm_buffer,16);The above code snippet waits until we have 16 bytes of data available in the buffer, then read all of them.
void UFlushBuffer()
Removes all waiting data in the fifo buffer. Generally before sending new command to GSM Module we first clear up the data waiting in the fifo.
The above functions are used to send and receive text stream from the GSM Module SIM300.
SIM300 AT Command Set
Now you know the basics of AVR USART library and how to use it to initialize the USART, send and receive character data, its time for us to move ahead and look what commands are available with SIM300 module and how we issue commands and check the response. SIM300 supports several functions like sending text messages, making phone call etc. Each of the tasks is done using a command, and sim300 has several commands known as the command set.All SIM300 commands are prefixed with AT+ and are terminated by a Carriage Return (or <CR> in short). The ASCII code of CR is 0x0D (decimal 13). Anything you write to SIM300 will be echoed back from sim300's tx line. That means if you write a command which is 7 bytes long (including the trailing CR) then immediately you will have same 7 bytes in the MCU's UART incoming buffer. If you don't get the echo back then it means something is wrong !
So the first function we develop is SIM300Cmd(const char *cmd) which does the following job :-
(NOTE: All sim300 related function implementations are kept in file sim300.c, and prototypes and constants are kept in sim300.h)
- Writes the command given by parameter cmd.
- Appends CR after the command.
- Waits for the echo, if echo arrives before timeout it returns SIM300_OK(constant defined in sim300.h). If we have waited too long and echo didn't arrive then it returns SIM300_TIMEOUT.
int8_t SIM300Cmd(const char *cmd)
{
UWriteString(cmd); //Send Command
UWriteData(0x0D); //CR
uint8_t len=strlen(cmd);
len++; //Add 1 for trailing CR added to all commands
uint16_t i=0;
//Wait for echo
while(i<10*len)
{
if(UDataAvailable()<len)
{
i++;
_delay_ms(10);
continue;
}
else
{
//We got an echo
//Now check it
UReadBuffer(sim300_buffer,len); //Read serial Data
return SIM300_OK;
}
}
return SIM300_TIMEOUT;
}
Commands are usually followed by a response. The form of the response is like this<CR><LF><response><CR><LF>
LF is Line Feed whose ASCII Code is 0x0A (10 in decimal)
So after sending a command we need to wait for a response, three things can happen while waiting for a response :
- No response is received after waiting for a long time, reason can be that the SIM300 is not connected properly with the MCU.
- Response is received but not as expected, reason can be faulty serial line or incorrent baud rate setting or MCU is running at some other frequency than expected.
- Correct response is received.
Command String: "AT+CREG?"
Response:
<CR><LF>+CREG: <n>,<stat><CR><LF>
<CR><LF>OK<CR><LF>
So you can see the correct response is 20 bytes. So after sending command "AT+CREG?" we wait until we have received 20 bytes of data or certain amount of time has elapsed. The second condition is implemented to avoid the risk of hanging up if the sim300 module malfunctions. That means we do not keep waiting forever for response we simply throw error if SIM300 is taking too long to respond (this condition is called timeout)
If correct response is received we analyses variable <stat> to get the current network registration.
depending on current network registration status the value of stat can be
- 0 - not registered, SIM300 is not currently searching a new operator to register to
- 1 registered, home network
- 2 not registered, but SIM300 is currently searching a new operator to register to
- 3 registration denied
- 4 unknown
- 5 registered, roaming
int8_t SIM300GetNetStat()
{
//Send Command
SIM300Cmd("AT+CREG?");
//Now wait for response
uint16_t i=0;
//correct response is 20 byte long
//So wait until we have got 20 bytes
//in buffer.
while(i<10)
{
if(UDataAvailable()<20)
{
i++;
_delay_ms(10);
continue;
}
else
{
//We got a response that is 20 bytes long
//Now check it
UReadBuffer(sim300_buffer,20); //Read serial Data
if(sim300_buffer[11]=='1')
return SIM300_NW_REGISTERED_HOME;
else if(sim300_buffer[11]=='2')
return SIM300_NW_SEARCHING;
else if(sim300_buffer[11]=='5')
return SIM300_NW_REGISTED_ROAMING;
else
return SIM300_NW_ERROR;
}
}
//We waited so long but got no response
//So tell caller that we timed out
return SIM300_TIMEOUT;
}
Similarly we have implemented the following functions :-- int8_t SIM300IsSIMInserted()
To simplify handling of such commands we have made a function called SIM300WaitForResponse(uint16_t timeout)
This function waits for a response from SIM300 module (end of response is indicated by a CR), it returns the size if response received, while the actual response is copied to the global variable sim300_buffer[].
If no response is received before timeout it returns 0. Timeout in millisecond can be specified by the parameter timeout. It does not count the trailing LF or the last <CR><LF>OK<CR><LF>, they remain in the UART fifo queue. So before returning we call UFlushBuffer() to remove those from the queue.
Implementation of function SIM300WaitForResponse(uint16_t timeout)
int8_t SIM300WaitForResponse(uint16_t timeout)
{
uint8_t i=0;
uint16_t n=0;
while(1)
{
while (UDataAvailable()==0 && n<timeout){n++; _delay_ms(1);}
if(n==timeout)
return 0;
else
{
sim300_buffer[i]=UReadData();
if(sim300_buffer[i]==0x0D && i!=0)
return i+1;
else
i++;
}
}
}
Implementation of function SIM300GetProviderName(char *name) The function does the following :-
- Flush the USART buffer to get rid of any leftover response from the last command or errors.
- It send the command "AT+CSPN?" using SIM300Cmd("AT+CSPN?"); function call.
- Then it waits for a response using the function SIM300WaitForResponse()
- If we receive a response of non zero length we parse it to extract string describing the service provider name.
- If SIM300WaitForResponse() returns zero that means no valid response is received within specified time out period. In this case we also return SIM300_TIMEOUT.
- uint8_t SIM300GetProviderName(char *name)
- int8_t SIM300GetIMEI(char *emei)
- int8_t SIM300GetManufacturer(char *man_id)
- int8_t SIM300GetModel(char *model)
uint8_t SIM300GetProviderName(char *name)
{
UFlushBuffer();
//Send Command
SIM300Cmd("AT+CSPN?");
uint8_t len=SIM300WaitForResponse(1000);
if(len==0)
return SIM300_TIMEOUT;
char *start,*end;
start=strchr(sim300_buffer,'"');
start++;
end=strchr(start,'"');
*end='\0';
strcpy(name,start);
return strlen(name);
}
SIM300 and ATmega32 Hardware Setup
To run the basic demo showing communication with SIM300 using AVR ATmega32 we need the following circuit :-- ATmega32 Core circuit, including the reset register, ISP header, 16MHz crystal oscillator.
- Power Supply circuit to supply 5v to the ATmega32 and the LCD Module.
- A 16x2 Alphanumeric LCD Module to show programs output.
- SIM300 Module.
Fig. SIM300 and ATmega32 Schematic |
Fig. SIM300 and ATmega32 Connection |
Fig. SIM300's PINs |
Fig. xBoard's USART PINs |
Fig. GSM Module connected with ATmega32 |
NOTE
The board shown below is the new version of SIM300 Modem, it can also be used to make this project. New version is much smaller and low cost.Fig. SIM300 Module New Version |
Demo Source Code for AVR and SIM300 Interface
The demo source code is written in C language and compiled using free avr-gcc compiler using the latest Atmel Studio 6 IDE. The project is split into the following modules.- LCD Library
- Files lcd.c, lcd.h, myutils.h, custom_char.h
- Job is to control standard 16x2 LCD Module.
- More information on LCD library.
- USART Library
- Files usart.c,usart.h
- Job is to control the USART hardware of AVR MCU. Includes functions to initialize the USART, Send/Receive chars, Send/Receive Strings.
- SIM300 Library
- Files sim300.c, sim300.h
- Working with latest Atmel Studio 6 IDE.
- Create a new AS6 Project with name "Sim300Demo".
- Using solution explorer create a folder named "lib" in current folder.
- Inside the "lib" folder create the following sub folders "lcd", "usart" and "sim300".
- copy followings files to the lcd folder (using Windows File Manager) lcd.c, lcd.h, myutils.h, custom_char.h
- copy followings files to the usart folder (using Windows File Manager) usart.c,usart.h
- copy followings files to the sim300 folder (using Windows File Manager sim300.c, sim300.h
- Add the files lcd.c, lcd.h, myutils.h, custom_char.h to the project using solution explorer.
- Add the filesusart.c,usart.h to the project using solution explorer.
- Add the files sim300.c, sim300.h to the project using solution explorer.
- Define a symbol F_CPU=16000000 using AS6's
- in the main application file Sim300Demo.c copy paste the following demo program.
- Build the project to get the executable hex file.
- Burn this hex file to the xBoard using USB AVR Programmer.
- If you are using a new ATMega32 MCU from the market set the LOW FUSE as 0xFF and HIGH FUSE are 0xC9.
Fig.: Setting the Fuse bytes. |
/*
* Sim300Demo.c
*
* Created: 10-07-2012 PM 12:23:08
* Author: OMKAR
*/
#include <avr/io.h>
#include <util/delay.h>
#include "lib/lcd/lcd.h"
#include "lib/sim300/sim300.h"
void Halt();
int main(void)
{
//Initialize LCD Module
LCDInit(LS_NONE);
//Intro Message
LCDWriteString("SIM300 Demo !");
LCDWriteStringXY(0,1,"By Omkar Kirpan");
_delay_ms(1000);
LCDClear();
//Initialize SIM300 module
LCDWriteString("Initializing ...");
int8_t r= SIM300Init();
_delay_ms(1000);
//Check the status of initialization
switch(r)
{
case SIM300_OK:
LCDWriteStringXY(0,1,"OK !");
break;
case SIM300_TIMEOUT:
LCDWriteStringXY(0,1,"No response");
Halt();
case SIM300_INVALID_RESPONSE:
LCDWriteStringXY(0,1,"Inv response");
Halt();
case SIM300_FAIL:
LCDWriteStringXY(0,1,"Fail");
Halt();
default:
LCDWriteStringXY(0,1,"Unknown Error");
Halt();
}
_delay_ms(1000);
//IMEI No display
LCDClear();
char imei[16];
r=SIM300GetIMEI(imei);
if(r==SIM300_TIMEOUT)
{
LCDWriteString("Comm Error !");
Halt();
}
LCDWriteString("Device IMEI:");
LCDWriteStringXY(0,1,imei);
_delay_ms(1000);
//Manufacturer ID
LCDClear();
char man_id[48];
r=SIM300GetManufacturer(man_id);
if(r==SIM300_TIMEOUT)
{
LCDWriteString("Comm Error !");
Halt();
}
LCDWriteString("Manufacturer:");
LCDWriteStringXY(0,1,man_id);
_delay_ms(1000);
//Manufacturer ID
LCDClear();
char model[48];
r=SIM300GetModel(model);
if(r==SIM300_TIMEOUT)
{
LCDWriteString("Comm Error !");
Halt();
}
LCDWriteString("Model:");
LCDWriteStringXY(0,1,model);
_delay_ms(1000);
//Check Sim Card Presence
LCDClear();
LCDWriteString("Checking SIMCard");
_delay_ms(1000);
r=SIM300IsSIMInserted();
if (r==SIM300_SIM_NOT_PRESENT)
{
//Sim card is NOT present
LCDWriteStringXY(0,1,"No SIM Card !");
Halt();
}
else if(r==SIM300_TIMEOUT)
{
//Communication Error
LCDWriteStringXY(0,1,"Comm Error !");
Halt();
}
else if(r==SIM300_SIM_PRESENT)
{
//Sim card present
LCDWriteStringXY(0,1,"SIM Card Present");
_delay_ms(1000);
}
//Network search
LCDClear();
LCDWriteStringXY(0,0,"SearchingNetwork");
uint8_t nw_found=0;
uint16_t tries=0;
uint8_t x=0;
while(!nw_found)
{
r=SIM300GetNetStat();
if(r==SIM300_NW_SEARCHING)
{
LCDWriteStringXY(0,1,"%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0");
LCDWriteStringXY(x,1,"%1");
LCDGotoXY(17,1);
x++;
if(x==16) x=0;
_delay_ms(50);
tries++;
if(tries==600)
break;
}
else
break;
}
LCDClear();
if(r==SIM300_NW_REGISTERED_HOME)
{
LCDWriteString("Network Found");
}
else
{
LCDWriteString("Cant Connt to NW!");
Halt();
}
_delay_ms(1000);
LCDClear();
//Show Provider Name
char pname[32];
r=SIM300GetProviderName(pname);
if(r==0)
{
LCDWriteString("Comm Error !");
Halt();
}
LCDWriteString(pname);
_delay_ms(1000);
Halt();
}
void Halt()
{
while(1);
}
Subscribe to:
Posts (Atom)