Boy, Dog, Source Code

This blog entry is taking care of business. The picture has nothing to do with the blog entry. The pic is of a boy on the fast ferry to one of the out islands in this island paradise. It was his birthday, and he got the puppy for his birthday. The Lovely One and I were enchanted with this little boy, and the obvious love that he had for the puppy.

When I first started writing this blog, I said that I might post some source code. This is my first source code posting. I am putting it up as a thank you for all of the other code snippets that I personally have benfited from, that my fellow geeks posted on the web.

Writing this was particularly time consuming because Google doesn't return any obvious results for find out (using Visual Studio 2008 professional), C#, Windows Mobile SDK for Smart Devices and such. Normally I program in C++, but I had to use C# to integrate with other C# code that was written for this project.

Okay, what happens is that the device accumulates data, and I have to send this data over the network using ftp. If I went directly to connect to the server, and the server was not up, then the application would lock waiting for the timeout on the ftp side. The lock was intentional, because I did not want other threads operating on the file that I was going to upload. Since the timeout is real long, I would like to collect data in the meantime. To avoid this, before I try to connect to the FTP server, I want to see if it is alive. WindowsCE does not have the ping function built in.

I do this in a method shown below that requires a custom packet class to send to the ftp server. If the server responds, Bob's yer uncle. I don't bother processing the response. The code is quite simple, and if you need explanation, use the comments.


///////////////////// *********** Check out (ftp) Server
///
/// checkOutServer
///

/// returns a boolean to indicated that a successful ping was returned
/// due to the lack of a ping utility in WindowsCE, I had to put one together.
/// Essentially, I have a custom ICMP class (see below) which generates a packet
/// to send to the server. I send the packet to the server, and if the server
/// responds, I set a boolean to true and return it, indicating that the ftp server
/// is alive.


public bool checkOutServer()
{
bool fsf = false;
byte[] data = new byte[1024];
int recv;
Socket host = new Socket(AddressFamily.InterNetwork, SocketType.Raw,
ProtocolType.Icmp);
IPEndPoint iep = new IPEndPoint(IPAddress.Parse("put in IP address string"), 0);
EndPoint ep = (EndPoint)iep;
ICMP packet = new ICMP();
packet.Type = 0x08;
packet.Code = 0x00;
packet.Checksum = 0;
Buffer.BlockCopy(BitConverter.GetBytes((short)1), 0, packet.Message, 0, 2);
Buffer.BlockCopy(BitConverter.GetBytes((short)1), 0, packet.Message, 2, 2);
data = Encoding.ASCII.GetBytes("test packet");
Buffer.BlockCopy(data, 0, packet.Message, 4, data.Length);
packet.MessageSize = data.Length + 4;
int packetsize = packet.MessageSize + 4;
UInt16 chcksum = packet.getChecksum();
packet.Checksum = chcksum;
host.SendTo(packet.getBytes(), packetsize, SocketFlags.None, iep);
try
{
data = new byte[1024];
recv = host.ReceiveFrom(data, ref ep);
ftpServerIsAlive = true;
host.Close();
return ftpServerIsAlive;
}
catch (SocketException bb)
{
string conn = bb.Message;


//I have to invoke a delegate because this is run in a separate


//thread that does not have access to the Form
this.Invoke(new textStatusDelegate(textStatus), new Object[] { conn });
ftpServerIsAlive = false;
return fsf;
}
}
} //public partial class





//this is the classfile that creates the packet to send out to the server
class ICMP
{
public byte Type;
public byte Code;
public UInt16 Checksum;
public int MessageSize;
public byte[] Message = new byte[1024];
public ICMP()
{
}
public ICMP(byte[] data, int size)
{
Type = data[20];
Code = data[21];
Checksum = BitConverter.ToUInt16(data, 22);
MessageSize = size - 24;
Buffer.BlockCopy(data, 24, Message, 0, MessageSize);
}
public byte[] getBytes()
{
byte[] data = new byte[MessageSize + 9];
Buffer.BlockCopy(BitConverter.GetBytes(Type), 0, data, 0, 1);
Buffer.BlockCopy(BitConverter.GetBytes(Code), 0, data, 1, 1);
Buffer.BlockCopy(BitConverter.GetBytes(Checksum), 0, data, 2, 2);
Buffer.BlockCopy(Message, 0, data, 4, MessageSize);
return data;
}
public UInt16 getChecksum()
{
UInt32 chcksm = 0;
byte[] data = getBytes();
int packetsize = MessageSize + 8;
int index = 0;
while (index < color="#336666">Convert.ToUInt32(BitConverter.ToUInt16(data, index));
index += 2;
}
chcksm = (chcksm >> 16) + (chcksm & 0xffff);
chcksm += (chcksm >> 16);
return (UInt16)(~chcksm);
}
}
}

Invitation


This says it all. This is the culmination of all of my efforts in this Caribbean Country. The Lovely One was a full partner in the effort. Without her, we wouldn't have branded and marketed the product. It is a tense, busy time until Monday, but it will be a new day for us, and for this country. This is a significant time in my life.

Woven Palm Tree Trunk

I have been incredibly busy. Our product launches on Monday and I am doing a million and one different things. But the marvels of nature can still stop me in my tracks. One of those marvels, is this "woven" palm tree trunk.

Most palm trees have a relatively smooth trunk. This one has leaves that ... well ... interleave and give the woven appearance. Some of these have just a bit of the trunk near the top with the interwoven part, and other species are interwoven all the way down.

The most amazing thing is the palm matting underneath. You can just barely see it in the pics. It is woven like a fabric. I examined the matting closely and the design is incredibly intricate. You see outdoor mats made of it. It grows sort of woven, and it is a tough fabric, essentially of wood. I use pieces of it to start the barbeque (real charcoal briquets).

These types of palm trees do not make edible coconuts.

Garbage Garden


Since there are no real seasons in this tropical paradise, and some plants actually grow better in December, I decided to plant stuff -- a garden if you will. However it has a twist. Everything that I have planted comes from the garbage.

I have gotten the big pit of a mango to sprout before. However, I did it indoors as a house plant. Mangos were on sale at the supermarket, and the Lovely One bought a pile of them. After I peeled them, and diced the fruit, I stuck the pits halfway into the ground in the flower beds on the patio. They have been there for a week or two. The tops dried out, and they didn't seem to be doing much of anything, but as of late, they seem to be bulging. Since they are showing signs of wanting to sprout, I decided to start watering them.

The next experiment was growing pineapples. I had grown pineapples as houseplants. It is quite easy. When you buy a pineapple at the store, cut the leafy head off. Peel off all of the fruit from the top and stick the head into moist soil. Soon it roots and grows. I planted about six of these so far, and it looks like two have took. The jury is still out on the others.

The third thing that has sprouted so far, is watermelon. I take my watermelon outside, and as I am eating it, I pitch the seeds into the flower bed. I was surprised to see the seedlings pop up. I am hoping for a whole crop of watermelon.

Gardening with seeds from the garbage is fun. For good measure, I went a little overboard and threw out all kinds of seeds, including those from barbados cherry, meyer lemon, tamarind, cuban orange, oranges, dillies, Caimito, and star apple. I expect to open my own fruit stand or supermarket for fruit in a few months. I may have to wait a bit longer for the ones that grow one from trees -- which come to think of it, is most of the stuff I planted.

Celebrity Singer Encounters

I have led a fairly quiet life up until now. However by moving to the Caribbean, I have moved to the playground of the rich and famous. Never mind that most of them are here because this country is a tax haven. And we do get over 300 days of sunshine a year. However, personally I have had many celebrity encounters, and some celebrity singer encounters.

The first one was sitting in first class next to the singer Shakira. She talked to me, and she is a gregarious beautiful woman. Even the pilot came out to have a peek at her, and when I was debarking the plane, he playfully punched me in the shoulder with a "you lucky dawg" gesture. I came home all excited and told the Lovely One over dinner in a restaurant, that I sat next to Shakira. The Lovely One looked at me blankly. She didn't know who Shakira was. I called the waiter over, and told him that I had just sat next to Shakira in an airplane, and the guy went nuts with excitement. Now I get reproachful looks when I hum "Shakira Shakira" (the song) under my breath.

The next encounter came with Kid Rock. I detail that encounter in an earlier blog entry. Kid had no problem jumping into my arms when I asked him for a photo opportunity.

And night before last was Sheila Raye Charles. She is the daughter of singing great Ray Charles. She was starring at the Jazz Festival. It was a lovely intimate venue on the water at the harbour. The Lovely One and I dined through the starlit evening listening to jazz. Then Sheila Raye came singing through the crowd and picked me to dance with her. After the show, she gave me a hug as we were leaving the venue.

On the celebrity side, at the invitational I have met several sports celebrities including the greats of baseball (Ozzie Smith stands out as a gentleman), basketball (Dr. J. -- Julius Irving. I also lost my respect for Michael Jordan), football (Michael Jenkins of the Falcons is a real good guy), hockey (Mario Lemieux stands out -- literally -- I didn't expect him to be that tall) and movie stars (some were snotty like Alan Thicke) and media people (Stone Philips of NBC Dateline) who walked off the golf course. All in all, many sports celebrities have distasteful traits, but all of the singers that I have met, have time for the fans.

This is all a major change for me, because for many years my life was incredibly dull. Not so in this small Caribbean country.

Island Bedrock

In the previous blog entry about the ancient Lucayan tool that I found, I was struck by a line in the historical intrepretive sign that I saw in the national park. The sign said that the Arawak and Lucayan Indians were forced to use coral, because they didn't have access to hard rocks.

When I got to thinking about it, it was strange to me. I come from a country were rock cuts are common, and the very hard metamorphic and igneous rocks are common. They make up the hills that we live in, and every road has a rock cut every few miles. But these islands are made of limestone -- dead coral reefs. This limestone bubbles when you drop some vinegar on it. It is just like the scales in your kettle, except a lot more of it.

There are two types of limestone bedrock. The first is dead coral reefs. The second is beach rock made from centuries of beach sand being compacted by the waves. I read somewhere that most of the sand on the beach is made by fishes such as parrotfish, who chomp on the limestone coral and excrete sand. They have been doing this for thousands of years, and when you combine the action of the waves, you get the beautiful sand beaches.

But as for the island, every once and a while you can see the bedrock of limestone. There isn't much soil, so you don't have to dig far. Plants can grow in the cracks of the limestone nicely (see inset). And when it is cut for a road, you can see the pattern (main picture) of limestone being laid down over the centuries. Yet chip a small piece off and throw it in vinegar and it dissolves. Thank goodness that the oceans are not made of vinegar, otherwise we would be in a real pickle.

Study in Blue


Summer has arrived in the Caribbean. It is now hot. But the ocean has lost its rage and the water has turned transparent crystal turquoise. It is beautiful. However there is a flip side to this. We are now in hurricane season until November.

This is also the rainy season. We have hot hot days, and then at eventide, the clouds gather and we have a tropical outburst of water from the heavens. It is an interesting sensation to have warm warm rain on your body.

But it wasn't raining on a beautiful Sunday when the Lovely One and I went to the beach. She was wearing her robin blue bathing suit, and a matching sun bonnet in the summery shades of ocean blue as well. And the ocean provided the rest of the blues in the palette.

When I composed this picture in the view finder of the camera, I thought of Thomas Gainsborough's Blue Boy painting. Some say that it was done to prove that an artist couldn't successfully execute a painting whose main colour is blue. Well this isn't Blue Boy, but rather Blue Girl. And I think that it is a much better image than Blue Boy.

RFID

Picture above are the "guts" of an RFID tag. RFID stands for Radio Frequency IDentification. The etched lines are the "antenna" that picks up the radio signal and it is carried to the chip in the left middle. This is usually embedded in a card, although it can be in a key fob or a cylinder or a tag.

After our money card is fully deployed, many many businesses here in the Caribbean are clamouring for our technology and applications. These range from large stores, to the airport, to the laundromats. The businessmen owning these entities want to take the cash out of the system, because of "leakages". It seems that I have become an RFID subject matter expert just in time.

I read in the New York Times, that a large fashion store in Europe has deployed RFID technology for the fashion illiterate like myself. If you are comtemplating buying a shirt and a pair of pants for example, you pass the attached tags of both items of clothing, and the system will tell you whether or not the two items go together in a fashion sense.

Right now, all suppliers to stores like WalMart must tag their deliveries with RFID. Some RFID tags can be scanned from six feet or two meters away. This will aid in things like luggage control, and courier deliveries.

The field is wide open for this technology, limited only by our imaginations, and it is gratifying to be on the cutting edge. I took the above photo on the boardroom table of our offices.

Go Fish

When I was showing the Lovely One my photos, she stopped at this picture ans said that there was something wrong. Obviously the picture was damaged or I had a malfunction. Somehow the fish's face was cut off. In fact, this is one weird fish of the ocean. It is called a LookDown Pompano. It is a fast swimmer. The fish is laterally compressed, meaning that it is awfully thin when it is facing you.

Fish have been front and foremost again, because I have started to spearfish after a fairly long absence. The other day, I got a wonderful Porgy and the Lovely One and I ate it for dinner. It was delicious. The Porgy is a type of ocean perch. It's flesh is exceeding white, fine and flavorful. There wasn't a lot of bones at all. Unfortunately, the batteries of my camera were not charged, so I don't have a pic of it.

When I got home, I was looking for ways to cook it. I came across a Food Network recipe called Porgy Roman Style or Pagro Alla Romano. I used that as a starting point and modified the recipe. I browned the outside of the fish in olive oil, garlic and onions and then added a can of diced tomatoes and Italian spices. I transferred it to a baking dish and threw in some olives, capers and covered it with grated peccorino cheese. I baked it for 45 minutes until the fish was completely cooked.

Usually the Lovely One dislikes me shooting fish on my favorite reef. But after tasting my version of Porgy, I have the green light to bring home all of the porgy that I can get. Now, I would be set if I could find a recipe for jellyfish. Perhaps on toast. Hmmm. Gotta run to the kitchen.

4 Sale

These are the steps down from our favorite restaurant. It is an open air balcony overlooking the sea. On a lazy hazy Sunday afternoon, the Lovely One and I go there for a leisurely late lunch. They serve incredibly tasty food, and the ingredients are fresh. For example, once I had an fantastic roast beef sandwich in a flatbread wrap with a mouth-watering dipping jus, and a basalmic fresh baby greens and yellow pepper salad. Another time, it was shrimp on skewers with arugula salad.

The place is also a bed and breakfast. The walls have black and white pictures of the island from 50 and 60 years ago. The interior is tastefully decorated in faux antiques. The establishment looks like it has been there for a hundred years, but it is only a few years old. Because it is built on a hill, it looks like a European fortress when you approach it, with doors that look like castle doors near a moat. When you go through the doors, you climb up stairs carved in limestone. It is an incredibly charming place.

We wandered through the bed and breakfast part of the building. The bedrooms have balconies overlooking the sea. The balconies are private. Each balcony has a bed on it, so that you can sleep in the outdoor air, with the tang of the ocean and sound of the surf providing a lullaby for sleep. The Lovely One and I decided that we would go there for a weekend some day.

Last week, I was flipping through a local tabloid, and I came across the real estate ads. There was our favorite restaurant offered for sale. I showed it to the Lovely One. She was dismayed for two reasons. The first was that "our" place was for sale. The second was the asking price. They wanted $4.5 million dollars.