- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Just to mention that icons on most *nix system are acctualy C code (XBM anyone) ... so what is so strange about this code !? When dealing with specialized hardware even more so ...
Admin
Um, so, where is the WTF? I mean, this is a perfectly reasonable approach to embedding binary files into programs.
Admin
Not a tractor on a christmas tree. The bottom is a perspective drawing of train tracks. A tractor is crossing the tracks to the left.
Or does this say more about me?
Admin
Maybe the original developer was dealing with a version control system that couldn't handle binary data?
Or else he was learning about bitmaps and thought this was a good learning exercise.
Admin
I'd say the "tree" / "tracks" are actually sound waves. Though I'm still not sure how it relates to the vehicle moving left. A warning icon / button, perhaps, indicating whether an alarm is active. Low-resolution icon design can be awfully tricky. Almost sure this is for some big graphic LCD readout, given the icon size (and the fact that it is black and white).
Admin
This isn't even close to being a WTF....considering it's an embedded system. The practice of encoding images in source code is common of small embedded systems where there's no such thing as a file system and storage space is a rare resource (embedding the image so that it can be referenced with just a pointer uses less space than needing a file system on the storage, the associated code for talking to that file system and code for loading the image into memory). Typically there's a tool that generates the .c/.h files from an image file (which presumably exists but has simply been overlooked...or lost with the handoffs...)
Admin
Not everyone is a codemonkey.
Admin
Exactly. On alot of these things, resources are so tight, that the standard library sometimes has multiple flavors for how much functionality you need. Like printf with only integer support. If you want floating point support, you have to link the standard library differently.
On that note, in this type of environment, even the overhead of parsing a bmp file might be a bit high (like you would have to do with the "link a bmp" suggestions everybody has been saying). With this, the bmp file can be in FLASH or EEPROM and never even need to be loaded into the very precious RAM. Just try parsing a BMP file into RAM on something like this http://atmel.com/dyn/products/product_card.asp?part_id=4347 <- that's 64 bytes of RAM. On the other hand, it's not exactly slow - up to 20 MIPS.
Where do they use such small things? As mentioned earlier lots of places. I might add garage door openers, remote controls (how many have a Logitech Harmony?), mice, keyboards, toys, peripheral devices inside a PC, the list goes on and on and on. See the projects at avrfreaks.net for more ideas. Ever heard of the Arduino platform? It is exactly this type of environment.
And this idea isn't even as uncommon on "regular" computers as some might think. How about the inline image part of the HTML spec: http://en.wikipedia.org/wiki/Inline_image. Google Chrome also does something similar http://www.chromium.org/developers/design-documents/linuxresourcesandlocalizedstrings For that matter, windows resources are just a systematic way of doing the same thing: http://blogs.msdn.com/oldnewthing/archive/2009/12/11/9935462.aspx, minus the C code, but that's just a universal way of doing the same thing.
Admin
There's a reason the GIMP has support for outputting arbitrary files to C files...
Admin
No, that doesn't count. If you're working with PNGs, building with Ruby and SCons and talking about "installable packages", you probably aren't working in a resource constrained environment. Stop being lazy and learn how to write a build system. A good rule of thumb: if building and installing your package means running code in more than one interpreted language - not counting shell script - you're probably doing it wrong.
When looking for open-source libraries/frameworks to support a new project, I often dismiss anything with a custom build system. The learning curve for autotools may be steep, but speaking as someone who has put the effort in, I wouldn't look back.
For anyone developing open-source code: UNIX is not Windows. Not everybody wants to - or necessarily can - run pre-compiled blobs. If your source is open, the source is just as important as the binaries, and that source is near useless if nobody but you can compile it. Make your project easy to build and install and distributions will package it for you - that's why they have people called package maintainers.
/rant
Admin
How about almost no RAM and no read access to your LCD? That was the last project I did with a display. Well, we had read access, but each 1x8 slice read took several milliseconds to read, which was way too slow to do anything useful. We had more than 64 bytes of RAM -- I think there was 1k total -- but much of that was reserved by drivers for the PWM and ADCs, and more of it was consumed by the stack.
(And ugh... please don't bring up the Harmony. I can't believe how buggy that firmware is. Love the remote, but I swear, if I could I'd write new firmware from scratch for the thing.)
Admin
Looks like some seismic sounding machine, maybe?
Admin
In other unrelated news, Sarah Palin signs multi-year deal with Fox.
Admin
FTFY
Admin
The real WTF is the submitter's knowledge of embedded systems.
Admin
That doesn't sound too far off from X Bitmaps (http://en.wikipedia.org/wiki/X_BitMap). Perhaps the code originated on a Unix system? It's a kind of crufty concept now, but XBM was fairly standard 15+ years ago.
Admin
That was an example, ATMEL has larger ones, but I know exactly what you mean. Memory is at a premium and don't count on using peripherals to help with that. Doing almost any kind of picture decoding on an embedded microcontroller is near impossible - the memory limitations will stop you before you even begin. Even a file system is very questionable with these (the block size alone might be half or more of your available memory).
I'm not particularly impressed with the Harmony either. Seems slow, and the PC software seems rather stupid (a desktop application that requires you to make an account?) Haven't seen many bugs yet, though. But the micro is probably either an 8 bit uC or a small ARM. My bet is 8 bit uC - much simpler. But this is a good example of an embedded device, poor implementation though it may be.
Admin
Today's true WTF!
Admin
That's actually fairly common... For example, the various X bitmap format like XPM are actually regular C header files. It's probably both more compact and faster to include it in the code, than it is to open a binary file, read in the data, etc. Especially on old devices the difference was measurable.
Admin
Addendum (2010-01-11 17:54):
"Deploy geological survey unit with ground-penetrating radar". (EDIT: My guess, btw.)Addendum (2010-01-11 17:56): (second edit: oh poo. that wasn't meant to happen.)
Admin
Admin
You'll be hearing from M00T's lawyers...
Admin
The HUGE WTFs here are:
No makefile, despite having over 274 source files (considering there were 274 images, and they were in separate files.)
None of the embedded people understand that this is a WTF.
I did a small stint dealing with embedded systems. When I first suggested the use of make (or some equivalent program if they wanted something different), I was told, "We can't just use a standard compile command, because it tacks on the standard libraries and stuff for the development platform, and the [target platform] doesn't have them."
So I modified the Makefile, so that it compiled the various parts the same way that they did them by hand.
While I was ostensibly primarily working for a different department, using make gave me such a development performance edge over the devs who were dedicated to that project, I was able to actually contribute more code while only spending 10% of my time on it than most of them were able to do spending "100%" of their time on it. (Of course, subtracting meetings and other overhead, that was really more like 60% of their time. No, overhead shouldn't take 40% of ones time, but that company was rather Dilbert-esque.)
For what it's worth, no, they didn't spend time debugging my code. No, they didn't spend time optimizing my code. My code was generally as tight, fast, and error free as their best. And, as of around 2003 or so, 80% of the code that still in use from when I'd been there (around five years earlier) was my code - but I'd only written about 1% of the code in the product.
Addendum (2010-01-11 19:24): I forgot to point out that, according to my source for the 2003 figures, the Makefile I'd made was deleted almost as soon as I'd left. He noticed its absence, because he'd been asked to give them 10% of his time, since they'd lost 10% of my time.
Admin
I understand there are actually tools that can take a binary file and spit out a C header that declares it as a byte array. Probably not the best way to embed resources nowadays, though.
Only example tool I know of is that Wireshark can take a network dump and convert it into a C header.
I can only assume one of the Wireshark devs needed that functionality at one point...?
Admin
The real WTF is that embedded coders don't care that 100 previous embedded coders have already explained that this is an accepted practice. Each one needs their "I'm smart and you're not" to be heard.
Admin
WTF? At the article, not the code. This is a perfectly standard and legitimate technique. It can be easier than messing with a bunch of image loading code, especially on embedded platforms that don't even have files. http://en.wikipedia.org/wiki/X_PixMap
Admin
This seems to me like the standard simple approach to embedding bitmaps into an executable. I don't get wtf would be?
Admin
Admin
Chances are they're autogenerated and today's WTF story is a result of pig-ignorance on the part of the submitter, the writer, and any editorial process (like there would be some...). Oh, and the commenters. I can understand that most programmers would never have been inside an XBM, XPM, PPM, PGM, PBM, or PNM; but to be unaware of their nature beggars belief.
Also, the caecum is for breaking down food to be reingested later so that more nutrients can be absorbed. Rabbits poot their caecal ("night") pellets out and eat them. Larger mammals like horses do it all internally. How apt that you didn't know that, either.
And what does "there were no makefiles and over warnings and errors" mean anyway? Is that supposed to be "other"?
Admin
A site that is not worth reading is a site that is not worth visiting.
...or am I somehow wrong?
Admin
Admin
The editors of this site should refrain from posting anything that's written in C as they don't understand the systems built in C nowadays. :(
Stick to the SQL/Java/.NET posts. Those technological areas seem to attract a crowd more prone to "interesting" solutions anyway...
Admin
Then Johnny had never worked with the X-Windows library, which uses this as a standard technique, and which provided tools and an API to support it.
I'm not supporting the concept, these days there are better approaches. But in the days before decent packaging tools, compiling commonly-used bitmaps into your application was a standard mechanism to (a) simplify delivery and (b) boost performance.
Move along folks, no WTF to see here.
Admin
The constraints are different on different operating systems.
In operating systems where the whole executable is loaded at once, or where it is customary to have different versions of the resources for different markets, it might seems like a bad idea to keep the bitmaps in the executable.
On the other hand, in operating systems that load and unload the executable page by page, and where more over it is convenient to have a single file executable, it is a good idea to integrate the bitmaps into the executable, and an easy and portable way to do so is to define them in the sources.
Tere are ever X bitmap editors that will save the bitmap directly as C sources!
Admin
[image]
my bad, here's the version that ISN'T upside down.
Admin
Besides, it was the only interesting part. There's nothing particularly exciting or specially WTF-y about an old project that someone hasn't kept track of all the bits and pieces and you have to reconstruct parts of it from whatever's left over.
That, OTOH, is definitely ARWTF!Admin
This is a pretty common method of embedding resources directly into a program. While it's a bit odd to want to embed an entire bitmap image, header and all, it has advantages - no dependency on external files, filesystems, etc.
"Like many global corporations, Johnny had the usual problems" Johnny himself was a corporation? An odd name for one, that's for sure.
"In fact, he wasn't even sure how it passed any compiler, as there were no makefiles and over warnings and errors." I'm not sure how this would pass proofreading, as there are over grammatical errors. (In before "over 9000".)
In any case the real WTF is that the site went down just after this article had finished loading. What are the odds? That of course meant I had to wait until I got back home to post my now-several-hours-late comment... oh well.
Admin
Admin
There was a WTF here:
WTF is such a standard, useful technique doing as a post on this site, and why, after dozens of comments pointing out that this is not a WTF, has the original post not been updated to say it isn't one?
The site's been getting less and less interesting over time, though I don't know if it's the site or me. But this was annoying enough that I think it's finally time to give up reading it.
But hey, thanks for the good times!
Admin
Admin
const char my_bmp_data[] = "BM6\x0c\x00[…]\xedMG\xf1";
? (Yes, fair enough, automatic NUL termination…)Admin
So long, and thanks for all the fish! lol
Admin
I am simply flabbergasted that I am able to get to Page 3 of the comments, and there are STILL people mentioning that this is not a WTF, outlining the same reasons that the first poster on the first page did. Yes I know some are doing it to take the wizz, but most aren't.
Yes, I have heard of XPM. I've heard of it at least 5 times now. All within the last 10 minutes.
Christ. I don't expect anyone to read every word of every comment, but is it really that hard to just gloss over the first couple of responses to see if anyone's already said what you're saying?
Admin
And the lack of a makefile is fine if you can just (fairly quickly) do something like
Of course, if it takes a while or requires a lot of typing, then, well…Admin
Admin
Once more, the real WTF is the complete ignorance of the poster. This site is becoming a little more pathetic every day.
Admin
I can see it!
It's a wifi controlled tractor that shoots rockets! Possibly to defend the agricultural sector for the upcoming zombie invasion?
Admin
Admin
Kudos to those who posted the bitmaps. I'm both impressed and disappointed. Impressed because that's quite the feat you pulled off. Disappointed because I was sure the bmp would be a rickroll of some sorts.
Admin
For those who keep saying "embedded system"... Here's how the boot logo is included in the Linux kernel: http://nerdvar.com/ting/linux-2.6.30/drivers/video/logo/
Granted, those .c files are automatically generated from the .ppm files in the same directory, but they're still essentially the same format as given here...