So you want to learn how to use Git…

Here are the best tutorials I’ve found for using git on windows and linux:

Start with a video tutorial on how to use github:  The Insider Guide to GitHub

Next, a guide to using git on windows: An Illustrated Guide to Git on Windows

And finally, learn to write good commit messages for yourself and fellow programmers: Writing good commit messages

BS2 & C#

So I found my Basic Stamp, a BS2, that came with a Boe-Bot I purchased several years ago.  I started looking for my old boe-bot code and thought I could setup a serial communication from a C# application to the chip.  Here’s what I came up with:

' {$STAMP BS2}
' {$PBASIC 2.5}
'page 253 for ir hookup
#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
T1200 CON 813
T2400 CON 396
T9600 CON 84
T19K2 CON 32
T38K4 CON 6
#ENDSELECT

Inverted CON $4000
Open CON $8000
Baud CON T9600 + Inverted

command VAR Byte

steps VAR Word
counter VAR Word
motor VAR Byte
speed VAR Byte

DEBUG "running"

DO
PULSOUT 12, 750
PULSOUT 13, 750
PULSOUT 14, 750
PULSOUT 15, 750

SERIN 16, Baud,[command]
SELECT command
CASE "m"
GOSUB motion
CASE ELSE
GOSUB default
ENDSELECT
PAUSE 20
LOOP

default:
SEROUT 16, Baud, ["n",0]
RETURN

motion:
' m motor speed steps
SERIN 16, Baud, [motor]
DEBUG motor
SERIN 16, Baud, [speed]
DEBUG speed
SERIN 16, Baud, [steps]
DEBUG steps

FOR counter = 1 TO steps
PULSOUT 12+motor, 650+speed
PAUSE 20
NEXT

RETURN

And with that code setup on the bot, I used this nice function in C# to send the orders to the servos connected to the bot.

private static SerialPort port = new SerialPort("COM4", 9600, Parity.None, 8, StopBits.One);
private static Queue toSend = new Queue();

private static void Main()
{
Console.WriteLine("Waiting for data...");
port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
port.Open();

Thread reader = new Thread(Read);
reader.IsBackground = true;
reader.Start();
motion(0,100,10); // run first servo counter-clockwise at full speed for 10 seconds
}


static void motion(byte motor, int speed, int seconds)
{
if (speed < -100) { speed = -100; } else if (speed > 100)
{
speed = 100;
}
double loop = (1.5 + 20 + 1.6) / 1000;
int pulses = (int)Math.Round(seconds / loop, 0);
lock (toSend)
{
toSend.Enqueue(Convert.ToByte('m'));
toSend.Enqueue(motor);
toSend.Enqueue((byte)(speed+100));
foreach (byte b in BitConverter.GetBytes(pulses))
toSend.Enqueue(b);
}
}


static void Read()
{
while (true)
{
if (toSend.Count > 0)
{
byte var = new byte();
lock (toSend)
{
var = toSend.Dequeue();
}
port.BaseStream.WriteByte(var);
}
Thread.Sleep(10);
}
}

Break time

Taking a break from working on mcsharp to concentrate on homework.  The release of revision-190 went well and we finally have some servers popping up on flist.  When I do get back into coding mcsharp, I plan on getting servers to communicate with one another.  This should help servers hosted by the same person to share banlists and rank lists to all of their servers (if desired).

The Linux flist heartbeat bug was fixed before I decided to take a break, so hopefully on the next release we will see even more mcsharp servers on flist.

Minecraft Part 3

So I’ve begun working with about four guys on the minecraft server they’ve started. It works well and it has a decent user base but it lacked in a few areas. Many users reported extremely high memory and processor usage from running the server and hosting a few maps.

I’ve started with recoding the level data to save ram, and it’s working.   Ram usage from my modifications fell from ~1-5 gigs to ~30-450 megs.  I’ve also improved CPU usage by decreasing the number of threads spawned by the server.

Minecraft Server Part 2 / Ripley Part 1

So… I don’t have a working server that I coded myself because I ran into trouble byte-reading the level files which are serialized custom java Level classes.  I’m thinking of just moving on to another project.

Maybe i’ll work on enhancements for ripley.  For anyone who doesn’t know, I found some source code on a lisp pastebin type site for some C#/Mono code called “Ripley”.  The code is designed to rip streaming music.  It is designed to work with the streams on sky.fm and one of its sister sites.  I want to add the option to select which songs you want to save.  I also would like to change them to mp3′s.  The stream is AAC.

I got redmine working on my home server, so that’s one project completed recently.

Minecraft server

I’m interested in starting a project for a mincraft server if the makers of the mcsharp server don’t release their source code. This will give me some experience with connection handling and managing multiple connections to a server.

www.minecraft.net

Beginning

This is the beginning of my blog. There is nothing before this point. I’ll probably keep things like new code ideas on here along with projects I’ll never finish.

Return top