Sunday, 25 June 2017

Review Comparison: Keweisi and USB Charger Doctor

I am currently evaluating two USB voltage/current tester : Keweisi and USB Charger Doctor.



Here is the data from the picture above:
My trusty Digital Multimeter - 8.87V
Keweisi: 8.99V/1.53A
USB Charger Doctor: 7.49V/1.50A

As some of you will wonder, why the voltage reaches more than 5V? This is because of Samsung's Fast Adaptive Charger, and it can go up to more than 5V. There are good explanations here: Link

Here, the charger switches up to to near 9V. Both the current on two USB voltage/current measurement device are almost identical so let's assume they are both ok. BUT, the voltage are different. It seems to me that the upper limit for the USB charger doctor is only up to 7.5V.

Conclusion:
Keweisi is the clear winner here. It can display the voltage and current at the same time and it can measure more voltage than the USB Charger Doctor.

Saturday, 10 June 2017

Instantiator Based Programming Paradigm (C++)

Recently, I had an issue putting the uWebsockets data type on my project's headers. There were so many compiler errors by just including the datatypes of uWebsockets to my project's header file. Placing both the class declaration and definition inside the cpp source code file resolved the issue. But the next question is how will I instantiate the uWebsockets outside, this is where the instantiator came in.

I discovered by accident, and I like this new paradigm of programming. This way, everyone will be forced to do a very important principle: “Program to Interface, not to an Implementation.” And I don't need to switch to header and source everytime. I can just use the IDE's split window capability to easily edit the declaration and definition. I know this will challenge the norm because we normally separate the declaration and definition to the header and source code file. But I am ready to take criticisms and I will adjust if necessary. But as of this writing, I don't see any disadvantage and instead I only see advantages.

To illustrate here is a very simple source code on how I did it:
Websocket.cpp – Both the class declaration and definition are located here. At the end, you will see the instantiator. It will return an abstract base class pointer.
Websocket.h - This will contain only the instantiator functions.
AbaseWebSocket.h - This the abstract base class that websocket class will inherit.
main.cpp - Demonstration of how to use it.

The instantiator can produce new instances or it could produce a static instance (aka Singleton).
Again, this way, everyone will be forced to do a very important principle: “Program to Interface, not to an Implementation.” Because there is no way for you to be able to instantiate a concrete class because they will all be inside the cpp file, thus you need to go to the necessary abstractions.

Source Code Link

Sunday, 7 May 2017

Animated Hello World : IronPython with XAML/WPF/Blend 2015 /.NET

I created a small tutorial on how to do an animated hello world in IronPython.

Link


Check my Youtube channel as I update it more often than this blog.

Saturday, 4 February 2017

Why Git?

On this post, I would like to highlight the advantages of using Git based on my personal experience. I am currently using TortoiseGit and it helped me increased my productivity. I had used different Version Control Systems (CVS, SVN, TFS, VSS) and I think Git is far more superior than them.

----------------------------------------------------------------------------

Scenario: When I started my career, the way I version control my project is by duplicating/copying the current folder and appending some info onto it. Sometimes, I will zip it. And like for example my project folder name is: MyProject , then I will copy it and rename it to MyProject - Dec 25, 2003 Version 00.08.00 Beta – Added unit test.

I even took it one step further, I created a Python script to automate the archiving and ignore all the files the doesn't need to be stored (like all files and sub-directories on bin\ and obj\).

Problem: Most of the times, you need to see the difference of the original and modified file. It will be very difficult to diff and compare the project files using the scenario above. How git resolves it? With git log, it is easy to compare the files and you can do a personal code review before doing a commit and this is a very big plus. I can also easily see if I accidentally deleted or unintentionally modified some of the codes. Plus, every log has some comments.
Problem: Using the primitive way of copying project folders manually, you will also be copying all the unnecessary things like executables and object files which you can always generate and this may also increase the size of your archieves. How git resolves it? Just create one text file (.gitignore) and it will ignore all the files to be committed.
Problem: People thinks that archiving the project into zip files will yield smaller backups. How git resolves it? That thinking is wrong. I had an old project where I archived it using zip files. I manually ported them to TortoiseGit (and I admit, it was tedious to re-commit that project and I should have used Git in the first place). After finishing, I went to Git Bash and run git gc. Bam! My total git repository size was far way smaller than all the zip files combined!

Conclusion on this Scenario:
I personally feel that the copying of files and/or manually archiving it into zip files is not a good way of doing things. Although that Python script worked perfectly, I think that it was a waste of time.

----------------------------------------------------------------------------

Scenario: Before, the way I reuse source code modules is by copy pasting the source codes into project folder.

Problem: Maintenance problems. Updating all the copies will be very difficult. If you modify that common code and you would like all the projects to use it, then you need to copy paste the updated files. Plus, you don't have any trace-abilities. How git resolves it? Git submodules! This is one of the best features of Git that I love. I have 3 projects and they share one library which is still evolving and being updated constantly. This one shared library is a submodule of the 3 projects and they refer to a single Git repo. Whenever there are new updates, I just do a Git submodule update.

----------------------------------------------------------------------------

I really love Git and I hope I learned it a few years back. I can easily do trial and error on my codes, and if don't like the outcome, I could easily revert it using Git. I can also put my current progress on-hold without committing (using Stash) and go to different branches. I almost use it in everything (e.g. Password manager, resume/CV [I use the diff in MS Word], version control during picture editing). The logging mechanism of any VCS is important and I hope people will start using Git (or any VCS) instead of copying and/or zipping project folders.

Thursday, 22 December 2016

Renesas RX62N: Transmitting data from UART/RS-232 through DMA

Here is an example I created on how to use DMA on Renesas RX62N for transmitting RS-232/UART data.  Link