Sunday, 29 May 2016

Junkers & Jesters

So, I've just had a massive clear up of my work area at home, I've cleared all the old bits and pieces, boxed over 100 pieces of electronics into nice foam lined cases and stacked them for sale at the nearest available car-boot... And I've stashed nice items I want to keep into dark corners away from the wife.

The aim of this exercise was to make the place look suitable impressive, so that she whom must be obeyed was happy... 

The net result however, it looks more messy!

I don't know how this happened, but it is infuriating.

Wednesday, 25 May 2016

Old CD Ripping Code

I just received a mail from "Experts Exchange" telling me a question I participated in would be deleted... When I opened the question, in question, I have no recollection of answering this whatsoever... it's not even really my style of coding...

I always Alman bracket alignment, never K&R...


------



I can't comment about "MusicBrainz" however, when using freedb (http://www.freedb.org) you need to compute an ID for the CD you have taken a track from, you can find all this information on their site in the "Software->Howto" sections:

But in essence, when you connect to their server to identify a track, you need to provide a disc ID.  This is an 8-digit hexadecimal (base-16) number, computed using data from a CD's Table-of-Contents (TOC) in MSF (Minute Second Frame) form.

--- Below is taken directly from the freedb.org "how-to" file regarding generating an ID to use with their service ---

The following is a C code example that illustrates how to generate the CDDB/freedb disc ID. Examples in other programming languages may be found on the freedb web site at http://www.freedb.org in the developers-section. A text description of the algorithm follows, which should contain the necessary information to code the algorithm in any programming language.


struct toc 
{
      int      min;
      int      sec;
      int      frame;
};

struct toc cdtoc[100];

int
read_cdtoc_from_drive(void)
{
      /* Do whatever is appropriate to read the TOC of the CD
       * into the cdtoc[] structure array.
       */
      return (tot_trks);
}

int
cddb_sum(int n)
{
      int      ret;

      /* For backward compatibility this algorithm must not change */

      ret = 0;

      while (n > 0) {
            ret = ret + (n % 10);
            n = n / 10;
      }

      return (ret);
}

unsigned long
cddb_discid(int tot_trks)
{
      int      i,
            t = 0,
            n = 0;

      /* For backward compatibility this algorithm must not change */

      i = 0;

      while (i < tot_trks) {
            n = n + cddb_sum((cdtoc[i].min * 60) + cdtoc[i].sec);
            i++;
      }

      t = ((cdtoc[tot_trks].min * 60) + cdtoc[tot_trks].sec) -
          ((cdtoc[0].min * 60) + cdtoc[0].sec);

      return ((n % 0xff) << 24 | t << 8 | tot_trks);
}

main()
{
      int tot_trks;

      tot_trks = read_cdtoc_from_drive();
      printf("The discid is %08x", cddb_discid(tot_trks));
}


This code assumes that your compiler and architecture support 32-bit integers.

Monday, 23 May 2016

Disable Caps Lock in Windows - Without hacking and without Registry Editing!

I'm back from tinkering, trying to help some poor unfortunate souls... Like old64goat, whom advise removing the caps lock key as a way to stop it operating... And then Lloyd here has actually broken his keyboard, and recommends you take your key off... Guys, if you remove your caps-lock key, all you have is a BROKEN KEYBOARD!

So, just calm down, calm down, everything will be okay, I'm going to explain everything to help you out... Lloyd, the "noise" thing... I cover that... And to all, read on, because there is of course a better solution.

I'm not saying this is an easier solution, because it's not, it's complex and all about configuring software, but there are No HACKS!  No Hammers! And No Needle Nosed Pliers required!

Best of all however, your keyboard can remain fully functional, other people can come and use your machine without being absolutely frustrated at your having acted like some kind of keyboard mohel.

Before I start however, I'd like to shout out to vwestlife as he pointed this one out, and I recently caught up with all this very interesting coverage and made me aware of this world of keyboard destruction.

The Video
From my live stream of the 23rd May 2016... Read the full solution below, this video is very rough & ready...


Unacceptable Sound Solution
So, what can you do to sort his problem out?... Go down to the start menu and type just the word "Keyboard" without any ENTER key, just the word and watch what comes up...


I've highlighted the first and simplest one which can help with the caps lock problem...

"Change How Your Keyboard Works"

Now, if you're not a touch type-expert and are constantly looking down at your keyboard, rather than at the screen, this can really help you hear if you've hit the caps-lock key... Lloyd, that's for you!

Simply go into that option and turn on the  option to hear a tone whenever the caps-lock key is pressed, now if you have speakers, or headphones on, you can hear a passing impression of an old Pong machine whenever you press the caps-lock key!!!


However, that just might drive you stark raving mad after a while, and since Lloyd posted his rant in 2009, I'm sure he's pretty much sick to his hind teeth of his machine beeping like this, if he ever found this solution out.

Unacceptable Horrible Hackery Solutions
And as I made mention, there are horrible, trickster hackery tricks to go into the bowels of the Windows Registry and unmap the caps lock key, however, this pretty much going to do the same as taking the key off, but worse, because it's removing the functionality for all users, and unlike with pushing the key back on, there's not a quick and simple way to undo the change!

Plus some applications you do actually need the caps-lock key!

DO NOT HACK, DO NOT HAMMER, DO NOT PRY YOUR KEYS!

Acceptable Solution
There is a much better, though more complex, software solution... If you go back to the start menu and now type "region", you'll be able to see "region & language"...


Selecting it opens this box:


And you can immediately see the tab at the top about the keyboard and languages, we're going to be coming into this later, remember this page!


Then we see this intriguing "Change Keyboards" control.  What can we do in there?  Well, we can see there's a way to add other language keyboard layouts, and if we add them, the language bar becomes available to switch between language and layouts.


However, ALL the layouts in there have the CAPS lock key set to  modulate the letter key codes, what we need is a new language/layout we can add, which does not respond to the caps-lock key.

Unlucky for us we have to create this layout... Luckily though Microsoft provide the "keyboard layout creator", which we'll now need to download & install from this link:


Install that and open it, you'll get a program looking like this:


Of course you can install your own keys now, clicking on each one, toggling it... etc... Play about, but all we want to do is create a clone of our favoured layout, for me this is "English (United Kingdom)", so from the file menu we can load that existing layout:



And it's presented to us...


We don't want to change any keys at this time, but we do want to change the properties to give the keyboard layout we're creating a name so we can spot it.

So, open the Project menu and select properties...


You'll get the default values...


Change them... so I'm going with this....


And just save this new layout project file...


You'll get a file, where-ever you saved it, looking like this...


Open it in Notepad, or whatever text-editor you favour...

Click to zoom in!

This looks like a lot of information, but whatever text editor you're using TURN OFF WORD WRAPPING!!!!!

And you'll see these columns in the center... the third column is "caps".

This column tells the keyboard controller (when is uses this mapping) what to do with a key when the VK_CAPITAL key code is received.  We want all the keys to do nothing, and some already do - such as the number keys.

Those keys already ignoring caps have zero's int his column, so we need to edit the letter keys to do nothing when caps is pressed, change any 1's or 5's you see in that column, especially against the a-z keys to a zero....

Click to zoom in!

Save the text file, and now re-open that "klc" file in the Layout Creator application from Microsoft again... I did this by right clicking on the file and selecting "open with"...

Don't touch anything, don't twiddle any values!!!!  If you do, the creator takes liberties and can change things back in your klc file.

Just go back into "project" and select "Build DLL and Setup package"...


The application will now try to validate the keyboard and you will be told (hopefully) that the verification succeeded, but that there were warnings, you can view the result I got...


Here...

Click to zoom in!

Those warnings tell you pretty much that everything worked as we expected, the CAPS LOCK is not set between 'a' and 'A'... etc... that's what we want to see!!!

When the DLL is built you can open the folder straight away...


And doing so, we see we have a bunch of msi and a setup executable...


Install the setup executable...


You will see that the name I entered in the properties is the window title, so this is "United Kingdom - NoCaps"....

Go back into the region & languagages menu, the keyboard again, and this time when you look you should see either... "United Kingdom - NoCaps", but more likely it just says "United Kingdom - Custom".  Select to enable them!  Anything new, this is a little sketchy, but this is Microsoft not what you've done.

Now, because you have more than one keyboard layout available in the languages, the language bar should show up...

Click to zoom in!

In that you can pull it down to select the "NoCaps" version!!!

Doing so in an editor now, I find caps lock has no effect!!! Exactly what people have been looking for.  And this only affects the capslock key, you can still get capital letters using shift!

You're Not hacked anything... Not been in to the guts of the registry, and best of all, you can uninstall it later... or deploy the same keyboard layout to any version of windows you like (above windows Vista at least).

And, best of all, you can just go back to the language bar and select the original standard "United Kingdom" default layout, and the caps lock is back on and working!

There are other options to let you select between key layouts on the fly too, so you can opt into and out of the NoCaps version at the press of a key combination... The default being "Left ALT + Shift", search your windows for "Text Services and Input Languages".

Sunday, 22 May 2016

Dell 2950 Server - Fan Modification - Part 3

This is the software side of modifying my Dell Poweredge 2950 (Model II) servers to be much quieter.

It WORKS!  But please beware, THERE ARE POTENTIAL RISKS IN ALTERING YOUR BMS FIRMWARE, IF YOU ARE READING THIS, IT IS ADVICE ONLY, ALL AND ANY ACTIONS YOU PERFORM ARE AT YOUR OWN RISK!  Just because it worked for me, doesn't mean you will be successful.

Part 1, shows how I added 47ohm 0.5watt resistors to the power (red cables) on each of the four internal fans.  I'm yet to modify the power supply fans, but I will.

Part 2, is my success video recorded at 3am last night when I was very tired, and had everything working.

And this, Part 3 is to cover my complete solution in how to do the software (BMC) firmware flashing.


The Centos Linux OS was used for the change, specifically the older version 6.4, downloaded from Oxford University here http://mirror.ox.ac.uk/sites/mirror.centos.org/6.7/isos/i386/CentOS-6.7-i386-LiveCD.iso.

This was burned to a DVD ROM, and as you can see in the image, I had to re-fit a DVD into the server as I have three servers, but only one DVD drive... DOH!

Next, I booted into Text Mode, so when the boot menu appeared from the DVD, I pressed Escape before the auto boot timed out, and selected to boot in Text mode.  Once booted, the login is "root", with no password.

My first command is to ensure the ipmi tools are installed, python, wget and rpm are on that image, but for completeness to the source material I include them in the installation:

sudo yum install freeipmi freeipmi-tools openipmi ipmitools python wget rpm

Once complete you can check the ipmi sensors are working with:

ipmi-sensors

You will get a huge list of all the sensors on the board.

Next you need to download the BMC firmware, to anywhere on the machine, you don't need any storage, the Live CD boot you're using will work fine just with RAM in the server!.. So no worry about overwriting any disks or data!

wget http://downloads.dell.com/esm/BMC_FRMW_LX_R202152.BIN

Once this has downloaded, you need to make it executable

sudo chmod +x ./BMC_FRMW_LX_R202152.BIN

Now make a directory as root:

sudo mkdir bmc

And extract this firmware you've downloaded into that path:

sudo ./BMC_FRMW_LX_R202152.BIN --extract bmc

And change into that directory:

cd bmc

Now we need the path script, but as we're in a directory created with sudo, we need to also run wget with sudo:

sudo wget http://projects.nuschkys.net/downloads/dell-adjust-fan-thresholds.py

And make this executable:

chmod +x dell-adjust-fan-threaholds.py

To then extract the values from the firmware and edit them, we run the script against the payload dat file:

./dell-adjust-fan-thresholds.py payload/bmcflsh.dat

This will extract a load of information, then ask you how many fans, or what model to edit, for the 2950, with four system fans and two power supply fans, I selected option 3.  To give me six fans to modify.

It lists each fan and their threshold value, so now select the fan by entering it's number, so try 1 first.  Then enter a number, now if I recall the default 2250 threshold is a value of 25.  I tried various values, but the best I found to modify for the resistors I'm using was 22, this gives a new minimum RPM of 1650 for the fans.  And I never saw any fan drop below 1800 RPM.

23 is 1750 RPM as a threshold, but I thought that too close to the lowest RPM I'd observed before starting this software mod.

So, 1 through 6 all selected and 22 entered for each, you then write this file back with the 'w' command.  This will repack the payload/bmcflsh.dat file with your new values.

Armed with this modified dat file you therefore need to flash the firmware, THIS IS THE STEP WHICH CAN BRICK YOUR MACHINE, PROCEED AT YOUR OWN RISK!!!

We're still in the bmc folder created before, so change nothing after altering the payload with the script, and you type:

sudo LD_LIBRARY_PATH=./hapi/opt/dell/dup/lib:$LD_LIBRARY_PATH ./bmcfl32l
 -i=payload/bmcflsh.dat -f

And as you can see in my full video coverage, this worked for me.

I hope this helps, below are the references I went to, but I must have read about 15 different posts, dozens (if not hundreds) of the comments to piece this together.  The biggest problems I had from other posts was understanding the problems using Ubuntu and other distros, they don't work.  There are problems with the libstdc++ libraries, and then the i686 installation and all manner of hoops and tricks I tried.

Centos 6.4 i386, is the only live DVD image I've been able to use... and this all work easily.

The main instructions I followed were from Martin Denizet, however, even his post has issues and it not clear how to get the right distribution.

I also tried to follow RatzBlog, but was thwarted at every step by the OS's I was using, even trying to use Centos 6 didn't work with his instructions.

Dell 2950 Server - Fan Modification - Part 2

For the start of this silencing journey, go to part 1.




More details to follow in Part 3! (WHICH YOU CAN NOW SEE IN FULL!)

Thursday, 19 May 2016

Blog Update: Mid-Session

Yeah, so what do I mean by mid-session?

Well, I'm midway through an awful lot of little projects, and right now (well about 5 hours ago) I actually just got home from a holiday (vacation to our American cousins)... So, lets just go over what I'm working on, what I'm planning for you guys, and when I plan to do it, saving time slips.

First, the server fan project, the fans have been modded with new resistors, they all still work, and the server boots.  And it a LOT LOT quieter, however, the BMC does start to moan after a while and it ramps the fans up to 100% screaming again when they drop below 2250 RPM.  So, I'm still working on software patching that...

Second, I have an introduction for you guys for the servers, covering all the little bits of kit I found in them, including memory installation, RAID controller configuration & installation, DRAC set up, and even re-working an Intel Dual Gigabit 8x PCIe.  Well I say re-working, I took the heat-sink off and put new shiny thermal paste on it to help it run cooler with the slower fans... Anyway, all that is coming up.

Third, what am I actually going to be doing with the servers?  Yes I have two new things to announce, watch this space.

Fourth, again a server item, racking them... I'm planning on building my own mini-coffee table style rack from some ikea items... However, this is a very low priority and depends on Pay-day coming around.

Last Server Item, it the new drives and RAM upgrades I've order, yes a whooping £20 has been spent!  However, I'm reaching out to several ebay and Amazon traders looking for partners to bring you new and exciting content as well as giving them reviews for their kit... So, watch this space for more kit being reviewed in my unique style.  To those vendors I've sent missives to... Get back to be folks, first come first served... I've got a Server CPU provider already negotiating... I'm missing RAM and cable providers... (hence why I've bought the first round of items for review & use).

Sixth, this is a software project, one of my most popular post series is my old, original, "Write your own CPU" series, which I think is pretty crap, I never finished it, never went beyond the basic add & sum op codes.  The later 4004 tutorial is not as popular (despite it being vastly superior), so to help my viewers see more of my blog and sites I'm going to be making a video series about writing your own virtual CPU.

I've got a bunch of real Z80 chips lying around, and some LED's, and a breadboard, so I may very well make a simple Z80 stepping/tester board and then we can write something similar in C++.

Seventh, Java code, the java series I had gets a fair view YouTube views, but I never see those viewers come through to here, so we need to figure out someway to get them java folks to read more than one line of text at a time!


So that whole series needs a tidy up, and the game itself there needs some new loving.

Eighth, I have some more Socket 775 modifications to work on, these are very very low on my list of projects, as I bought them at exactly the same time as the new servers came in.  And since the servers work, and are dual socket quad core Xeons, they are far more performance ready.

Very finally, I need to sort out the work-area, I have a new lovely digital controlled soldering iron, I have the Z80 project to solder, and three different arduino powered projects for the father-in-laws DCC train-set hobby to work on, so all those are coming this way, the first will be to mount the arc welding effect lighting into a single board solution.  Then I have an RGB effect lighting board to build to emulate a glowing set of fires for him.  Then finally a 5v DC motor project to power with PWM and emulate a set of coal-mine head stocks turning.



Thursday, 12 May 2016

Failed Windows versus Linux Rant

I'll be honest, I was coming to write to you all today to give windows another well-deserved roasting.  Unfortunately, I found the same issue in Linux.  Well, when I say issue, perhaps this is my own expecting something more logical from a system.

Lets take a look at the folder I'm talking about:
  
It's any folder you like, within it, I've created a folder called ".example", another without the leading period "example" and then a file which includes the word "example" within it's file name.

When I go to search this directory, with the explorer search bar within the window presented, I expect it to work by using exactly what I type...

So, if I search for "txt", only the "example.txt" file should come up, and it does...

But if I search for "example", I'm getting three results, as they contain the word, therefore I aim to be more specific and search for ".example"... The result of this last search:


Yup, I still get all three results.  Clearly only one item matches ".example", and this annoys me.

And I jumped to Linux to take screen shots of this not working this way, but I found ls does work this way too... To be more specific I had to use "find":


This annoys me, I want the search to be specific, unless I add wildcards like "?" or "*" then I want what I type to be what it searches for, and if they have to put dumbed down searches in there, make it obvious that what you're getting is not an exact match.

The reason?... Imagine you have 300,000 files and you select 2,49 of then based on an exact filename search, and you give it a cursory glance, assume it to be correct, select all and delete?!?!?!

Yes, you end up deleting a load of stuff you didn't intend.

And I know, I know, I assumed what it was doing, and I know assumption is the mother of all fuck up, but still....

Even more annoying however, whilst setting up this example on windows, I did find something minor to moan about:


You can't create a folder which starts with a period in Explorer...


But you can with DOS/Command Prompt!