Ryan's Rambling

Sunday, September 26, 2004

Byte Alignment Bites

We are so spoiled when developing for the Windows platform. It is polite enough to allow us to access mis-aligned data (data which is not aligned on machine word boundaries). I have been tinkering around with some ActiveSync code on a Compaq Aero and just finished getting a fresh reminder that non-aligned data can and does result in worse than sub-optimal performance.

In particular, the data exchange occurs within the GetPacket and SetPacket methods of the IReplObjHandler interface. This interface is implemented on both the desktop and the device. I have written the desktop bits in Delphi and the device bits are in Embedded Visual C++ 3.0. Normal thought processes suggest minizing the volume of data passing over the link (especially when it is serial 19200-56000). So, as is typical,I immediately packed the structures for all text content. Basically it is just a fixed header with a variable portion followed by one or more variable length property entities. This format permits me to send just about anything and is relatively robust except for the overhead associated with the property names travelling in each packet exchange. But that is getting a bit off topic (as I am permitted to at this time of night).

All was fine with marshalling the data on the desktop (where you can debug, have a good tool, etc.) but the ActiveSync connection would literally drop and there was nothing logged as to the failure other than a NAK (obscure at best). With some heavy injection of file based debug statements in the code in question I found that the system simply stopped when trying to access the second property header. For whatever reason as soon as I saw what was happening it just sort of turned on a light bulb for me (gotta love that on those rare instances). So, now the marshalling code does four byte alignment on strings that it passes along. It was quite easy since the data lengths were already being used so I was pretty lucky in terms of length of time to finding the bug and fixing it. Now I can get on with the rest of the tinkering.

So, the lesson, remember that all platforms are not created equal and you still need to know something about what is underneath. Happy coding.

Labels:

Friday, September 24, 2004

Some more links for ActiveSync

Well, I am back at poking about some Windows ActiveSync code again. The hunt for real-life-problem-solutions relating to ActiveSync are pretty hard to come by for some reason so anyone looking atdoing it really is starting from scratch (or nearly anyway). I have located another set of pages outlining in a very understandableformat,some insights on handing the ObjectNotify device function. Here is the relevant page and a link to the site map which has some more worthwhile information.

Here is another link but it is a bit more thin.

Labels:

Tuesday, September 21, 2004

Sun, Microsoft, and alliance in the same sentence

CNET news item successfully put all three together in a single sentence without including breach of contract. Who would have thought that could be a reasonable idea just a couple of years ago?

Tuesday, September 14, 2004

DiamondBack really moves some markers

The guys at Borland seem to have pulled out all the stops and implemented some of my most sought after capabilities. Specifically we have for ... in syntax (qc #6922), Multi-unit namespaces (i.e. real namespace support as we expect it) [Allen], and finally we will have function inlining support as well.

It does appear that Generics and.NET 2.0 support will be a post-release concern. Hopefully when the release comes out we will all remember that lots of positive movement has been achieved before we start complaining out the "other" new stuff we all wanted.

Thanks to Robert Love for blogging on these new features from BorCon.

Labels: ,

Monday, September 13, 2004

IntelliSense for WiX files

If you happen to be using/trying the XML based Windows installation tools known as WiX and have a copy of Visual Studio handy then you should have a peek at this blog for instructions on hooking up wxs file support. The Borland Delphi editor is not quite as robust and/or I have been unable to find a great method of getting the Borland code completion working reliably for this particular file type.

Wednesday, September 08, 2004

Great list of Delphi RSS feeds

Nick has put together a great list of Delphi related blogs. Check it out and add it to your reader.

Labels: ,