Random thoughts about software, hardware and electronics. And other things too...
perjantai 30. lokakuuta 2015
Shut up and stop refusing my money!
...well, any more of my money, at least. Another rant coming right up.
I've been less than pleased with DVDs lately. There's nothing but endless trouble trying to play them, as they either keep freezing or just refuse to work at all.
Just now I tried to watch Star Trek DS9 DVD I just bought, but I just can't. Windows 10 doesn't have DVD player so that's off the table. VLC played a few minutes of it, then froze. So failure there. And MPC just reports copy protect failure. At least I have DVDFab as last resort... But the point is that I should not need to resort to these tools just to watch the goddamn DVD I own!
Well fuck you [checking back of DVD quicly] CBS & Paramount. While I'd love to get (as in buy) rest of the series on shiny disks, at the moment it seems that places like piratebay offer far better value. Their offerings at least fucking work as advertised!
(and no, netflicks doesn't offer any Star Trek series here. Apparently they don't want my money either... Well, screw them, too.)
Update, the next day: I had old unused (or no longer used, maybe ten years old) computer still laying around and this experience was just what I needed to push me past the initial trouble of installing (once again) a Linux distribution (Xubuntu proved most useful for me) on it. And what do you know, this DVD that proved unwatchable in Windows played without any trouble whatsoever.
maanantai 26. lokakuuta 2015
Why, not what
This has been said over and over again, but yet I feel like saying it one more time again.
At the typical beginner class people are taught that comments are good and every line should be commented. So we end up something like this;
for (i = 0; i < np; ++i) // Iterate np times tot = tot + s[i]; // Add value to total
Totally useless comments that tell nothing. Contrary to popular opinion this kinds of comments are actually worse than no comments at all, as they tell nothing or even worse, they tell lies.
for (i = 0; i < p; ++i) // Iterate np times tot = tot + s[i]; // Add value to total
p times? np times? What is going on? Someone did some changes, possibly, but never bothered (or remembered) to update comments. If you trust the comments (I generally don't, in cases like this) it is possible that there is a bug in there and now you have to spend time figuring out whether code or comments is right. And then some more time to fix the mess.
So please, don't write comments like that. They're useless.
So what then?
Just few days ago I was going through some code I wrote maybe a year ago and came up with this nugget:
i = 0; while (inBuffer[i]) { if (inBuffer[i] != '0') { addString(inBuffer); break; } ++i; } if (!inBuffer[i]) { ... }
What is going on here? But right after first confused glance I noticed the comments;
i = 0; // if given string has other chars than zeros, use it. // Only zeros (no matter how many) -> ignore while (inBuffer[i]) { if (inBuffer[i] != '0') { addIdString(inBuffer); break; } ++i; } if (!inBuffer[i]) // just zeros; discard data { ... }
Just a few short sentences, but enough - now it immediately made sense. Data passed here is only numbers as ASCIIZ string (no other characters except ending zero, reading the value takes care of that already so validation not needed at this point) and value with just zeroes is to be ignored. So this checks the string, stores it if it isn't just zeros, or throws it away if it is. There absolutely are prettier (as in easier to read without comments) ways to write this but I often prefer efficiency, this is code for relatively tiny MCU anyway.
Granted, it wouldn't have taken me long to figure this out even without comments, but with comments I didn't have to waste time for that. This might not be greatest example there is, but this is a real world example I just stumbled, and of my own making, too.
Neglect is something even this commenting style doesn't fix, however. If I were to change the code and not update the comments to match, next time I visit this code I'd have to spend some time figuring out what is going on - and what should be going on.
So once again: Code is there to tell reader (be it compiler or human being) what is done. Comments are there to tell reader (human being) why and preferably also how it is done. Together they tell more about the code than either ever could alone. And do keep comments short unless absolutely, positively necessary. Writing novel-length comment is the easiest way to make sure no one will ever read or update it. Keep it short and to the point.
torstai 22. lokakuuta 2015
Bad caps
Well, seems that we aren't immune to bad caps either. No real surprise there, though.
Taking picture of the bulge is often tricky but just trust me here, once you actually see them the bulge is very obvious. Diagnosing first units wasn't exactly easy as unlike ones here the caps aren't always visibly bulged. To make things even more annoying the failure mode varied a lot; device suddenly turns itself off, fails to start on morning, starts counting distance at a wild pace, display behaves erratically... When first such device comes up, finding the real culprit may be difficult, especially since power rails sometimes seem good when measuring them on the desk, even after some gentle persuasion with heater and/or cold spray. ESR of caps very likely is off, but measuring that with caps still on board may be tricky and I don't have ESR meter handy anyway.
On the other hand, these are from devices over ten years old that have been powered essentially 24/7 the entire time. I'd say that few failures after over 80k hours of operation is within acceptable limits.
And yes, I still repair these units if asked to.
maanantai 19. lokakuuta 2015
Replacement bike parts? Print 'em!
I can be cheap bastard at times with things that might seem so very insignificant, which might be reason too - when something small, stupid and, well, insignificant is broken I don't really want to pay for it.
Case in point: my bicycle's side stand (I'm not sure this is the proper term for it, but I'll use it for now) is essentially but a hollow two-part metal tube (two-part due to adjustable length) that originally came with plastic at the end to distribute the load on ground. Over time (fairly quickly, actually) plastic wore out, and not very surprisingly hollow tube doesn't hold even bike's weight very well when on a gravel, grassy or otherwise less firm surface, making the stand pretty useless as bike will just fall over. Plastic part is still there but since it was so difficult to rip off that I just left it there.
On recent bike ride the screw holding two parts together came loose. Fortunately this was at stop so no parts were lost so instead of spending some 20€ (or something around that, haven't checked exact prices) and some ten minutes of my time (to take old out and put new in, ignoring time needed to drop by a shop) I chose to waste some 15 minutes of time to draw and print a new end piece. Printing of course took longer but since it's hands-off I don't really count it.
Drafting the part in openscad took just few minutes (I've grown used to it by now so small things like this are trivial), but maybe I shouldn't have drawn it first thing on the morning. I measure the opening at the end of metal tube, which was about 6.5mm. Then I draw a cylinder (well, cylinder stack actually) with r=6.5mm and commit print (I think print time was one hour or so)
When prints start I usually check that is started well, but typically I don't bother but occasional quick check mid-print (I moved the printer to another room as the noise gets annoying next to my desk when trying to do something else so I don't watch it all the time anymore).
After printing finished I go to check it out and immediately see what went wrong. Radius of 6.5mm. Stupid me.
Modify model and start over.
If you've been reading my posts you might remember that I pretty much consider USB unusable for any job that requires any reliability. As it turns out, that list would include 3D printing. Mid-print I hear usual USB disconnect noise (for no reason apparently), printing stops and it's ruined. Close Repetier, unplug cable, plug back in, and restart. Another 30 minutes (of print time) wasted.
Try again. And then I get the part printed.
Now to see if it does the job. Angles don't match the original but hope it's good enough but then again, I can modify it and print it again anytime if it doesn't. Possibly with a different material, as PLA most likely isn't the best material for the job (didn't feel like switching material just for that).
As a side to, the more I use the 3D printer the more I start to find it useful for many small, even tiny things like this. Some small part that broke, or some small thing that would be useful (like wedge-shaped spacer for between shelves and wall to distribute load), toy repair like mentioned before... Anything. Draft it quickly and print it. Parts aren't necessarily pretty but who cares, they get the job done well enough.
perjantai 16. lokakuuta 2015
Story time: Airlines
There was a recent headline I saw where an airline sent a woman home for no cost when then found out her son got injured. Although this was a good deed in this case, by airline that apparently cares about its service (I didn't really bother reading the article itself, wasn't that interested), the headline and reputation of some less than stellar airlines made be expect the events to be something like this:
"Looking for Mrs. Bouvier, Looking for Mrs. Bouvier, please come to gate desk."
Middle-aged woman looks briefly confused but then gets up and walks to gate desk. "I'm Mrs. Bouvier, what is this about?"
Aside normal gate desk operator there is also a man in his late 20s, in dark suit, standing behing the desk. He glances at woman quickly then speaks: "Mrs. Lorraine Bouvier, from Atlanta?"
"Yes, that's me."
"It has been bought to our understanding that your son was recently in an accident. You have my deepest symphaties and we have arranged your return flight home immediately."
"What? An accident? No, that's not.. "
"Your returns flight is leaving shortly so I ask you to move to gate 23 immediately for immediate boarding."
"No, no, it's not possible, he was just training when.."
"Now, unfortunately the business class for this flight was full so we had to downgrade you to coach."
"What?!? Now, he just strained his ankle, why should I ret--"
"I understand that you are under considerable stress due the recent events but please restrain yourself. Everything has been arranged for you and I'd like to ask you to follow me to gate 23, please."
"NO! He just strained his ankle, there's no reason to go back now, I'll just continue to my destination."
"Unfortunately that is not possible, we had to cancel your next flight to make new arrangements. You don't need to worry about your luggage though, I am sure that they will be moved to your new plane before it will take off."
"No, no..." Woman is now in clearly distraught. "He just strained his ankle, he's okay..."
Man sighs, then glances sideways. "I was hoping this would be needed. Boris, will you please show Mrs. Bouvier to her next flight."
A very large man, wearing similar, but badly fitted suit, steps in, taking hold of woman's arm, guiding her almost forcefully away from gate desk. She is too confused to even properly resist. The first man then turns his attention to a man that has been so far silently following the conversation, mouth agape.
"Mr. Bouvier?"
"That's me. Why the--"
"I understood that you are not the biological father?"
"Well yes, I'm not, but what--"
"Unfortunately we could not make similar arrangements for you because of this, but I guarantee that your original flight plan is still in effect." He smiles.
"--Now hold on--"
"Have a nice wedding anniversary at Hawaii, Mr. Bouvier." He turns and walks away.
"..."
maanantai 12. lokakuuta 2015
Cyberpunk predictions
On a wake of rise of personal computers in 80s a new kind of fiction was introduced - cyberpunk. It was pretty much created (or at least popularized, there were novels with similar themes and environments before) by the Willian Gibson, specifically with his novel Neuromancer. Although (so I've been told) Gibson himself didn't even use computers at all, he still pretty much lanched it as major literary genre. Not a small feat.
For those not familiar with genre, typical setting is somewhat dystopian/film noir-type future where megacorporations essentially run the world, cities are polluted and dark, and a human life is pretty much worthless. People can jack in the cyberspace (essentially direct brain link to virtual reality internet), and for many this is escape from bleak life - or, for some, a way to fight corrupted world. Or to fight for corrupted world. Our concepts of "white hat" and "black hat" don't exist there - there's just shades of grey, and shades change depending on one's point of view.
As a prediction of future a local computer magazine wrote (to paraphrase from my memory, this also being in mid-to-late 80s if my memory serves); "..Maybe in future someone reading this will be worth keeping alive no matter what; even with [extremely expensive, injected] nanomachines that would keep you alive by repairing cellular damage...". This stuck to me, guess I was hoping to be one of these very best hackers later.
As it turns out, the future didn't turn out as predicted - at least not completely. So far world hasn't become noir-ish polluted, dark hellhole (which is good) but power the global corporations hold seems to be way too large for comfort relative to us mortals (which is bad). But at least they hold puppets - often called politicians (fully bought and paid for, bad again) as a facade so far so it isn't as explicit as in cyberpunk novels (but I wouldn't call it good anyway). So far separation on black and white hats also stands (good again), but sometimes that seems to be starting to slip - there's been news on corporations wanting to start essentially cyberwarfare against hackers that are attacking them - that are possibly employed by some other corporations. So who is "good" and "bad" there, really? (shouldn't need to be said, but I do consider that bad)
For us who actually do the work building the systems, even the best of us are little more than cogs in the machine in the eyes of these corporations. There is no appreciation, or even ability to appreciate or even properly evaluate a programmers in companies these days, as evident from numerous articles about interview and work practices - and results of those practices. This isn't just limited to large ones, this applies to just about every company these days, some smaller ones possibly excepted (where everyone knows everyone and everyone reads everyones code - bad programmers tend to stand out then). While companies are looking for - and hoping to find - a rock star (read: insanely great) programmer, they rarely if ever find one, and even less often allow their newly found stars to work as they do best.
These days the committee sets the coding standards, and every cog in the machine has to meet these standards without deviation or that cog will be forcefully be made to meet them or be thrown out. As it happens, that standard very often happens to be the bare minimum - i.e. not very much. In our current, standards-seeking future there is no place for master hackers of cyberpunk nor the rock stars of reality. Everyone has to be a cog in the machine -- nothing more, nothing less. No deviations allowed.
And those health-providing nanomachines? At this poins I'm absolutely certain that those will be reserved for those that bring the most value to the company -- CEOs, boards and other highest executive staff, the people that get benefits and bonuses no matter how badly they screw up. Not the lowly cogs that do (and suffer) the actual work, they just get laid off for their mistakes. No, not "they" the workers, I mean "they" the highest bosses. Cogs can be discarded and replaced at will, no point wasting money on them. What do they know, anyway?
Now I'm only waiting for the cyberspace. With devices like Oculus that might be getting nearer. Direct brain link (as typically described for cyberspace) doesn't sound too compelling to me, however, even with very, although there are some very, very temping arguments for it.
See, cyberpunk predicted also black ICE, essentially a firewall around company network that could actually attack your brain (direct link, rememer). In literature those reacted only if you got too near, but in the internet of today of a bit too accessible as it is. I'd rather not have some random goon try to take over my wetware just because they just stumbled on my WIP by chance (wetware IP, I just made that term up), or if I tried to search for more information about some obscure yet restricted topic, thank you very much ...
perjantai 9. lokakuuta 2015
Teknologia '15
Just this week there was Teknologia '15 fair at Helsinki. I haven't been regular there as I haven't had any need to keep in contact with different equipment/part dealers there are often, but this year I had enough stuff planned that I chose to spend a few hundred euros to drop by.
My primary interest was Elkom part (Elektroniikan komponentit, Electronics components), but there are several different but thematically close events at same general event, including automation, hydraulics & pneumatics, mechanics, manufacturing, packaging and so on. Essentially almost everything you'd need when designing, building and manufacturing (technology) products, albeit there was also food production/packaging equipment on display so not just technology after all.
Since every other stand seems to have these huge structures reaching towards, or hanging from ceiling it's damn difficult to get a good overall photo. But I still had to try.
I've been drooling after new 3000-series scopes by Keysight lately, and damn did they have nice offer there - buy any keysight scope this year and you get all software options included, free of separate charge! I think I just spent several grand there, too, nevermind that I haven't received my quote yet.
No photos of that, I'll just forward you to Dave Jones' video blog, I think he checked one out lately.
Aside that, there was a lot to see. Almost too much for single day, and boy I was tired when I got back home that evening after all the walking and gawking and negotiating. This day wasn't waste of time nor money I think. I can't go in depth to other things I discussed there, some of that is a bit hush hush for now, but I think I made some promising connections for future.
These camera microscopes seemed pretty handy, although I'm not sure how I would get used to working like that instead of the microscope I'm using now. I think this setup (on right, one on left was something else) was around 4000 eur. And there was one with price tag of about 8000 too at another stand. A bit too much for my budget...
But some other random pickings...
How about some Heavy machinery? This motor (?) was rated at 800kW if my memory serves, plaque said 6000v / 90A (I think). I know, numbers don't match, I just took a quick glance so something might be wrong.
Containers of bright, colored fluids bubbling or whirling in them are always fun to watch. For a while. Then someone comes asking be what I'm interested in on their stand - and I don't know squat about (chemical) process technologies. Time to quickly mumble something incomprehensible and move on...
Helsinki Metropolia (University of Applied Sciences) was also present. They had their all-electric race car on show too. Sorry for bad photos, like most of them here I remembered to snap them only when being almost ready to leaving so I didn't have much time or energy to spare for nice ones. And really, there's a lot of press about it floating around already. Well, at least locally there is...
Next to this was another project car, with classic e-conversion labeling. I didn't examine it too much, but damn those power cables are of impressive size. I'm pretty sure that the small battery, as seen directly left from those cables isn't the one feeding the power units there...
And much much more, in so many categories that ones can't but feel exhausted after a day of browsing. Maybe next time some more, then ...
tiistai 6. lokakuuta 2015
Old copy protection dongle
Long time ago, back in 80s when Programmers were Programmers and happy to write assembly to get the shave off the last clock cycle from inner loop, when computers were archaic and ran DOS the printers were connected to computers via parallel port. And that printer port was great thing indeed, offering bidirectional 8-bit bus and "clock" signal for running all kinds of fun external devices aside printers. I for example built a primitive 8-bit D/A converter out of it, mostly for fun. Sound quality was pretty awful but that didn't bother me.
Then modern Windows' appeared (in this context I mean Windows NT, 2000 and XP), blocking common software from accessing the parallel port (at least without using third-party drivers) and spoiled all the fun. Although serial ports (often) remained, they weren't as useful as good old parallel port.
But dwelling in ancient history is not my topic today, although this is related.
Apparently at some point I had actual license to an some kind of CAD program that ran on those old computers, as I have actually its copy protection dongle left over. I don't remember ever really using this software but that doesn't really matter here.
I am not exactly sure how these dongles worked (I never bothered to crack any of the programs using them) but my guess would be similar to one game I did successfully "liberate"; the software itself doesn't actually have all the necessary data needed to run it, instead some must be loaded from a dongle (or in a part normally inaccessible on a floppy disk, in case of the game mentioned). When loading program, this part if fetched from protection device, allowing program to properly run.
This method of course makes program pretty much impossible to crack if you don't have the protection device (be it dongle, floppy disk or whatever) accessible, but with it process often is fairly trivial (details are left as exercise for the reader), despite programmers' best efforts to make it as challenging as possible.
At this point the CAD package is irrelevant, as is the dongle too, but I was kinda interested on what's inside this thing anyway. These were plugged in parallel port and they actually could coexist with other devices and printers. At least usually, sometimes they did conflict. Quite annoying if you had to keep reaching behind the computer to switch these dongles.
Opening this was simple enough and inside is a simple PCB with passives and three chips.
Before proceeding further I just mention that these things weren't built just for single software product; some company designs and manufactures these modules and associated protection software, and the company using these to protect their software needs to "simply" include provided protection library in their product (not unlike modern protection counterparts). So there were many software packages from many developers that used essentially same dongles.
But back to innards of this dongle.
Left side chip has marking 74HC0324AM, indicating common-as-dirt 74-series logic. 324 within that family is a VCO - voltage controlled oscillator - but this chip here has 20 pins whereas VCO only has 14. So that doesn't sound very likely.
A bit of digging around suggests that this marking is actually forgery and that it is likely some kind of GAL (Gate Array Logic) chip, proprietary to this application. Considering that this thing is supposed to protect Very Expensive software I have to agree there - short of decapping chip and comparing it against other silicon there is no way to figure out what chip it is and what kind of logic is in there.
In middle there is 93LCS56, 4kbit serial EEPROM. There are two options here; this chip may contain the logic code for the GAL chip, or it may contain some software package-specific data such as license identification, serial number or such. Or possibly both. Very likely encrypted somehow (this being from mid-90s simple XOR with custom key is most plausible). Or its marking might also be forgd, but on quick glance pinout seems to match. I didn't feel lucky so I didn't bother trying to pull data out from it.
On right side there is chip with marking T9421W. Only thing I find with that code is a digital potentiometer but that isn't very plausible either. That code might, too, be forged to hide what the actual chip does. So pretty dead end deducing how the thing works (well, if I had better equipment and some nice chemicals I could try to dissolve packages to see what is inside, but alas I don't).
Now speculating on the functionality. Since you could put multiple of them together (for multiple different software packages) and still have the printer functional, there must be a way to activate one specific module. This is most likely done by outputting a specific byte pattern from PC, after which the triggered module takes over the parallel bus and starts communicating with PC.
Then there must be some data exchange; possibly some challenge/response type queries (above byte pattern being first of those) - possibly with changing keys to check if module is actually module and not, say, another PC replaying some stored old communication pattern. And then there is exchange of actual product specific data, which very likely is verified at the PC end somehow.
Of course the software on the PC doing all this is very likely encrypted on disk, obfuscated as well as possible, very picky about timings (no breakpoints for you!) and be in every way as annoying to work with as possible.
And I bet I would have had some serious fun cracking it back in my teens!
perjantai 2. lokakuuta 2015
Best 3D modelling software (for me)
3D printer is nice tool, but of course to really create something new (as opposed to just downloading models from the web) with it you'll need some kind of software for creating/designing the models. If nothing else a simple text editor to create STL files manually, but let's not get absurd here (insert "real men 'cat << EOF > file.stl'"-joke here...)
There isn't shortage of 3D modeling software these days. When trying to pick suitable software for me, the criteria limited the offerings a bit. First, it must be capable of making 3D printable parts with well-defined dimensions (including sub-parts, like mounting holes and so on; preferably also sub-assemblies like full gear/enclosure structures). Second, the cost must be pretty low (so packages like Solidworks was pretty much out immediately; for hobbies the cost is just too high, and the occasional professional stuff is both easier and cheaper to contract out)
Previously I had used Blender a bit, for testing 3D modelling for games, but the first criteria caused me to drop it - while it might be that I hadn't found the proper tools within its vast arsenal it just didn't feel like a tool for creating engineering schematics.
So after some more reading I tried FreeCad next. At this point I'd like to remind that I have never had any kind of 3D CAD modeling experience nor tutoring - I was starting from absolute zero. Considering this I was pretty amazed that I was able to start using it after only after ten hours of studying and trying (over two or three days - sleeping over it when you don't clearly get some detail always helps!) Then somethings just clicked and I got the idea well enough to start building simple models.
Over the years I've learned that this click is pretty important when learning something new like this. You may read, study, try, read more ... ad nauseam, but until that click happens, you haven't really learned anything. In my experience the most imporant steps are reading, trying and improvising. Read about something; try the examples; then improvise on them to see what happens. Then repeat until either you are ready to give up or it just suddenly clicks - and then it's all easy.
In this case click was the general principles of modeling - relatively simple stuff. But after some tring I started running into a wall; my problem with FreeCad is that is claims to be parametric but if you actually try to use it like that the part I was trying to built pretty much self-destructed every time. Many designs I made (like test jig I mentioned earlier) have a base (bottom piece) and over that other details. Too many times moving some supposedly completely disconnected part at the other end of base caused some other part to fail, ruining entire design. Time to start over (or from last backup), and this makes me very very unhappy.
Also after some more reading I pretty much realized that for designs like gears and such I would have to delve into scripting anyway; GUI just doesn't allow that. My experience says that mixing GUI and scripting rarely works, so at this point I wasn't too happy.
Since I am a programmer, lately I started to play with OpenSCAD that uses very different approach; you write the description of model in a script very like a programming language which generates the actual model.
Take this very simple wheel:
Oh, and for the reference, here's the toy itself, with original wheel on other side and replacement on other. It doesn't look the same (I think now, after some more work, I could make similar shape) but it's good enough - at least I got the toy working again.
Now, while there is some ease and charm in "drawing" the 3D model with a GUI, thinking in code (as building blocks) is easier for me. One might claim that SCAD way is more difficult as you'll need to have "picture" of the end product in your head when you start the work but in my opinion same goes for GUI method too - either way, unless you have clear image what you are building at the start, the end result will not be pretty.
I think I'll stick to OpenSCAD for now, as it feels like the right tool. For me. And for now, at least.
Tilaa:
Blogitekstit (Atom)