Stelios's Place
A place for thoughts and ideas
PicAxeLan
I got the SimpleLan (link) module to use with the PicAxe chips. This module is able to serve documents (HTML, XML, etc.) over HTTP to the clients. It can also send emails, send a UDP packet and receive a UDP packet. The interfacing is done through a simple serial connection (5V TTL) to the SeriIn and SerOut of the module.
The way this module works is by defining a set of variables which the PicAxe chip can read and write to. Those variables act a shared memory for the module and the chip to exchange data. An HTML page can display these variables or through a Web Form these variables can be changed by the user. Besides those variables (known as Web variables) there is a set for the email functions and a set for sending and receiving UDP packets.
Sample code:
Sending a UDP packet:
'
' Send a UDP message from SimpleLan.
' Maximun size of message is 64bytes.
'
high 1
main:
'
' Construct the message and send it to 192.168.2.1:22002
'
serout 2, t2400, ("!AT0WBM:This is PicAxe!", 13)
serout 2, t2400, ("!AT0WBI:192.168.2.1", 13)
serout 2, t2400, ("!AT0SB")
Sending an Email:
'
' Send an email message from SimpleLan.
' Maximun size of message and subject is 64bytes.
'
high 1
main:
'
' Construct the email and send it
'
serout 2, t2400, ("!AT0WET:my@home.add", 13)
serout 2, t2400, ("!AT0WEF:PicAxe@home.add", 13)
serout 2, t2400, ("!AT0WES:PicAxe Alert!", 13)
serout 2, t2400, ("!AT0WEC:This is PicAxe!", 13)
serout 2, t2400, ("!AT0WEV:smtp.home.add", 13)
serout 2, t2400, ("!AT0SM")
Simple HTML page to display a Web Variable:
<html>
<head>
<title>PicAxeLan - PicAxe & SimpleLAN</title>
</head>
The value of var05 is: <At_var05> <br>
</html>
Simple HTML Form page to update a Web Variable:
<html>
<head>
<title>PicAxeLan - PicAxe & SimpleLAN</title>
</head>
<form method="get" action="page2.htm">
Enter a value for Var: 05: <input name=�At_var05� type=�text� maxlength=�16�>
<input type="submit">
</form>
</html>
Simple UDP Server to receive messages from SimpleLan
#!/usr/bin/python
#
# Simple UDP server to test the SimpleLan UDP functions.
# by Stelios M.
#
# Import the modules we need
import socket, traceback
# Create the IP/Port bindings
host = ''
port = 22002
# Create a UDP socket and set it to Listen
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((host, port))
# Loop always
while 1:
try:
message, address = s.recvfrom(8192)
print "Got data from ", address
print "Data: ", message
except (KeyboardInterrupt, SystemExit):
raise
except:
traceback.print_exc()
Comments and suggestions are welcomed.
~steliosm