Τρίτη 4 Δεκεμβρίου 2012

Using Python and MQTT on a Rasberry Pi

Mosquitto Mosquitto (mosquitto.org) is an open source message broker that implements the MQ Telemetry Transport protocol. MQTT (mqtt.org) privides a lightweight method of carrying out messaging using a publish/subscribe model. More about the MQTT protocol you can read at http://mosquitto.org/man/mqtt-7.html


After installing mosquitto 1.0.5 on my rasberry pi  I wrote the following two python scripts to experiment myself.

The code is shown below and it is self explanatory:

mosqsrv.py

#!/usr/bin/python

import mosquitto

#define what happens after connection
def on_connect (mosq, obj, rc):
        if rc==0:
                print "connected"

#On receipt of a message create a message
def on_message(mosq, obj, msg):
        print msg.topic+', '+msg.payload

#create a roker
mqttc = mosquitto.Mosquitto("python_sub")

#define the callbacks
mqttc.on_connect = on_connect
mqttc.on_message = on_message

#connect
mqttc.connect("localhost", 1883, 60)

#subscribe to topic test
mqttc.subscribe("test", 0)

#keep connected to broker
while mqttc.loop()==0:
        pass


mosqcl.py

#!/usr/bin/python

import mosquitto

#define what happens after connection
def on_connect (mosq, obj, rc):
        print("connected")

#create a broker
mqttc = mosquitto.Mosquitto("python_test")

#connect
mqttc.connect("192.168.1.105",1883, 60)

#publish to broker
mqttc.publish("test", "hello world!", 1)

mqttc.disconnect()

To test it I run mosquitto broker from the command line after editing the mosquitto.conf file to define the run user.




Τρίτη 27 Νοεμβρίου 2012

HP Photosmart C7200 "ink system failure fix"

Follow the following procedure before you buy a new one!
1. Press and hold key '*'
2. Press the '#' and release both keys
3. Press and release in sequence the '1','2' and '3' buttons
4. Press and release the right arrow until the display says "system configuration menu"
5. Press and release the "ok" button
6. Display should say "Hardware failure status". Press and release the "ok" button.
7. Press and release the cancel button as many times needed until the main menu appears
8. Turn off the unit and unplug the power cable for 30secs
9. Turn the unit on

Hopefully you should be backup and running!

Σάββατο 18 Αυγούστου 2012

Raspberry Pi Crude Benchmark

I created a very crude calculation benchmark to compare Raspberry-Pi against Alix and MicroClient Jr, calculating PI to 2000 decimal places:

time echo "scale=2000;4*a(1)" | bc -l

Here are the results:

Raspberry-Pi : 0m25.210s
Alix: 0m42.063s
MicroClient Jr: 1m32.134s

Παρασκευή 17 Αυγούστου 2012

/etc/apt/sources.list -- Lenny

Now that Lenny has been archived, you will need to update your /etc/apt/sources.list file. It should now look like this:

CODE: SELECT ALL
deb http://archive.debian.org/debian lenny main
deb http://archive.debian.org/debian-security lenny/updates main
deb http://archive.debian.org/debian-volatile lenny/volatile main
deb http://archive.debian.org/backports.org lenny-backports main

That'll keep you going for a few more years! . 


My Little Raspberry Pi

I just received my tiny Raspberry Pi (http://www.raspberrypi.org/). An ARM/Linux box for embedded linux projects for just 25$. Some projects to work on:



The Raspberry Pi® is a single-board computer developed in the UK by the Raspberry Pi Foundation with the intention of stimulating the teaching of basic computer science in schools. The design is based on a Broadcom BCM2835 system on a chip (SoC), which includes an ARM1176JZF-S 700 MHz processor, VideoCore IV GPU, and 256 megabytes of RAM. The design does not include a built-in hard disk or solid-state drive, instead relying on an SD card for booting and long-term storage. The Foundation plans to support Fedora Linux as the initial system software package/distribution, with support for Debian and Arch Linux as well -Wikipedia.

Σάββατο 4 Αυγούστου 2012

Debian - Free up some disk space

Just recently, I ran out of disk space and the lcd panel stopped working. The OWWUPDATE couldn't be updated and it was always null. How do you avoid this problem? 

clean up log files
rm /var/log/*.gz
rm /var/log/*.old
rm /var/log/*.1
rm /var/log/*.2


clear the apt-get cache. The apt's cache is never cleaned out. Apt caches all the .deb files and that can quickly eat your disc space. To clear it:

apt-get clean

Σάββατο 24 Σεπτεμβρίου 2011

SIOCDELRT: No such process - SOLVED

first off you need to edit your /etc/hosts file * use vi

Code:
vi /etc/hosts
add your ip address and your name at line three

Code:
127.0.0.1    localhost    linux
#127.0.1.1    linux.WorkGroup    linux
192.168.20.20    voyage # <------ add your ip and name 


then restart your network and the error is fixed, the edited /etc/host file is also need for the static changes you made