Friday, November 20, 2009

How Not To Make A Corporate Web Site

Ok, Time to blow off some steam.

I think I have found the worst large corporation web sit there is.
www.motorola.com

What I was trying to do is simply find the manual for a Motorola XTS 5000 portable radio so I can hook it up to a PPP serial port on my Vista laptop.

Sounds easy, huh?

Well I tried the obvious, I googled Motorola XTS 5000 manual.
All the results are for very unsafe web sites for manuals, none of which actually have the manuals.

(Annoyed)

A few links were to www.motorola.com, but all actual documents were just marketing brochures with no details.

Their search function is so broken as to be nearly useless.

(Anger level rising, 1 hour wasted)

I finally called support and was told that all those manuals are on Solutions - Motorola USA
though "solutions" was obviously used as a euphemism for "marketing".
But I would need to register to get an online acocunt and it would take two days.

So I went to the site to sign up. Wow, I think the signup form was designed by committee where any field that was suggested was put in.

Ok, this is silly. All I wanted was to find an online manual for a radio. Instead I got a process that would make passage of Obama's Medical Fiasco look easy.

So while I waste two work days waiting for a simple piece of information, I noticed that there is a feed back email address. Ohhhh, nifty. So I careful write a short email about the shortcomings of the site. Yup, you guessed it, the email bounced.

So If it wasn't for the fact that my job requires that I get this software written...

Ok, I'm done. All better now.

Oh, and let me theorize how the web site got this way...
All the CXX managers of Motorola fought over getting their pet project in, and the web designer inside Motorola was ignored. Nobody any where the top of the organization has ever actually used the site to try to do anything remotely like what a customer would do. The web site is obviously organized by someone who is thinking about what they want the customer to see, and has no idea at all about what the customer actually wants.

TF

Three days later, after the weekend, yet another hurdle to cross.
This is regarding your account with us. Will you be reselling our products? Or will it be for your own company use?
If for company use than please state you are taxable. If for resell then fill out the attached tax cert and fax back
to NNN-NNN-NNNN

Aaaaaargh!

TF

Tuesday, October 20, 2009

COM Port Listing in C#

Ok, here is the problem.
How does one get a listing of COM ports in C# ?

The short answer is...

String[] portNames = System.IO.Ports.SerialPort.GetPortNames();

Like most short answers it is correct but not useful.
The resulting list is a series of entries like "COM14". In my application I want the
list to have the long port description like "Prolific USB-to-Serial Bridge (COM16)"

This is tricky. There can be regular serial ports and there can be USB dongles with serial ports.

So what you do instead is first list the ports and make a list of them with both the simple name
and a friendly name that are the same.
Then you look through the plug n play devices for COM ports and get the Name from that.
Like this...


using System.Management;
using System.IO;

Then ...


private void SetupCOMPortInformation()
{
String[] portNames = System.IO.Ports.SerialPort.GetPortNames();
foreach (String s in portNames)
{
// s is like "COM14"
COMPortInfo ci = new COMPortInfo();
ci.portName = s;
ci.friendlyName = s;
ComPortInformation.Add(ci);
}

String[] usbDevs = GetUSBCOMDevices();
foreach (String s in usbDevs)
{
// Name will be like "USB Bridge (COM14)"
int start = s.IndexOf("(COM") + 1;
if (start >= 0)
{
int end = s.IndexOf(")", start + 3);
if (end >= 0)
{
// cname is like "COM14"
String cname = s.Substring(start, end - start);
for (int i = 0; i < ComPortInformation.Count; i++)
{
if (ComPortInformation[i].portName == cname)
{
ComPortInformation[i].friendlyName = s;
}
}
}
}
}
}

static string[] GetUSBCOMDevices()
{
List list = new List();

ManagementObjectSearcher searcher2 = new ManagementObjectSearcher("SELECT * FROM Win32_PnPEntity");
foreach (ManagementObject mo2 in searcher2.Get())
{
string name = mo2["Name"].ToString();
// Name will have a substring like "(COM12)" in it.
if (name.Contains("(COM"))
{
list.Add(name);
}
}
// remove duplicates, sort alphabetically and convert to array
string[] usbDevices = list.Distinct().OrderBy(s => s).ToArray();
return usbDevices;
}



And we need the list element class...


public class COMPortInfo
{
public String portName;
public String friendlyName;
}



There you are.

Oh, and as extra credit. This code lets you list every possible Management class.



private static void ListAllManagementClasses()
{
string cimRoot = "root\\";
ManagementClass nsClass = new ManagementClass(
new ManagementScope(@"root"),
new ManagementPath("__namespace"),
null);
foreach (ManagementObject ns in nsClass.GetInstances())
{
try
{
Console.WriteLine(cimRoot + ns["Name"].ToString());
ManagementClass newClass = new ManagementClass(cimRoot + ns["Name"].ToString());
EnumerationOptions options = new EnumerationOptions();
options.EnumerateDeep = true; // set to false if only the root classes are needed
ManagementObjectCollection moc = newClass.GetSubclasses(options);
foreach (ManagementObject o in moc)
{
if (o["__SuperClass"] == null)
Console.WriteLine(o["__Class"]);
else
Console.WriteLine("\t" + o["__Class"]);
}
}
catch (Exception ex)
{
Console.WriteLine("Exception: " + ex.Message);
}
}
}


Thursday, August 20, 2009

SATA RAID

Ok, for a compter game we are working on we need to record full HDMI video to make a marketing trailer. My current computer could not handle it at all.

First the math: HDTV is 1290 x 1080 at 24 frames per second.
That works out to 1.4 MPixels at 3 bytes per pixel is 100 MB per second.
But there is also sound and some other overhead.

So we went to NewEgg and bought parts:
  • RAIDMAX SAGITTA 2 ATX-928WB Black case. (Cool blue lights!)
  • ECS Black Series A790GXM-AD3 AM3 AMD 790GX HDMI ATX AMD Motherboard
  • AMD Phenom II x4 955 Black Edition Deneb 3.2 Ghz AM3 socket Quad-Core CPU
  • 6 GB Ram
  • 4 SATA Western Digital Caviar 160 GB Drives
  • Vista Home Premium 64 Bit
  • DVD SATA Drive
  • A Screen 22" wide screen
  • RAIDMAX 630W Power supply (More nifty blue lights)
  • Silver Thermal Past (not needed)
  • Cables etc.
The total was 1005.34 USD

We also have a BlackMagic Intensity Pro for 200 USD. This is a HDMI video grabber card and claims to be able to suck up full HDMI video.

So it all showed up in about 3 days. Lots of boxes.

We put it all together.

Then configured it in the BIOS for RAID 5. That was a mistake. RAID 5 means that 3 of the 4 disks are used in parallel for reads and writes, and one is used for parity error correction. This makes it more reliable. After all the install and config, we put in the disk speed test program that came with the Intensity Pro, and we were getting about 350 MB per second read, but only about 50 MB/Sec write. It would never do for what we needed.

(I think the parity generation was slowing it down.)

So...

We reconfigured for RAID 0 with all four disks. This uses all 4 disks in parallel for reads and writes. After a complete reinstall of Vista etc. we ran the disk test again.

450 MB/Sec read and write.

Smokin'

This box is amazing. The click and open on programs is almost instantaneous.

TF

Tuesday, August 11, 2009

XNA Screen Projection

In XNA there is a method,

Vector3 GraphicsDevice.Viewport.Project(Vector3 source, Matrix projection, Matrix view, Matrix world)

that converts a world point to screen coordinates.

The return value is a Vector3. The X and Y is the screen location of the point. It may not be
within the GraphicsDevice.Viewport if the object is "off screen".

One point of possible confusion is the Z part of the return value. It is the depth into the Z buffer.
Your projection matrix has a near and far plane. A Z value of 0 is right on the far plane and is very far away into the screen. A Z value of 1 is a point near the observer, right on the screen plane.

A value of 0.5 would be half way between the far and near planes.

If the Z value is greater than one then the point is behind the observer.

After calling Project, you should check the Z value and if it is greater than 1 then don't draw anything.

Note: if the Z value is > 1 then that means that X and Y must be negated to figure out where the object is relative to the screen. This is important if you are doing a "Mario Smash Bros." style arrow that points off screen at an object that has flown off the edge. But Smash Bros has it easy because no objects ever can get behind the observer.

The reason that X and Y have to be negated is simple. Imagine that the object is behind your head while you are looking at the screen. Draw a line from the object, through your head, to the screen. That is the screen location of the object.

Note: UnProject is a method that does the inverse of Project. It converts a screen location (don't forget the Z part) to world space.

TF

Friday, July 10, 2009

The Easy Programming Allusion

The Utopian Requirement
On many project, I have seen the following logic...

  • Lets have a easy scripting language or visual programming lanuge so non-programmers can customize the system.
  • We currently have to have programmers put in custom code for each customer's need and it is expensive.
  • We'll let the analyst at the customer's company do the change instead so it is easy and inexpensive.
The Reality of Programming
What is wrong with this picture?

There are two types of changes to systems, configuration parameters, and code.
A configuration parameter is usually a single number or setting that has a very limited set of valid values. For example the department names in a company. Some programmer has thought out in advance what all the possible valid values will be and designed the program to handle them.
The second type of change is the one that causes the most trouble. It is a change in the logic and processing of the program. For example, maybe a 'if' statement that then calls any method available in the program to do processing. Such changes can bring down the whole house of cards that is the program.
Programmers deal with this by knowing the system well, making changes and debugging and testing.

The Flaw
The desire of management is to make such changes easy for a non-programmer. But there is a basic contradiction here. They want a person that does not know the code well, to make the change and not thoroughly test the whole system for interactions.

The Reality
What happens in the real world of product roll out, customer complaints, and emergency fixes to save the sales reps. account, is that the customer quickly gets the application into a state where is will not run, and then a programmer from the company ends up making the change, only now it is some 'scripting language' that is less flexible and powerful than the native language of the application.

The Exception
There is one exception in the real world to this logic, Excel.
Excel is the most widely used programming language in the world and is used mostly by non-programmers.

Why does this exception exits?
Because Excel spreadsheet language is a highly domain specific language in it's simple form. It lets you do simple math on cells. There is no sequential programming being done, no 'if' statements, and a highly limited and sanitized method set. If you make a mistake it tends to be located in exactly the cell you are editing.
Then Excel has deeper programming constructs which most users never use. Thus in some ways it is not being used as a programming language so much as simply customizing settings on cells, which are simple math.

The Secret Solution
There is a sweet spot of customization where the user is not programming, but simply customizing settings. If you can reduce your customers job to 'configuration' then you win.

So here is Keene's Rule of Customization:

"Only let your customer configure."

TF

Tuesday, June 30, 2009

Wrong Science, Write Answer, Wrong Execution

Congress is soon to pass a climate bill.

Wrong Science ?
The climate debate and the science behind it is inconclusive. On one side is the view the we create global warming by emitting CO2 and should stop it before the climate goes haywire and we have a disaster.

The evidence to support Global Warming is fairly good, and in some areas is the current best science we have. That does not make it correct and also the debate is not over. When the debate is over then science has stopped and there is nothing more to discover.

On the other side is the belief that Global Warming is not happening, or if it is, it is not our fault. The science for that point of view is also fairly good.

The data about global climate is buried under so many layers of politics, dogma, academic reputations and such, that even reading the raw scientific papers does not arrive at any clear conclusion.

So lets make a big assumption, that the whole Global Warming thing is one big mistake and hoax.


Write Answer
Ok, so then why cut carbon emissions, and do the economically painful, switch to non fossil fuels?

  • Firstly, the USA is currently shoveling cash at unbelievable rates at other nations to buy their oil. This is unsustainable from any point of view. (Yeah Pickens Plan!) We will go bankrupt as a nation trying to buy foreign energy.
  • Second, The oil is running out. We are just about out of 'Easy Oil' and as oil becomes more scarce, the price will be come increasingly volatile. As oil becomes harder to get, the funds to research and build a non-oil base infrastructure will not be available.
  • Third, The environment (not the climate) is damaged by fossil fuel burning, starting with the lungs of Humans.
  • Fourth, Oil is used to make plastics and fertilizer, not just for energy. The world food supply and much our modern junk we buy at WalMart is dependent on oil. It does not need to be. Fertilizer can be made from air and electricity. Plastics are the difficult one, and rubber for tires. That might be a far better use of oil.

Wrong Execution
So hooray for Obama and the climate bill. It forces a reduction in fossil fuel use and dependence on foreign oil.

And now for the main point (drum roll please)

The massive tax that the new climate bill represents $175 per household, with 105,480,101 households in the USA so that would be 18 billion dollars. There has been absolutely no talk about how the fees collected as 'carbon taxes' would be spent. There has also been no talk about how much money the carbon credits would rais for the government. The 18 billion dollar estimate is the best I can do for now. Maybe it is more like a trillion dollars? Who knows? It does not get talked about.

Not only that, there are zillions of loopholes in the bill so that the major emmiters of carbon won't suffer too much. So who is going to suffer if we are to actualy reduce carbon emissions? I bet it will be the middle class, as usual.

My crystal ball tells me that the money will go to social spending.

The correct answer should be to earmark ALL the money gathered from carbon sin taxes to alternate energy.

Could you imagine what 18 billion dollars of research into algae oil would do?

TF


Footnote: The down side...
Obama's climate bill will bankrupt the nation, while spending the money on 'lets be happy' programs. This will result in an economy with no money to change over to alternate energy, an no time to research alternatives before the oil runs out, leaving us in poverty and despair. Nations in poverty have no desire to help the environment. Conclusion: Obama's climate bill will be the worst thing ever for the climate.

Go Google 'The law of unintended consequences.'

Friday, June 12, 2009

What is 1 + 1?

  • A five year old: two
  • A mathematician: That is arbitrary symbol system and unless I know which system you are using the answers are infinite.
  • A Physicist: 1.95 +- 0.01
  • A Poet: The many splendors of love...
  • A Computer Programmer: printf("%d\n", 1+1);
  • A Computer Scientist: 10
  • Bush: that is classified for national security reasons.
  • Obama: How about we fund that research out of the stimulus money?
  • A Drunk: Shoe.
  • A Policeman: I'll ask the questions here unless you want to get tasered.
  • A Ninja: (Could not find one to ask)
  • Chuck Norris: That would be my Punch (tm) followed by my hallmark Roundhouse Kick (tm).
  • A Manager: Lets hold a meting to plan the response to that question.
  • A Consultant: I see we are funded for three weeks work, so come back in three weeks for the answer.
  • A Tester: Your program crashed while calculating the answer.
  • Buddha: Your attachment to the number one causes suffering for all beings.
  • The Pope: The correct question is what is 1 + 1 + 1.
  • Global Warming Alarmists: Our simulation shows that the answer will be increasing over time.
  • Global Warming Deniers: Our leading scientist says the answer is 2 but has recently been fired for saying so.
  • Mormons: Actually 1 + 2 or 1 + 3 works well too.
  • McDonald's Employee: Do you want fries with that.
  • Picasso: N