git archive


To quickly get a source distribution in zip format

git archive --format=zip -o source.zip HEAD source/ README

Assuming, source code is under the folder source. README is a file in the same folder as source. Subfolders ignored by .gitignore are not archived. You can replace HEAD with a commit label. zip can be replaced with tar or tar.gz. See man git-archive for more details.

Posted in Miscellaneous

Color depth


While working with the RFB protocol, I came upon a situation where I receive 16-bit pixels, with red, green, and blue each at 5-bit color depth i.e. each color value ranges from 0 to 31. I need to change each pixel to 24-bit color depth for displaying as a bitmap, or 8-bit for each of red, green, and blue. What works for me is left shifting each of the 5-bit colors by 3 so that each color is 8-bit.

Posted in Software Design

The box lasts longer


…than what comes within it. I got myself an iPhone 6 Plus as a replacement. It’s hard to resist a wish come true.

Posted in Miscellaneous

Comparison of Logic Analyzers


Logic Analyzers

Posted in Miscellaneous

Folders consuming most disk space using du


du is available natively on almost all Linux distributions, and on Mac OS X. If you are in need of reclaiming disk space, and want to quickly find which folders to focus your attention on, run the following command

du -h -d 1

That will quickly list all the folders under the current folder and their disk space usage. Use the following command to check space left on each disk

df -h
Posted in Linux, OS X

Physical serial port redirection


I have previously posted about Virtual serial port redirection on Windows, to develop and test applications that use serial ports. I’ve found the available drivers increasingly buggy on Windows 8.1. This post shows how you can wire two USB-Serial cables to achieve the same objective.

Serial Port Redirection

You’ll need two USB-Serial cables such as USB to TTL Serial Cable for Raspberry Pi from Adafruit or several similar ones from Amazon. Wire the cables so that the ground wires are connected, and receive wire of one cable is connected to the transmit of another and vice-versa. Plug the cables in and install the appropriate drivers. Windows usually works with FTDI chipset based cables without requiring installation of drivers.

Now, you should see two serial ports, which redirect data to each other.

Posted in Hardware

Virtual serial port redirection using socat


Here’s how socat can be used to redirect one serial port to another on Ubuntu

sudo socat -d -d pty,link=/dev/ttyS0,raw,echo=0 pty,link=/dev/ttyS1,raw,echo=0

Assuming both serial devices above are not assigned to a real device. If the above command is successful, you can send data from on serial port to another using a terminal emulator such as screen

screen /dev/ttyS0 115200

Install screen using sudo apt-get screen if not already installed. Repeat the above command on another prompt for the other serial device, and you’re good to go. Quit screen using Ctrl-A \.

socat can also be used to perform serial to TCP redirection

sudo socat -d -d pty,link=/dev/ttyS0,raw,echo=0 tcp-listen:8000

Now, you should be able to use screen to send and receive data on the serial port, while you use something like netcat to receive and send data to the serial port

netcat 127.0.0.1 8000
Posted in Linux
Follow

Get every new post delivered to your Inbox.

Join 79 other followers

%d bloggers like this: