Saturday, April 18, 2015

Programming Xilinx CoolRunner CPLD XC2C128 via Bus Pirate v3

For the past few days, I am having difficulties to make Bus Pirate v3 work with the stock XSVFplayer frmware JTAG from Dangerous Prototype's website. I fetched the latest source code from the SVN and modified the firmware. Now, my Bus Pirate can upload XSVF files generated by Xilinx ISE to my Xilinx Coolrunner xc2c128 CPLD.

I uploaded the hex file here Link. I used PicKit2 to upload the firmware and I didn't use the Bus Pirate's bootloader.

Sunday, February 22, 2015

Protobuf-net - Did I initialize that list or not?

Protobuf-net is a very great binary serializer for .NET. I use it heavily on my project (memory, file, and over-the-wire serialization).

One of the confusions I recently had is that after I initialized a List, I assumed that it will be serialized into the stream. However, having a zero-length List, it always return null whenever protobuf deserializes the stream. I had seen some developers do a null checking or implement null-coalescing operator operations after they deserialize the stream and those null checking are scattered through-out the code (which violates the DRY principle and is ugly).

One very simple work-around for this is to provide a standard constructor and initialize the List on that constructor. Here is a sample unit test code which demonstrates that.

Special thanks to the protobuf-net author: Marc Gravell

Saturday, February 21, 2015

My C# Naming Conventions

I would like to share the naming conventions that I am using for C#. Link

I use this as a guideline to be able to make my code more readable (especially for big projects) and to be able to identify the type of variable or method in one glance.

Moq (and primitive mocking) Demo

Here is a simple demonstration of using Moq and using a primitive mocking approach.  Link


The 1st approach (using Moq), takes a bit of a learning curve, but it is worth doing it.

The 2nd approach is easier, but at the expense of creating additional dummy class/es.

Friday, February 20, 2015

JSON reading and writing in C#

Here is a very simple example of JSON operation for C#. Link

Wednesday, January 14, 2015

C# code for E-Gizmo's RFID using Observer Pattern

Here is a console application to demonstrate the E-Gizmo's RFID. The code is written in C# / .NET 4.5. This uses simple observer pattern with one subscriber. The code could still be extended to support many subscribers.

Saturday, August 2, 2014

Music: My version of Floyd Rose Tremolo Stopper for my Craftsman EG-95 guitar

Just now, I tried to create a Floyd Rose Tremolo stopper from another cheap floyd rose. I used the saddle/intonation screw and i turned out to be working pretty well. :)  No vibrations nor any problems after the modifications. :)