Skip to main content

Posts

Showing posts from December, 2012

Simple TCP client server sockets application using IPv6 and IPv6

So here is a pair of programs demonstrating the use of sockets on Linux. The server program is run first. Then whenever the client program is run, it connects to the server on the specified port and they both exchange strings and terminate. TCP is used over IPv4. Simple_tcpserver_ipv4.c: # include < stdio.h > # include < stdlib.h > # include < unistd.h > # include < string.h > # include < sys/types.h > # include < sys/socket.h > # include < netinet/in.h > # include < netdb.h > # include < arpa/inet.h > void error ( char * msg ) { perror ( msg ) ; exit ( 1 ) ; } int main ( int argc , char * argv [ ] ) { int sockfd , newsockfd , portno ; socklen_t clilen ; char buffer [ 256 ] ; struct sockaddr_in serv_addr , cli_addr ; int n ; if ( argc < 2 ) { fprintf ( stderr , " Usage: %s \n " , argv [ 0 ] ) ; exit ( 0 ) ; } ...

Script for uploading DHT11 readings to Cosm using Curl/JSON on Raspberry Pi running Arch Linux

Earlier, I have written on how to get the Vodafone 3G USB Modem (K3770-Z) working on Raspberry Pi here . After I was done doing that, I decided to create a shell script to upload sensor data from DHT11 to cosm.com over the internet connection provided by the Vodafone 3G USB Modem. Here are is how I got that done: NOTE:  Execute all commands on Raspberry Pi unless otherwise specified. I referred to the following two Adafruit tutorials while doing this:  DHT Humidity Sensing on Raspberry Pi with GDocs Logging and  end Raspberry Pi Data to COSM Assemble the setup as shown in the photo above and follow the instructions here (Getting Vodafone 3G to work on Raspberry Pi in India using K3770-Z)  to get the Vodafone 3G USB Modem working on your Raspberry Pi. I use the Arch Linux distribution. Make sure to create sakis3g.conf to automate the Sakis3G script. Also ensure that the sakis3g script is in your root's home directory (/root) and has the execute...

Visio and Word files misbehaving with GitHub

All GitHub repositories are initialized with a default .gitattributes file which has the following configuration to handle Microsoft Word files: *.doc diff=astextplain *.DOC diff=astextplain *.docx diff=astextplain *.DOCX diff=astextplain This configuration works fine as long as the Word files in your repositories have only text and tables. The moment you try to commit Word files with images embedded in them or Microsoft Visio files, the line ending conversion and diff applied to them by Git will probably corrupt them. The files will open properly on your computer, but if you try to clone the repository on a different computer and try to open those files you will probably encounter the following messages: Corrupted Microsoft Word file: The file cannot be opened because there are problems with the contents Corrupted Microsoft Visio file: An error (100) occurred during the action Open File. Visio cannot open the file because it's not a Visio file or it has...

Getting Vodafone 3G to work on Raspberry Pi in India using K3770-Z

I live in Pune, India and I wanted to do this:  DHT Humidity Sensing on Raspberry Pi with GDocs Logging So I assembled this: and faced two problems:  I couldn't immediately figure out how to get K3770-Z to work on Raspberry Pi. Since this K3770-Z 3G USB Modem from Vodafone worked on Ubuntu 12.10 x86 without requiring any installation or configuration, I was sure that I could somehow get it to work on Raspberry Pi When I finally did get the modem to work on RPi, I found that the iBall Portable Charger ( Datasheet here ) could not source the peak current requirements of the modem when it turns on registers to the 3G network. The charger can supply only 600mA @ 5V where as the 3G modem definitely requires a lot more during registration. The second problem can be solved simply by using a 12V 2.2Ah Sealed Lead Acid Battery  and a 12V to 5V DC-DC converter. For the conversion you could use the car accessory for charging phones or build one yoursel...