Here I will share some of my insights about embedded and PC software design and modern electronic hardware development. Everyone is welcome to engage into discussion.
Sunday, April 27, 2014
wxWidgets strange modal dialog crashes
Saturday, August 18, 2012
Radio-controlled all-wheel drive Robot based partly on Arduino modules
Today I have attended Chaos Construction 2012 (in Russian) - computers and computer graphics, 8-bit music and demo scene annual festival. For me, one of the most interesting things there was presentation of all-wheel drive radio-controlled robot made partly based on modules from Arduino open-source electronics prototyping platform.
Robo-hobby blog (in Russian) is the official current webpage of these guys (those who are working on a robot, not those who develop Arduino). If you will ever want to learn anything about relatively easy-to-reproduce hand-made radio-controlled robots based on open-source hardware & software components, I would advice to check this blog. Authors share their experience about working on such a project. This is really interesting, even for me, professional electronics developer. I've already added RSS feed of their blog into my feed reader.
Saturday, August 11, 2012
Broken WM_DROPFILES (Drag-and-Drop) functionality in Windows 7
Sunday, June 10, 2012
Bugs in Windows Application Development
Monday, January 16, 2012
Requiem to Phobos-Grunt
Its short flight raised many questions to Roscosmos and even state's officials. Combined with several other satellite launch failures during last year, these questions are especially vital today. Maybe something in the area of top management of Roskosmos is really going wrong, maybe someone still think that world-class high-tech unique things can be developed for amount of money much less than world market suggests. Maybe something is broken at the bottom end of a technological chain, say poor quality control of production.
But here I want to point to only one side of the problem: nowadays, we have many strong rigorous math instruments that can be used to assess reliability and probability of failure for virtually any piece of hardware and software. Researches in the area of development of error-tolerant and reliable hardware and software systems allow one to employ many scientifically proved methods of designing and testing. This is XXI century, at last.
If scarce funding had really taken place, why main engineers and their bosses who were responsible for device subsystems could not just say: "Hey, guys, this is not enough to achieve the project's goals. You either will give us enough resources (time, money, people, equipment, etc.), or we will not sign for the work.". It seems that something is broken in the whole chain of decision making in Roskosmos. Sadly, but such conclusion came to mind after reading news.
Wednesday, November 2, 2011
Multi-Platform User Interface and GTK+
My conclusion is trivial: if you target only one platform, it is better to use GUI libraries created for this particular platform that fully complains with established de-facto standards.
Saturday, October 1, 2011
CRM and Electronics/Software Development
Crew Resource Management explanation on Wikipedia
CRM is all about preventing, detecting and correcting (even potential) human errors at the earliest possible stage, thus achieving the best flight results and safety. If you will regard flight of an aircraft as a multi-people PROJECT, you may naturally see that CRM principles can be applied also to electronics/software multi-people development PROJECTS. Unfortunately, I did not hear that even basics of such approach are studied in any university. This leads to very big role of project leader and his personal communication skills in overall success of any development project.
Such dependency could be mitigated, in my view, by working out and accepting concept of interpersonal communication in software/electronics development industry.
In particular, co-pilots are specially trained to correct the captain and to question potentially wrong decisions if it seems appropriate in a given situation. But in the area of electronics/software development, authoritarian project leader often has too much power and possibilities to send a project in totally wrong direction.
Tuesday, September 20, 2011
Forms (Windows) Interface Font
Standard behavior would be to use default OS Dialog font.
To overcome this, in each form's OnCreate event, invoke the following procedure:
procedure SetFormFontToSystemDefaultFont(Form: TForm);
var
NonClientMetrics: TNonClientMetrics;
begin
NonClientMetrics.cbSize := SizeOf(NonClientMetrics);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @NonClientMetrics, 0);
Form.Font.Handle := CreateFontIndirect(NonClientMetrics.lfMessageFont);
if Form.Scaled then
begin
Form.Font.Height := NonClientMetrics.lfMessageFont.lfHeight;
end;
end;
(Set ParentFont property to True for all controls on the Form for this to have effect).
Sunday, September 18, 2011
Delphi Inactive Forms Behavior
To remedy this, add the following code to your modal forms:
type
TMyForm = class(TForm)
...
protected
procedure CreateParams(var Para: TCreateParams); override;
....
end;
....
procedure TMyForm.CreateParams(var Para: TCreateParams);
begin
inherited;
Para.WndParent := GetActiveWindow;//to allow title flashing of child modal dialogs
end;
Thursday, September 15, 2011
On Interface Design
After noticing that, I began to tend to double-check all my user interface look-and-feel features and logic, although neither of my programs deal with user's financial data.
Tuesday, September 13, 2011
Reusing of Classes in a New Project
Monday, September 12, 2011
64-bit Delphi version is ready
1. 64-bit compilation support
For example, if you have MS Office Add-In, clients will inevitably ask for support of 64-bit MS Office. You have to create 64-bit DLL in order to be able to integrate with any of 64-bit MS Office application, 32-bit, no matter how good it is, will not work. The only plausible solution before was to create a 64-bit stub DLL in Microsoft Visual Studio. Now one can provide 64-bit support without using another IDE.
2. Native Unicode support
Although using of WideString type instead of AnsiString everywhere, and components such as TNT Unicode Controls, in general solves the problem, there still remains some artefacts. For example, you can not register COM server with regsvr32 command, if DLL resides in a path that contains characters which are not representable in the default system Ansi Code Page. And WideStrings was designed to be compatible with system OLE interface calls, and thus they are not reference-counted and use a special system memory allocation routine, which degrade performance. In
contrast, since Delphi 2009, the new native UnicodeString type was introduced, which is reference-counted and uses internal memory manager to allocate space, more efficiently than system-wide does. TNT Unicode controls are also, while work, look a bit like a crutch.
3. Bugs fixing in the IDE
Delphi 7 is convenient IDE, but some intricate bugs sometimes annoy. These include "internal compiler error", AVs, and inability to customize the IDE watches and debug windows in arbitrary way (I constantly got AV after effort to do this). The same applies to C++ Builder 5.5 which I also used for several years.
Embarcadero seems to pay much attention to quality in last years, I hope that their latest products are much more stable.
Unfortunately, C++ Builder XE2 does not yet include 64-bit compilation mode, but its next version anyway seems to fix that. All what is said above, applies also to C++ Builder (I used it for several years).
During last years, Embarcadero are making great efforts to rehabilitate Delphi & Builder IDEs reputation in comparison with MS Visual Studio and open-source competitors. I hope that when demand of support for ARM CPUs will become evident, they will add it in time.
Saturday, September 10, 2011
About testing
The end conclusion that I have drawn is that testing should never be neglected or shrunk. It takes time, but if not done well, the end users will be whose who will find bugs and errors.
Similar thing has to be said about hardware testing. You should never be confident that a given part of device is working properly if it was not properly and thoroughly tested.
Object-Orieneted Systems Analysis and Design using UML
I remembered that personally I too often neglected the software design phase and rushed to write a code, which led to far-worse-than-they-may-be solutions. I did not deal with large-scale systems as described in this book, all my projects were much smaller, but they definitely might (and should) be much better. I hope that even if I will not apply the exact techniques from this book, the systematic approach to software development process described by authors, will remind me about necessity to assign more time for planning and design when the next project will start.
This book on Amazon
Hard-to-find lack of variable initialization issue
Variable "VarName" might not have been initializedBut when you have record-type local variable, and somewhere passes it as a parameter to another function, the Delphi (7) compiler does not check that you have initialized all fields. It will silently use whatever values was in memory at the call stack on the location that was taken for such record field. So you must be especially careful when using local record vars. Doing ZeroMemory on all such records at the very beginning of the function (or procedure/method), seems to be a good habit, otherwise it is a big chance that you will lose some valuable time trying to understand why the program behaves so strange.
To illustrate what has been said, take a look at the following code:
type
TFoo = record
a, b: Integer;
end;
procedure A(Foo: TFoo);
begin
end;
procedure B;
var
Foo: TFoo;
begin
A(Foo);
end;
Compiler will not say anything on A(Foo) source code string.
The following string
ZeroMemory(@Foo, SizeOf(Foo));before A(Foo), if will not make your program free of logical errors, but at least will make the program behavior predictable and reproducible.
Hard-to-find object variable overwriting issue
I started to seek for the reason, and finally it traced to using WideString-type field of the object which passed as now "const" parameter. The code was something like:
procedure TFoo.SetProperty(const APropValue: WideString); ... begin ... FPropValue := APropValue; end; .... procedure TFoo.DoSomething(const APropValue: WideString;...); ... begin ... SetProperty(APropValue); DoSomethingElse(APropValue); end; procedure TFoo.DoSomething2(...); ... begin ... DoSomething(FPropValue); ... end;
The compiler did not detect any issues, yet the problem was
that after invoking of SetProperty, the previous pointer to WideChars array contained in FPropValue field, and in APropValue parameter, becomes invalid, but this old pointer value was used when invoking DoSomethingElse method.
I fixed the problem by eliminating "const" specifier from DoSomething declaration.
Be aware of such a pitfall!