Posted 04 January 2013 - 10:00 PM
I wrote a primitive python server/script that lets you send/receive data from a CC computer to COSM, and also your computer's serial port. COSM is an online data feed service for internet enabled devices.
It works by taking the URL from a HTTP GET request and cutting out the main server directory. For example, if you request www.example.com/i101 it will send the data "101" to the COSM feed using your server at example.com.
This lets you easily control "things" inside minecraft from anything connected to the internet: PCs, cellphones, hacked routers (OPENWRT), even that 'arduino' thing (I program in ASM, but I hear it works with COSM). Big red buttons sound fun.
You can also control things outside minecraft from inside the game. Want to get an SMS when your powerplant is heating up? Control blinkenlights? Just requires a little engineering.
Oh, and license = public domain. You can do anything with it except claim you wrote it.
To set it up:
Download Python 2.7.
Use IDLE to open the script.
Add your COSM username, password, feed, and API key. If you don't have one, register for one.
Add the COM port for your serial port (or /dev/tty for linux, see pyserial docs)
Set your serial baud rate
Change the port (default 4242) if you like
Run it
Install dependencies if it doesn't run (google is your friend, or use Linux)
Python dependencies are:
BaseHTTPServer
cgi, sys
eeml
time
csv
urllib2
serial
decimal
If you use windows, I think you'll need:
lxml (2.3 or higher)
libxml2
libxslt
Here is how to use it:
send a HTTP GET with http://[server IP:port number]/[command][data]
–>Server IP is the IP address of the server running the script. If it's the same machine that is hosting minecraft, you can use 127.0.0.1
–>Port number is the port the script is configured to use, default is 4242
–>Commands are: i (input), o (output), s (serial port send), r (serial port receive). COSM commands have a latency of around 8 seconds. Serial commands are faster.
–>The data field is what you're actually performing the command on. Valid data is different for each command:
Input: Enter the address to read from on COSM. For example, for address 42…. http://127.0.0.1:4242/i42
Output: Enter the target address, followed by the data… http://127.0.0.1:4242/o42your_data. Strings, numbers, and some punctuation is supported.
Serial send: Enter the data to send. Must be a number 0-255… http://127.0.0.1:4242/s42
Serial receive: No parameters. Converts all ASCII to numbers, so receiving '~' will get you the number 126… http://127.0.0.1:4242/r
So far I have a real life voltmeter I can read from inside minecraft.
Enjoy!
It works by taking the URL from a HTTP GET request and cutting out the main server directory. For example, if you request www.example.com/i101 it will send the data "101" to the COSM feed using your server at example.com.
This lets you easily control "things" inside minecraft from anything connected to the internet: PCs, cellphones, hacked routers (OPENWRT), even that 'arduino' thing (I program in ASM, but I hear it works with COSM). Big red buttons sound fun.
You can also control things outside minecraft from inside the game. Want to get an SMS when your powerplant is heating up? Control blinkenlights? Just requires a little engineering.
Oh, and license = public domain. You can do anything with it except claim you wrote it.
To set it up:
Download Python 2.7.
Use IDLE to open the script.
Add your COSM username, password, feed, and API key. If you don't have one, register for one.
Add the COM port for your serial port (or /dev/tty for linux, see pyserial docs)
Set your serial baud rate
Change the port (default 4242) if you like
Run it
Install dependencies if it doesn't run (google is your friend, or use Linux)
Python dependencies are:
BaseHTTPServer
cgi, sys
eeml
time
csv
urllib2
serial
decimal
If you use windows, I think you'll need:
lxml (2.3 or higher)
libxml2
libxslt
Here is how to use it:
send a HTTP GET with http://[server IP:port number]/[command][data]
–>Server IP is the IP address of the server running the script. If it's the same machine that is hosting minecraft, you can use 127.0.0.1
–>Port number is the port the script is configured to use, default is 4242
–>Commands are: i (input), o (output), s (serial port send), r (serial port receive). COSM commands have a latency of around 8 seconds. Serial commands are faster.
–>The data field is what you're actually performing the command on. Valid data is different for each command:
Input: Enter the address to read from on COSM. For example, for address 42…. http://127.0.0.1:4242/i42
Output: Enter the target address, followed by the data… http://127.0.0.1:4242/o42your_data. Strings, numbers, and some punctuation is supported.
Serial send: Enter the data to send. Must be a number 0-255… http://127.0.0.1:4242/s42
Serial receive: No parameters. Converts all ASCII to numbers, so receiving '~' will get you the number 126… http://127.0.0.1:4242/r
So far I have a real life voltmeter I can read from inside minecraft.
Enjoy!