Canon MP280 - Scanning at resolution 1200 dpi
Though 600 dpi is good enough to scan photos, for some of my coins which measured few millimeters, this is not enough.
From the specification of MP287, it is clear that it supports 1200 x 2400 dpi. So, I should be able to scan at 1200 dpi. After searching a lot, I found the answer.
The 1200 dpi option will be available only from the scan dialog of the driver - ScanGear.
For this
CUSAT exam result checker python script
Many times it is very time consuming task to go through each and every results. It becomes even difficult when we are checking the results of our friends or relatives and dose not know the exam dates or the semester.
I had to check results of my brother who is finishing his Engineering course from Cochin University(CUSAT) and all I had was his register number and not much information about when the exam was. So I made these python scripts.
There are two parts in this script. First one will read all results from CUSAT exam results page and form a dictionary with all the available results including the previous attempts and creates a pickle dump of the same. The next script will then read the pickle and generate a report.
In this script beautifulsoup4 library is used on Python 3+. Hence, it is necessary to install it first and then run.
Note: Before use, open the results page, and check whether internet connection is available and the results portal is not down.
You may download the scripts from here.
Below you may find snapshot of tool output for a random registration id.
-------------------------------------------------------------------------
| Sem | Subject | Marks | Results |
|------|----------------------------------------------|-------|---------|
| I&II | A101 ENGINEERING MATHEMATICS-I | 87 | Passed |
| I&II | A102 ENGINEERING PHYSICS | 82 | Passed |
| I&II | A103 ENGINEERING CHEMISTRY | 79 | Passed |
| I&II | A104 ENGINEERING MECHANICS | 77 | Passed |
| I&II | A105 ENGINEERING GRAPHICS | 79 | Passed |
| I&II | A106 BASIC CIVIL & MECHANICAL | 84 | Passed |
| I&II | A107 BASIC ELEC. ENGG. AND ELE | 76 | Passed |
| I&II | A108 COMPUTER PROGRAMMING | 90 | Passed |
| I&II | A109 TECHNICAL COMMUNICATION | 88 | Passed |
| I&II | A180 COMPUTER PROGRAMMING LAB | 86 | Passed |
| I&II | A190 ELE. & MECHA. WORKSHOPS | 80 | Passed |
| III | B101 ENGGN MATHEMATICS II | 83 | Passed |
| III | B102 ELECTRICAL TECHNOLOGY | 75 | Passed |
| III | B103 NETWORK THEORY | 62 | Failed |
| III | B104 DIGITAL ELECTRONICS | 79 | Passed |
| III | B105 SOLID STATE ELECTRONICS | 65 | Failed |
| III | B106 ELECTRONIC CIRCUITS - I | 65 | Failed |
| III | B180 BASIC ELECTRONICS - LAB | 51 | Passed |
| III | B190 ELECTRICAL MACHINES LAB | 70 | Passed |
| IV | C101 ENGINERING MATHEMATICS-II | 60 | Failed |
| IV | C102 MICROPROCESSORS | 75 | Passed |
| IV | C103 ELECTRONICS CIRCUITS II | 67 | Failed |
| IV | C104 SIGNALS AND SYSTEMS | 62 | Failed |
| IV | C105 ANALOG COMMUNICATION | 64 | Failed |
| IV | C106 INDUSTRIAL AND POWER ELEC | 52 | Failed |
| IV | C180 DIGITAL ELECTRONICS LABOR | 50 | Passed |
| IV | C190 ELECTRONIC CIRCUITS LAB - | 53 | Passed |
| V | D101 ENGINEERING MATHEMATICS I | 97 | Passed |
| V | D102 ELECTROMAGNETIC THEORY | 63 | Failed |
| V | D103 DIGITAL SYSTEM DESIGN | 77 | Passed |
| V | D104 ADVANCED MICROPROCESSORS | 79 | Passed |
| V | D105 MICRO ELECTRONICS & INTEG | 56 | Failed |
| V | D106 DIGITAL SIGNAL PROCESSING | 76 | Passed |
| V | D180 MICROPROCESSOR LABORATORY | 60 | Passed |
| V | D190 ELECTRONIC CIRCUITS LABO | 71 | Passed |
| VI | E101 DIGITAL COMMUNICATION | 55 | Failed |
| VI | E102 MICROWAVE TECHNIQUES & DE | 62 | Failed |
| VI | E103 VLSI DESIGN | 62 | Failed |
| VI | E104 ELECTRONIC MEASUREMENTS | 86 | Passed |
| VI | E105 CONTROL SYSTEMS ENGINEERI | 77 | Passed |
| VI | E106 EMBEDDED SYSTEMS | 78 | Passed |
| VI | E180 COMMUNICATION LABORATORY | 64 | Passed |
| VI | E190 MINI PROJECT | 95 | Passed |
| VII | F101 INDUSTRIAL ORGANIZATION& MANAGEMENT | 87 | Passed |
| VII | F102 RADIO COMMUNICATION | 77 | Passed |
| VII | F103 COMPUTER COMMUNICATIONAND NETWORKS | 80 | Passed |
| VII | F104 ELECTRONIC PRODUCT DESIGN | 82 | Passed |
| VII | F106 SIGNAL PROCESSING LABORATORY | 71 | Passed |
| VII | F107 COMMUNICATION LABORATORY II | 88 | Passed |
| VII | F108 SEMINAR | 37 | Passed |
| VII | F109 PROJECT DESIGN | 46 | Passed |
| VII | F150 INTELLIGENT SYSTEMS | 83 | Passed |
| VIII | G101 AUDIO AND VIDEO ENGINEERING | 86 | Passed |
| VIII | G102 COMMUNICATION SYSTEMS | 71 | Failed |
| VIII | G103 OPTO ELECTRONICS &COMMUNICATION; | 66 | Failed |
| VIII | G105 PROJECT WORK | 286 | Passed |
| VIII | G106 VIVA - VOCE | 81 | Passed |
| VIII | G140 DIGITAL IMAGE PROCESSING | 85 | Passed |
-------------------------------------------------------------------------
Uncleared Subjects
----------------------------------------------------------
| Sem | Atmpt | Subjects |
|------|--------|----------------------------------------|
| III | 5 | B103 NETWORK THEORY |
| III | 5 | B105 SOLID STATE ELECTRONICS |
| III | 5 | B106 ELECTRONIC CIRCUITS - I |
| IV | 6 | C101 ENGINERING MATHEMATICS-II |
| IV | 6 | C103 ELECTRONICS CIRCUITS II |
| IV | 6 | C104 SIGNALS AND SYSTEMS |
| IV | 6 | C105 ANALOG COMMUNICATION |
| IV | 6 | C106 INDUSTRIAL AND POWER ELEC |
| V | 6 | D102 ELECTROMAGNETIC THEORY |
| V | 6 | D105 MICRO ELECTRONICS & INTEG |
| VI | 6 | E101 DIGITAL COMMUNICATION |
| VI | 6 | E102 MICROWAVE TECHNIQUES & DE |
| VI | 6 | E103 VLSI DESIGN |
| VIII | 4 | G102 COMMUNICATION SYSTEMS |
| VIII | 4 | G103 OPTO ELECTRONICS &COMMUNICATION; |
----------------------------------------------------------
Semister summary
III 3
IV 5
V 2
VI 3
VIII 2
cnt 43
tot 3493
Total arriears: 15
Pass %: 54.578125
Running Google Cloud Messaging(GCM) XMPP server using python
Some days before, I was reading about some project about using pushover service and pebble along with Raspberry Pi to notify on a doorbell project. Idea of push notifications impressed me and I decided to try it out. However, the famous pushover service used for this purpose was not a free.
While searching for alternate services to send push notifications, I stumbled upon the android developers guide about GCM. So, I thought of using it on my raspberry Pi based hobby projects.
After finishing the android application, I started with server side and chose the XMPP since the upstream messages can be used for sending commands to Pi from android application. However, the Python sample code failed to run due to missing xmpp module. I thought the module must be a part of google's python sdk for cloud. However, the xmpp module from sdk did not even had client class used in the sample.
Then I thought of trying other libraries. sleekxmpp did not work too and later the xmpppy module give me successful result. So, the point is google is using the xmpppy for xmpp in the sample but it is not documented. Maybe it is known to may programmers with good experience progroamming in Python and these kind of libraries. I am writing it here so that if anyone else who is searching could benifit.
So, go ahead install xmpppy module and successfully run the python gcm xmpp server.
Transferring files between Windows and Raspberry Pi
Many times it is necessary to transfer files between Raspberry Pi and Windows Desktop. I use my desktop to write code for Pi because of the availability of editors which I am familiar with; also I am running Pi in headless mode(ie. without monitor). So it is necessary to pull files from Pi for editing and later push it back to Pi.
This possible by using either ftp, sftp or scp. This tool(WinSCP) is one of the easiest method which I found available to transfer files between Windows and Raspberry Pi. It also has options to sync files between both sides while we are busy coding and debugging using various editors on both sides.
Follow these steps
Generating .pem from .p12 for google cloud applications
openssl pkcs12 -in path/to/key.p12 -nodes -nocerts > path/to/key.pem
Raspberry Pi 2 on sale!!
I am very much impressed with the new design and surprised to know that even Microsoft supports it with the windows 10(Windows On Devices) for free(for those who Joins the Windows for their IoT Development program).
Though Microsoft supports it. I think this is their step to capture a share in the new market of Internet of Things like all giants are trying now. I am not sure yet how much it will be beneficial for the Open community.
Anyways, raspberry will still continue to grow as one of the first choice for enthusiasts and small business category of people due to it price $35. Old models are still available for the same price.
I have a Model B board which I use for some automation of fish tank and door bell now.
For me and this is the easiest option to do an embedded project because I am more comfortable with the programming part. Using a microcontroller will consume a lot of time for the initialization kind of stuff. Same project which can be made with Pi in an hour will take a week to do using a conventional microcontroller. Moreover, if we want to use WiFi/Ethernet connectivity it will cost further more time and money.
Below attached a video from the release page.
BCM2836 silicon bringup from Raspberry Pi Foundation on Vimeo.
Function pointers - The unconventional use
The unconventional use
Usually function pointer are used in callbacks or some special cases. But, we can use it also to simplify code. Consider the below example
void print_zero(void)
{
printf("Zero\n");
}
void print_one(void)
{
printf("One\n");
}
void print_two(void)
{
printf("Two\n");
}
void print_three(void)
{
printf("Three\n");
}
void print_four(void)
{
printf("Four\n");
}
void example_switch(void)
{
unsigned int number = 0;
switch(number)
{
case 0:
print_zero();
break;
case 1:
print_one();
break;
case 2:
print_two();
break;
case 3:
print_three();
break;
case 4:
print_four();
break;
default:
break;
}
}
The snippet above is nothing but calling few functions in a switch case. Using function pointers, it can be simplified as below.
void example_fPtr(void)
{
unsigned int number = 0;
void (*pFun[5])(void) = { /* Define and initialize function pointer */
print_zero, print_one, print_two, print_three, print_four
};
number = 4;
if(number < 5)
pFun[number](); /* Call function corresponding to number */
}
Function pointers - Simple use without confusion in C Programming
Good way to define function pointer
In an embedded project with different programs, pointer is of great use. For example, in an embedded project, one may want to do a soft reset. Which means nothing but jumping back to the starting address(most of the cases, the reset vector = address 0). In C program, this can be achieved by using a pointer, assign it to value 0 and call.
void (*pSoftReset)(void); /* Define a function pointer */
pSoftReset = (void (*)(void))0; /* Assign address 0 to pointer */
pSoftReset(); /* Function call using pointer */
In the above snippet, in line 1, a function pointer is defined. In line 2, pointer is initialized with address. Note the typecasting. 0 integer is typecast-ed to a function pointer with address value 0. Then, the function is called. It will never return as the initialization routines will initialize all the variables, stack etc.
The same code can also be written in single line as
((void (*)(void))0)(); /* Typecast address 0 to pointer and call */
Here integer is typecast-ed and called at the same time.
This function pointer definition, typecasting etc might be difficult to read for many. Because of this code may be less readable. To avoid this we may use the typedef functionality to define new types as below.
typedef void (*typFPtr)(void); /* Define new type typFPtr as pointer to a function */
typFPtr pSoftReset = (typFPtr)0; /* Assign address 0 */
pSoftReset(); /* Call using pointer */
In order to avoid confusion and improve readability, it is better to define new types and use it instead of directly using the function prototype. However, please note that this may also cause some confusion as the '*' is missing in declaration of variable and typecast. Alternately, it can also be done as below.
typedef void (typFN)(void); /* Define new type typFN as pointer to a function */
typFN *pSoftReset = (typFN *)0; /* Define pointer to function and Assign address 0 */
pSoftReset(); /* Call using pointer */
To conclude, definition and use of complex function pointers can be achieved by using typedef. Some examples are mentioned below.
/* Below definiton is a function pointer fp which
* will accept a pointer to a function which takes
* pointer to int as argument, returns void and
* another int as second parameter and returns a
* function pointer which takes int as argument
* and returns pointer to int */
int *(*((*fp)(void (*)(int*), int *)))(int);
/* Uning typedef it can be simplified as below */
typedef int *typFun_pint_int(int);
typedef void typFun_void_pint_int(int*);
typFun_pint_int * fp_simplified(typFun_void_pint_int *, int *);
/* Here it is clear what is the return type
and what are the arguments */
In my next post, I will list some examples of using function pointers. Initially, I thought of adding it here. But, it is too late for me now. So thought of writing it as another post.
Finding IMEI number if mobile is lost or stolen
So if you have any of the above options available, it is possible to obtain the IMEI number for reporting to the police. Below you can see my Xiaomi Redmi 1S's box with IMEI labels. I have masked it for privacy.
Lost my mobile for second time
Without wasting much time, I called the customer care center and requested for temporally blocking my mobile number which he accepted after verifying my personal details.
Now, the next thing is to inform police. However, from my previous experience, I was sure that they will not help much. Maximum they will do is nothing but issue acknowledge for lost mobile reporting. They says, the IMEI number is added to the tracking system and if someone use the mobile it can be tracked. But, still there is no information about my Sony xperia U which is in tracking system since two years. I have found the news here about arrest of person who used to modify IMEI. So what I think is, the people who steals the mobile would approach such people, change the IMEI and then either use it or resell. So, the tracking systems will not be able to find the mobile phone. Below line is from the news source.
Accused, who is a software engineer, was arrested and charged under the IT Act for using technology to change the unique IMEI number of mobile phones
Now, for getting a duplicate Sim-card also, acknowledge from police station is required. This is because, I have ported my number from Vodafone postpaid to BSNL prepaid. And for getting new sim for prepaid, acknowledge is must. Also I think it is necessary to report the loss to avoid any misuse/abuse of the device.
While searching the Bangalore police website, I found this website of Bangalore police. In the page, there is an option 'report lost'. A screenshot is pasted below.
For reporting, we will have to first search in their partner site Lost Click Found. If our mobile is not in the list, then it will give us option to reach this page(Police report of lost item) finally report to Bangalore City Police site. Here there are lot of categories. After submitting we will get option to download the acknowledgement. I have pasted screenshot of my acknowledge below.
Acknowledgement downloaded
However, in the form, there is no option to enter IMEI number. So, I mentioned in the comments column. Since, the IMEI number is not specifically asked, I have also personally went to the nearby police station and informed so that they will add the IMEI number for tracking.
Fluid width for facebook comment box
Usually, blog templates has fixed widths for most of the fields. But those who are using fluid layout may want the facebook comment box to be fluid too. Or those who does not know the width to be set can also try fluid width as it will fill the container. In blogger, filling the container will be nothing but taking the width of the side bar or body where the widget is placed.
Facebook comment box
If you dont want to generate, then it is also possible to just edit the existing code and change the part.
'data-width' to 100%
The width of the plugin. Either a pixel value or the literal
100%
for fluid width. The mobile version of the Comments plugin ignores the width parameter, and instead has a fluid width of 100%.
How much power does my USB project/device/phone consume?
Current reading of Arduino
Well I found this nice little device(seen in the image above) from Deals Extreme which is also very cheap. It shows the current and voltage of the USB device attached. All we have to do is add this device in between.
Some uses for this are
Note: If you want to buy one like this, you may search for USB power measurement or USB current measurement.
Voltage reading of Arduino
Pinguino on bread board
Now a days, there are lot of cheap options, if we want to do some hobby projects using micro-controllers. Arduino being one of the most popular which uses the self reprogramming feature to flash the new code, can be used even by people who does not know much about software or hardware programming.
Pinguino is an arduino like hardware and IDE for PIC microcontroller. Its software is Free and Open Source. And Pinguino boards are Open Hardware. It is very much similar to arduino with additional USB features supported by PIC microcontrollers. So it does not need a USB to RS232 converter chip in the hardware which must make the hardware cheaper. Below is the description of Pinguino as published in Pinguino website.
Pinguino is an Arduino-like electronics prototyping platform. It
supports different 8- and 32-bit ©Microchip microcontrollers, all with
built-in USB module (no FTDI chip !).
However, due to lack of popularity the Pinguino boards are difficult to find and costlier than that of the Arduino boards. Hence I decided to try it using a PIC18f2550 on bread board. It is very easy to construct as there is not much components. Firmware which is necessary to make the controller work with the Pinguino IDE is available at the Pinguino website. An image of final constructed circuit with an 8x8 led matrix display is below.
Pinguino comes with a USB Bootloader. This small program running
inside the microcontroller is responsible for transferring your
application from your PC to the microcontroller memory and handing over
the control to this program afterwards.
No programmer is needed(*), the microcontroller can be reprogrammed over USB with a PC.
Pinguino is an Integrated Development Environement (IDE) which gives
everyone the ability to write, compile and upload programs on a Pinguino
board.
Pinguino's Language is an Arduino-like or Arduino-influenced rather
than Arduino-compatible Language. Users can use the same keywords but
can not include Arduino's libraries in their code. Adapted libraries are
listed here.
It makes you write easily your application without spending hours learning pragma, configuration bits or command line compiler.
Following are steps to make it working.
I will soon add some posts on some of these stages since some problems might occur.