Wednesday, December 29, 2010

Why can't I write to 0x2AAA or 0x5555

Here is a bin for clues as to why the programming sequence for the Maxtor 28LV010 fails for these special addresses.

The datasheet:

http://about.maxwell.com/pdf/me/product_datasheets/memory/28LV010_Rev6.pdf
from
http://about.maxwell.com/microelectronics/products/memory/eeprom/28LV010.asp

This shows that these addresses are used to unlock the "software protection mode". It seems unlikely that they are completely reserved, however. Most likely we are programming it incorrectly and just haven't figured out the mistake yet. To that end:

The part is a Mitsubishi part, actual part number HN58C1001, which has two AN's at Maxwell:

http://editors.maxwell.com/microelectronics/products/_components/memory/28LV010/app_notes.html

For minor SEU's:
http://editors.maxwell.com/microelectronics/support/app_notes/eeprom_error.html

For why does the documentation suck so much:
http://editors.maxwell.com/microelectronics/support/app_notes/hitachi.html

A search on the Hitachi part number gives links to a "Renesas" datasheet which seems pretty similar to the Maxwell one:

http://documentation.renesas.com/eng/products/memory/rej03c0145_hn58c1001.pdf

That datasheet apparently says that the part ships with software protection off, so the algorithm that we implemented to turn it on all the time may be causing some of our trouble. It also gives a lead for tech support questions.

Earlier, more floundery searching uncovered this datasheet to a different "LV010" part which is by a different manufacturer, and seems to work slightly differently despite having a similar pinout. The key discoveries here are that the software data protection feature is industry standard, and that it is implemented differently in this part than in hitachi's.

http://www.datasheetcatalog.org/datasheets/560/181909_DS.pdf
http://www.atmel.com/dyn/products/product_card.asp?part_id=1911
http://www.atmel.com/dyn/resources/prod_documents/doc0395F.pdf

Tuesday, December 21, 2010

How to prevent a file on a USB drive from being accidentally deleted

I can't wait to try this answer:

http://www.experts-exchange.com/Storage/Storage_Technology/Q_23715466.html

Which says:

You can use NTFS file permissions to prevent casual users from inadvertently deleting files.

Format the stick with NTFS, then (assuming the stick is on E:) type the following console commands:

cd /d E:\
cacls . /T /G Everyone:R /G Administrator:F

Make sure to use "Administrator" and not the plural "Administrators". The former SID is worldwide unique to your computer, the latter isn't. This will allow only your PC to modify the stick.

There is no way to 100% prevent a determined user with admin on their box from modifying your files. A determined user can take ownership and override the ACL. But there will be evidence (the ACL has changed). It is hard to restore a foreign SID to hide the evidence of tampering, without using special tools.


For reference, here are the M$ KB pages for the cacls command and also cd /d which I hadn't seen before:

http://technet.microsoft.com/en-us/library/bb490872.aspx

http://support.microsoft.com/kb/162786

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/chdir.mspx?mfr=true

Monday, December 20, 2010

std::vector

While looking at various online examples of how to do the wxWidgets strip chart, I stumbled across this C++ implementation of the C linked list, the std::vector. This object is so beautiful and solves so many problems that I shall give it its own entry here.

I also ran across the following tutorial that explains how to use std::vectors in such painstakingly simple terms that essentially no other reference is required:

http://www.codeguru.com/cpp/cpp/cpp_mfc/stl/article.php/c4027

More C crutches

Here is a hash list of various bits of information I had to google in this language that I supposedly know:

Here is a reference of all the variable types recognized by Visual Studio 2005. I was entertained by the weird windows double underscore prefixes:

http://msdn.microsoft.com/en-us/library/s3f49ktz(v=vs.80).aspx

Here is a problem that most elementary school kids can solve these days that I had to google for. I liked the way the nerds on this message board chased down all of the wrong answers and shot them dead, leaving some pretty elegant final solutions:

http://www.velocityreviews.com/forums/t634980-p2-convert-32-bit-unsigned-int-to-16-bit-signed-int.html

Printf: The big crutch

The last time I combed through the online pages for printf format specifiers, it was to learn, incredibly enough, that the number of digits printed in the exponent factor for %f and even %g cannot be specified. Depending on the system, it's either always two or three digits (sadly, it's three for my windows C++ displays). Anyhow, here are a couple of super nice and complete descriptions of all the format specifiers:

Of course, cplusplus.com:

http://www.cplusplus.com/reference/clibrary/cstdio/printf/

and also of course, wikipedia:

http://en.wikipedia.org/wiki/Printf

here is a nice copy of the man page, I guess:

http://www.thinkage.ca/english/gcos/expl/c/lib/printf.html

and here is one with examples:

http://www.friedspace.com/cprogramming/outputformats.php

Tuesday, December 14, 2010

wxDateTime::Format() blows

Was getting crashes, of all things, on my call to wxDateTime::Format. The problem turned out to be that where I should have used %S for seconds, I had used %s. This should not be a compiles-fine-but-crashes issue!!!

Making lemonade after lemons, here are a couple of nice pages that I found along the way to figuring this out:

The most examples ever for wxDateTime::Format on a single web page:

http://forums.codeblocks.org/index.php?topic=1587.0

The "Hello World" example in the following verified that when I was building my file name for the dialog box I was using %s correctly:

http://biolpc22.york.ac.uk/wx/docs/html/wx/wx_wxstringoverview.html

However, I was possibly using a wxString incorrectly instead of wxString.c_str() for the source of my %s.

Here is the big table of all the time formatting controls:

http://www.cplusplus.com/reference/clibrary/ctime/strftime/

Here are a few doc pages for the wxWidgets time classes, which are very interesting and full-featured:

http://docs.wxwidgets.org/2.9/overview_datetime.html

http://docs.wxwidgets.org/2.9/classwx_date_time.html

The wxWiki page of file dialogs for babies:

http://wiki.wxwidgets.org/Writing_Your_First_Application-Common_Dialogs

The docs page for file dialogs, for which the examples are pretty weak:

http://docs.wxwidgets.org/trunk/classwx_file_dialog.html

Trying to find wxFile with both hands

So far, I've had to just give up and use fopen and fprintf to write to my text logfile, but I know that a real man would have used wxFile. The problem is, I just can't figure out how to make my wxFile a global object in my application (maybe after I've had more sleep; I guess I'm once again forgetting to consider objects as objects) so that I can open a file, leave it open, and add to it in different subroutines. So, in the meantime, here are my favorite links for wxFile:

Class References:

http://docs.wxwidgets.org/trunk/classwx_file.html

http://biolpc22.york.ac.uk/wx/docs/html/wx/wx_wxfile.html

Forum threads of people with stupid questions like my own:

http://www.programmingforums.org/post132821.html

The inevitable zetcode tutorial (the wxFile stuff is towards the end):

http://zetcode.com/tutorials/wxwidgetstutorial/helperclasses/

A google books result (this book looks pretty nice, actually):

http://books.google.com/books?id=CyMsvtgnq0QC&pg=PA397&lpg=PA397&dq=using+wxFile&source=bl&ots=SSdvj7Lnva&sig=FltKY36kTFWrPluhkgCbJgsLsQk&hl=en&ei=4q8HTZ7kO4-enwfAuqTmDQ&sa=X&oi=book_result&ct=result&resnum=6&ved=0CCgQ6AEwBQ#v=onepage&q=using%20wxFile&f=false

And finally, the example-laden page from Cprogramming.com on how to use fopen and fprintf:

http://www.cprogramming.com/tutorial/cfileio.html