Older blog entries for MichaelCrawford (starting at number 47)

Predictions of Snow

By noon or so tomorrow I need to deliver a build of my embedded application that my client intends to demo in his booth at the MacWorld Expo next week.

But a foot of snow is expect to start falling at midnight tonight. I'm concerned about losing power.

We were more concerned about being stuck in the house without any food so we went to the grocery store to stock up. Apparently the entire town had the same idea, the place was packed.

Whenever there's a particularly bad snowstorm we can't get out for the next day because it takes that long for the plow man to make it to our lane. It's just because it takes him so much longer to plow each of his customers.

Some happy news, in a couple days I will be able to tell you what the embedded product is I've been working on. If you will be attending MacWorld, you could go see it demonstrated at my client's booth.

ZooLib

My application requires a small user interface on the host computer it's attached to. I am using ZooLib to do the UI. Since CodeWarrior 6 doesn't work so well on OS X and I don't have time to purchase the update, I tried using Project Builder. But ZooLib wasn't happy with Project Builder.

I am managing to use CodeWarrior for this task but I'd really like for ZooLib to support Project Builder. So next week I'm going to fix the problems.

I had a problem that I'm pretty sure is a bug in Project Builder. After I posted to a Mac programmer's newsgroup someone from Apple wrote to ask if he could help. Tomorrow I'm going to send him my project and my sources.

I had a long talk with Andy Green last night, and we've decided to make the push for a new ZooLib release soon. Basically as soon as all the existing demo code will build and run cleanly in all the target compilers.

I'm also going to try again to get ZooLib to build on Windows under MingW. That would allow one to build ZooLib on all the supported platforms for which gcc is available using gcc. Classic Mac OS doesn't have gcc but you could build a carbon app under OS X using gcc and run it on Systems 8 or 9.

My New Year's Resolution

Is to finish writing The ZooLib Cookbook by the end of the year. (It is under the GNU Free Documentation License.)

More generally, I want to stop letting my economic troubles prevent me from finding the time to do all the things I want to do. If I write just a little bit each week. I should be able to finish the book in a year no matter how busy things get.

There is other writing I want to do too, and I want to finish grinding my telescope mirror. I should be able to find the time to do all that.

I corresponded with a technical publisher about the possibility of them publishing a dead-tree edition of The ZooLib Cookbook. They were interested, but they didn't feel ZooLib was popular enough yet that they would sell enough copies to justify the cost of publication.

I have the idea that if I finish writing the book, ZooLib will appeal to many more people than it does today, and that will convince the publisher to print the book in, say, 2004.

Accounting

So I decided tonight that I wanted to fix some errors that I have known have been in my QuickBooks records for my business. I knew that a recurring charge had just been charged to my debit card, and I would have been overdrawn if I didn't lend some money to the business. But things are tight so I only lent enough to have a balance of about a dollar, and I wasn't comfortable that my "estimate" of my balance was correct.

I am a rather disorganized kind of guy so I don't have all my bank statements. What I did was print out each month's online banking statement. Then I compared the statements to quickbooks, checking the cleared status in QuickBooks and writing a checkmark on the printout.

In this way I found a couple of transactions that were entered twice in QuickBooks. Voiding the extras increased my balance. I also found a couple of transactions that the bank had recorded but that I had not. Recording them decreased my balance.

I had thought I had only one error, when I actually had four, but they nearly canceled each other.

Finally, comparing the balance reported by my bank in its online banking (Key Bank works great with Mozilla!) and subtracting off the charge that I know will hit my account in a couple days, Key Bank thinks my balance will be $1.13 once that charge comes in.

But QuickBooks thinks my balance is $1.23.

Crap.

I was about ten dollars off, now I'm ten cents off! I'm no good at bookkeeping.

I spent a little time trying out GnuCash a few months ago, and basically liked it. I will probably switch to GnuCash sometime soon. I hate QuickBooks with a passion. I hated it so much from the start I never paid for an upgrade from the version I bought in early 2000 because I felt so burned. I'm really looking forward to GnuCash.

The stable version of GnuCash is not yet ready for business accounting, but I think I can make it work. I just checked www.gnucash.org and it appears that some business features are now available in the development version, so I may try testing it again soon.

I just need to figure out how I can issue a paycheck while accounting for tax withholding. If I can get GnuCash to do that properly, it will have everything I really need.

GnuCash holds particular appeal for me because it can handle accounts in any national currency. That's important for an American married to a Canadian. I really found it a drag to deal with reimbursing out-of-pocket business expenses that were paid in Canadian dollars when I lived in St. John's, as well as handling some paychecks that were issued by wire transfer to my Canadian bank account.

I don't need most of what QuickBooks offers. I actually figure my tax withholding manually in a spreadsheet, because I'm too irate to pay for Intuit's tax table subscription service, seeing how I don't think I should have to pay to get information that the Feds and each state publishes for free. QuickBooks doesn't even provide a method for me to type in the tax tables manually or import a file I get from elsewhere.

I get a much better understanding of where my money is going by using a spreadsheet to figure my withholding anyway. At least QuickBooks is kind enough to let me enter the withholding manually when I issue each check. That's manageable for a corporation with one employee.

Intuit stopped supporting online banking for QuickBooks '99 earlier this year. The only option they provided was to pay for an upgrade. I canceled my QuickBooks online banking and now I just use Key Bank's free web banking.

I think Intuit along with its products QuickBooks and Quicken is the best argument there is for Free Software. While they may not be a criminal monopoly like Microsoft, Intuit does more to personally irritate me, and on an almost daily basis, than Microsoft ever has.

QuickBooks will automatically print certain tax forms like the employer's quarterly payroll tax withholding statement, but I find that it's better to keep a summary of my payroll in one page of a spreadsheet and then just copy the figures into the form each quarter. This also gives me a good overview of my company's payroll (and my income) over the whole year.

By March 15th I have to file my corporation's annual tax form, and pay taxes on any profit it may have made (which it won't have, because I pay myself in salary everything I don't spend on business expenses). That ten cent error will be a problem - I don't want to deal with the IRS inquiring about a ten cent error in my tax statement.

So what I'm going to do is find all the bank statements that I can, then get Key Bank to reprint all the ones that are missing. That will cost considerably more than ten cents. But at least my books will balance.

GnuCash, here I come!

Kindness

Times have been pretty tough for Bonita and I since the dot-com crash happened. There have been a number of times when bill collectors have been ringing me up every day to hassle me, and we didn't have enough food to eat. Sometimes during the cold Maine winters we have had to keep the house much colder than is comfortable to avoid using too much heating oil.

One important reason that we have made it through these difficult times is the kindness and generousity that has been shown to us by our friends and family. It's happened a number of times that some friends have gone out of their way to help us without being asked.

Sometimes these are little things, but quite often people give us help that must represent a significant sacrifice for them. Many of the friends who have helped us are going through hard times too.

I'm very grateful for the kindness that has been shown to us. We could never have made it without the help we have received.

To the extent I am ever able to, I will pass on this kindness to others who are in need.

Back online after two days of vacation. I stayed home, but my wife doesn't like me to get online on Christmas Eve or Christmas. I turned off all my computers, even my network gateway (a Mac 8500 running Debian Woody PowerPC) that was starting to get a respectable uptime. The silence in the office was eerie. One of my long-term goals is to replace all my fans and disk drives with quieter ones.

Happy news: there was an email waiting in my inbox from a potential client I've been talking to for a couple months. He still wants me to work for him starting in January. Things have been pretty tight for a while and this new work should put me back on track. My wife was very relieved when I told her. It will be more embedded work!

My mom gave me a T-shirt that read Real Men Shop on December 24th. How true, or at least it used to be before I moved far away from everyone and have to ship the gifts I give.

There was a fierce storm last night (Christmas night), the wind was howling and the snow fell horizontally. I got up today to find bright sunshine and eight inches of fresh snow on the ground. The depth of the snow gave the snow plow man such trouble that he didn't get to our house until 5 pm, so I didn't get to go out to run the errands I planned to do today.

I find it really odd to live in a place where the removal of frozen water that falls from the sky is a significant economic activity.

Threads vs. State Machines

I can see the advantages of using state machines over threads, but I don't see how one can get operating system support for distributing a program across all the processors in an SMP machine if you're using a state machine that has only one thread of execution. Perhaps someone can clarify this.

I realize threads are implemented in an OS kernel as state machines. What I'm asking about is how a user program can do SMP via state machines without the use of threads.

Saying to run two state machines in different processes isn't the right answer. That's the same as using two threads and presents all the same difficulties.

I agree that threads are resorted to too quickly by the lazy who don't treat them with the respect they deserve. Threads present a lot of problems and it takes care and skill to deal with them properly.

I wrote a test tool at Apple when I was one of the QA engineers for MacTCP, Apple's original TCP/IP network stack. Macintoshes didn't have threads or even proper preemptive multitasking. One could run interrupt tasks and do asynchronous I/O.

I implemented it as a state machine and it worked very nicely. Each Mac could have 64 TCP streams or UDP "pseudo-streams" and all the Macs on a network could communicate in any combination to create a pretty fierce amount of I/O. Without state machines that would not have been possible.

State machines tend to be much more conservative of resources than threads usually are. On the BeOS, each thread has a fixed stack allocation of (I think) 256 kb, and that is often very wasteful.

Hacker Angst

Sometimes when I have some particularly difficult work to do, particular when I have something totally new to work on, I just can't face it. The thought of even so much as opening any of my source files fills me with dread. It stops me cold.

Usually what I do is go to lie down for a while. Sometimes I take a nap. It's the worst feeling.

When my wife sees me like this she tries to encourage me to get back on the horse. It's pretty easy for her to tell that I'm in this state because I get up abruptly from my desk only to lay on the couch or bed.

Usually the best thing to do is try to find something easier to do to get myself back in the rhythm. Any work at all as long as it's somehow productive.

I hit this wall tonight with something difficult I planned to do. I have a programming task that won't be a lot of code but it's not obvious to me at all how to do it. After taking my usual time out I decided I would spend some time writing test code first and doing some testing. I probably won't even get to the difficult work tonight. It only matters that I get it done in the next week or so, so I should be able to work up the momentum.

20 Dec 2002 (updated 21 Dec 2002 at 07:04 UTC) »

Updated: Embedded Systems Programming

I've been up all night working on a really whacky bug that cropped up yesterday. After backing out some recent changes I decided that I must have inadvertently introduced a bug in some working code while I was working on some unrelated code. My guess was the I typed something into a source file accidentally and it happened to compile but caused trouble.

So I decided that rather than track it down, I would restore a backup from before my latest work, make sure that code worked, and then merge in my latest changes.

But that didn't work.

I went to earlier and earlier backups, becoming increasingly dismayed and to be honest rather panicked.

At some point I tried out a known good binary that had been a test build I delivered to my client that I knew worked, that my client said worked for him too. And it had the same bug.

That's when I began to suspect I had an electrical bug.

After some examination I discovered that a ribbon cable wasn't plugged in quite right, its connection was at a slight angle. It looked like it should have been OK though. But I popped the cable off and plugged it back in again.

Bug fixed!

It is now 2 a.m. saturday morning and I'm now ready to start productive work for the day after spending all day trying to fix a hardware bug in my source code!

Live and learn, I guess.

Back to our regularly scheduled program...

Well, I'm pretty close to completing the embedded systems project I've been working on the last couple months. It's not quite done yet, and one really significant challenge remains, but it should be done in a week or two.

That means I'm going to need to get new work.

I have been in discussions with someone else for another embedded project that I would be quite stoked to work on. The guy has told me several times I am his top candidate to do the work, but it is not yet a sure thing. If I do the work it will start in January.

I was pleased just now to get a call from someone who saw my antry at MacTalent and was very interested to have me do a six month contract. But the rate he suggested was pretty dismal, and I'd have to live away from home for six months.

I told him what I would rather get for a rate, and he said he'd see what he could do (I think he is a headhunter). I also said that that rate would only apply if I could work out of my own office, to work away I would also need my extra living expenses covered.

I told him I'd maintained my own office for almost five years and had been very successful at it. It seemed like it hadn't occurred to them that someone could do the work at a distance. He actually seemed pretty open to it. So it's a possibility.

This embedded project I've been working on, I think it has been the most difficult programming project I have worked on in my entire life. I have had bigger jobs that took longer, but nothing that required the kind of effort and mental strain that this has. But now I know a lot more about how to do embedded work than I used to, and I feel much more comfortable now working with hardware.

Ironically, one reason I proposed it to my client was that I thought it would be really easy to do. I thought I could have a shippable product in no time at all. That hasn't been the way it turned it, but fortunately my client has maintained his enthusiasm for the product.

Hopefully I won't have to keep the secret of what my product is for much longer. The plan is for my client to demonstrate it at his booth at the upcoming MacWorld Expo in San Francisco.

Sometimes my wife expresses great distress at how tough things have been for us, and one way I try to reassure her is to tell her that things are tough for everyone. We are doing better than most - at least we are both working. I see posts from time to time here and elsewhere from people who are out of work, some who have been out of work for a year.

My wife has scored a contract with a second client for her web design business. She is quite stoked.

Her first clients are a folk-rock band, and at the release party for their recently completed CD, the band members publicly thanked Bonita for doing their site. This prompted one of the other women at the party to approach Bonita to do a site for her store downtown.

Word of mouth really is the most effective advertising. The challenge is in getting it to happen.

I'm proud that I got Bonita into using cascading stylesheets. Now she knows a lot more about CSS than I do.

I'm probably going to do a little web application programming to help Bonita out on this job, writing a small program to allow the store owner to easily list her inventory on her site without having to know how to code HTML. Very likely there is some open source application that does this.

Brother, Can You Spare a Clue?

I have made considerable progress at improving the performance of my embedded application. Using a better algorithm (what I believe now is considered the fastest algorithm) in C got me a factor of ten improvement. Re-coding that in assembler got me another factor of three improvement.

The problem is, it's still not fast enough to meet the client's requirements. I need to increase the performance by another factor of three. I believe I can do this by tweaking the assembly, but it's not at all obvious to me how.

That's why I submitted an "Ask Kuro5hin" on the topic of ARM Assembly Code Optimization?

I felt the discussion would be more useful to others, and likely to result in more ideas that would inspire me to solve my problem, if I encouraged people to post performance tips for any architecture.

I mention in the article that I don't have the budget to buy all the books that have been recommended to me. One reason for that is that I rather dramatically underestimated the time it would take me to deliver the proof of concept, and I had agreed to do that work for a fixed price (being under the impression it would be so easy!). But the happy news is that I asked my client if he would be willing to help me out with the cost of a couple of books that people recommended to help me speed up my assembly, and he agreed.

After a couple hours of calling around (and being disappointed that online bookstores won't ship on Saturdays) I got a bookstore a couple hours from my house to put on hold for me:

My friend Dave Lyons, who recommended Hacker's Delight to me, said that he was quite suprised by what it showed you can get a two's-complement execution unit to do.

Embedded Systems Programming

I worked through the night, night before last, to speed up my code, and hit what I believed at the time was a brick wall. The kind of brick wall that would make it impossible to get my product fast enough to bring to market.

But after I finished up for the day and spent a few hours just relaxing I thought of a possible solution. I don't know if it will work, but it could work, and maybe if I can get my solution working at all some further work will make it fast enough.

I was eager to implement my idea yesterday, but I hadn't slept and was exhausted. It was very hard to bring myself to go to bed. I managed to, but I woke up at 2:30 am today and got up to go to work. Even though I had gone to bed in the late afternoon, it's not like me to wake up so early and go straight to work. That's how badly I want to succeed.

This embedded project has been a Trial by Fire. But it still has the potential to pay off well, and the painful experience I'm gaining should make future embedded projects a lot easier.

Writing

Zach Frey very helpfully wrote to me about my last diary entry where I discussed the tension between my struggle to make a living and my desire to do things that I felt were more important like writing and political activism.

He referred me to a speech C.S. Lewis gave to some British University students at the outbreak of World War II, in 1939. The speech is called Learning in War-time.

A Google search for "Learning in War-time" doesn't find the complete text online but there are a number of quotes available that I have found helpful:

The war creates no absolutely new situation: it simply aggravates the permanent human situation so that we can no longer ignore it,..

Human life has always been lived on the edge of a precipice. Human culture has always had to exist under the shadow of something infinitely more important than itself. If men had postponed the search for knowledge and beauty until they were secure, the search would never have begun...

We are mistaken when we compare war with 'normal life'. Life has never been normal.

I'm going to go look for the full text of the speech in the library and a couple bookstores some time in the next few days.

Zach also wrote about the importance of what I do in the way of making a living, that this advances the cause of Freedom - working independently as a consultant, and making what contributions I can to Free Software.

My long-sufferring wife understands why what I do is so important to me, and she supports and encourages me as best she can, but the way my other activities sometimes threaten to bring us closer to the precipice often frighten her.

I wish I didn't cause her so much pain when I take off to do something that I'm not getting paid for. I wish the way I do make my living were much more secure, so that when I am working billable hours, there would be more certainty in our lives. Usually I make enough money from my work that I can afford to take take off now and then to write, but it's never certain at the time I do it that my consulting is going to work out well.

38 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!