Wednesday, 11 January 2012
Just over a year ago I had a problem, I'd just bought a new PC and since it had 8Gb RAM it had to run 64bit Windows (see this post for an explanation on what that's all about). But 64 bit Windows doesn't support DOS based programs, now I'm happy for that to be the case as DOS is a very old technology and at some point I think that modern systems need to leave the past behind.
However, for the past 18 years I've been using a DOS program to monitor and update a computer that controls out of parlour feeders which feed our dairy herd. Unfortunately, despite several requests I've not been able to find a Windows version of the program and I've never found the time to try and reverse engineer the serial port based communications. So I'm stuck with this DOS program, but it was easy enough to overcome the lack of DOS support by running the program in a DOS virtual machine.
While this program has many reports, there's only ever been one which has been of any interest to me, this report tells me which cows didn't eat their full ration in the previous period and how much they had left over. Since I had an old printer plugged into my parallel printer port I was happy enough print the report on paper that I recycled for the purpose many time over (by putting in upside down or back to front I got about 4 passes out of each page, the report isn't usually that long). I was quite happy with that and could easily compare previous reports.
But at about the same time I ran out of clean space on the recycled paper I was using, so rather than use more paper I decided to go paper free and 'print' the report to a text file. The simplest way to achieve that was to have the VM direct parallel port output to a text file instead of my parallel printer port. Unfortunately, the VM reuses the same file everytime, offering to either append new data or overwrite the file so I had to come up with a way of archiving old reports.
That left me with a couple options, I could either archive each file after I'd 'printed' the report or, since it was a text file, transform the data into something else. I chose the latter as in the long run it was much less fuss and I could also engineer it so that I could have easy side by side comparisons.
In the next part I'll look at how the file could be parsed to get the key data out.
Here's an example of the file: