Axigen mail server for Windows

I was looking for a mail server for Windows with IMAP v4 support, to use in a project. I came across and installed Axigen. The free version allows 100 accounts, good enough for my needs. They require you to register, and send a license key that is good for a year. The setup was painless. The admin interface is browser based. Setting up IMAP with SSL was straightforward. I needed SSL to use plain authentication using the login command of IMAP. They also have a version for Linux.


Useful references and tools for AVR32 developers

Here’s a list of useful tools and references for AVR32 developers.

  • GCC reference – gcc AVR32006
  • GNU Assembler reference – as
  • GNU linker reference – AVR32795 ld
  • GNU Binary Utilities reference – nm objcopy all
  • GNU C Library reference – libc (AVR32 GNU toolchain ships with avr32-newlib)
  • AVR32 architecture document – pdf
  • AVR32 datasheet – pdf
  • Atmel Studio and AVR32 Studio (see help for AVR32 Software Framework, JTAG etc) – all
  • AVR32 GNU Toolchain (included in Atmel Studio and AVR32 Studio) – binaries

Convert a bin file to hex

I was doing some work today that required converting a raw bin file – read from flash memory using JTAG – to hex. I found the excellent srecord utility that does the job, as follows

srec_cat.exe file.bin -binary -offset 0x80800000  -o file.hex -intel --line-length=44

As I am hacking a AT32UC3 based board, offset is where the application is located on that board. line-length of 44 produces a hex file that has the same line length as the avr32-objcopy utility.

To convert a hex file to binary

srec_cat.exe file.hex -intel -offset -0x80800000 -o file.bin -binary

Note the negative offset. Without it, the large offset address will result in a binary file that is more than 8 MB long.

HxD is a nice freeware binary file editor that you can use to edit the binary file.

Frustrated with gestural interfaces?

This article by Don Norman and Jakob Nielsen cites research that may explain why.

Points to remember regarding C pointers

Some points to remember regarding C pointers:

  1. A pointer is like any value type, but the value it stores is an address, that is why pointers to any type have the same size i.e. value returned sizeof is the same.
  2. A pointer can store the address of another pointer, thus the existence of **.
  3. If defined within a function its scope is auto, it is created on the stack and dies when the function returns.
  4. If passed to another function i.e. callee, the value it stores i.e. the address it points to, is passed to the callee.
  5. To gain access to the value it points to, a pointer has to be dereferenced, this is done by using the * operator.
  6. A pointer that has a value of 0 is called a null pointer.
  7. To get the address of any identifier, the & operator can be used. Don’t pass pointer to a variable of scope auto to a callee that may retain it for use at some future point in time. Once the caller returns, the region of stack used by it is reclaimed, the callee may read values that are, for all effects, junk.
  8. Pointer arithmetic can be used to read array elements, when you add n to a pointer, you are traversing to the nth element in the array.
  9. A pointer may be cast to a struct pointer, and the attributes of the struct read or written to. Beware of byte ordering i.e. endianness, and struct memory alignment, when you memcpy data between devices with different processor architectures. Usage of appropriate compiler directive, packed attribute of GCC for instance, is recommended to prevent padding from causing issues e.g.
    • struct __attribute__ ((__packed__)) identifier {... OR
    • typedef struct {...} __attribute__ ((__packed__)) identifier... OR
    • #pragma pack(1)
  10.  A void * is used to store the address of any arbitrary type.

GStreamer pipeline in C

In a previous post, we implemented live streaming of WebM to browser, using GStreamer and Node.js. In this post, we replace the GStreamer pipeline we spawned in that post, with a native executable that does exactly the same thing.

Here’s the code for the pipeline in C. You can build the code using instructions in this post.

#include <gst/gst.h>
#include <glib.h>

static gboolean
bus_call (GstBus *bus, GstMessage *msg, gpointer data)
  GMainLoop *loop = (GMainLoop *) data;

  switch (GST_MESSAGE_TYPE (msg)) {

      g_print ("End of stream\n");
      g_main_loop_quit (loop);

      gchar  *debug;
      GError *error;

      gst_message_parse_error (msg, &error, &debug);
      g_free (debug);

      g_printerr ("Error: %s\n", error->message);
      g_error_free (error);

      g_main_loop_quit (loop);

  return TRUE;

main (int argc, char *argv[])
  GMainLoop *loop;

  GstElement *pipeline, *videosrc, *colorspace, *videoenc,
    *videoq, *audiosrc, *conv, *audioenc, *audioq, *muxer, *sink;

  GstBus *bus;

  /* Initialisation */
  gst_init (&argc, &argv);

  loop = g_main_loop_new (NULL, FALSE);

  /* Check input arguments */
  if (argc != 2) {
    g_printerr ("Usage: %s \n", argv[0]);
    return -1;

  /* Create gstreamer elements */
  pipeline = gst_pipeline_new ("audio-player");
  videosrc = gst_element_factory_make ("videotestsrc", "videosrc");
  colorspace = gst_element_factory_make ("ffmpegcolorspace", "colorspace");
  videoenc = gst_element_factory_make ("vp8enc", "videoenc");
  videoq = gst_element_factory_make ("queue2", "videoq");
  audiosrc = gst_element_factory_make ("audiotestsrc", "audiosrc");
  conv = gst_element_factory_make ("audioconvert", "converter");
  audioenc = gst_element_factory_make ("vorbisenc", "audioenc");
  audioq = gst_element_factory_make ("queue2", "audioq");
  muxer = gst_element_factory_make ("webmmux", "mux");
  sink = gst_element_factory_make ("tcpclientsink", "sink");

  if (!pipeline || !videosrc || !colorspace || !videoenc
    || !videoq || !audiosrc || !conv || !audioenc || !audioq
    || !muxer || !sink) {
    g_printerr ("One element could not be created. Exiting.\n");
    return -1;

  /* Set up the pipeline */

  /* we set the port number to the sink element */
  g_object_set (G_OBJECT (sink), "port", atoi(argv[1]),
    "host", "localhost", NULL);

  /* set the properties of other elements */
  g_object_set (G_OBJECT (videosrc), "horizontal-speed", 1, NULL);
  g_object_set (G_OBJECT (videosrc), "is-live", 1, NULL);
  g_object_set (G_OBJECT (videoenc), "speed", 2, NULL);
  g_object_set (G_OBJECT (audiosrc), "is-live", 1, NULL);
  g_object_set (G_OBJECT (muxer), "streamable", 1, NULL);

  /* we add a message handler */
  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_watch (bus, bus_call, loop);
  gst_object_unref (bus);

  /* we add all elements into the pipeline */
  gst_bin_add_many (GST_BIN (pipeline),
    videosrc, colorspace, videoenc, videoq, audiosrc, conv,
    audioenc, audioq, muxer, sink, NULL);

  /* we link the elements together */
  gst_element_link_many (videosrc, colorspace, videoenc,
    videoq, muxer, NULL);
  gst_element_link_many (audiosrc, conv, audioenc, audioq,
    muxer, NULL);
  gst_element_link(muxer, sink);

  /* Set the pipeline to "playing" state*/
  g_print ("Streaming to port: %s\n", argv[1]);
  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  /* Iterate */
  g_print ("Running...\n");
  g_main_loop_run (loop);

  /* Out of the main loop, clean up nicely */
  g_print ("Returned, stopping playback\n");
  gst_element_set_state (pipeline, GST_STATE_NULL);

  g_print ("Deleting pipeline\n");
  gst_object_unref (GST_OBJECT (pipeline));

  return 0;

To test, replace the cmd variable with the name of the executable compiled above, e.g.

cmd = './a.out';

Replace args with just one parameter, the muxPort

args = muxPort;

Then, execute Node.js.

Play ogg audio using the Hello World example of GStreamer

The source code of the example in C can be found in the GStreamer application development manual at chapter 10.


I am using Ubuntu 11.04. I installed the following packages. Get the equivalent packages for your distribution.

  • libgstreamer0.10-dev
  • libglib2.0-dev
  • libgtk2.0-dev


Assuming your source code is located in hello_world.c, you can compile the source code thus

gcc hello_world.c `pkg-config --cflags --libs glib-2.0 gstreamer-0.10` -o hello_world


Execute as follows

./hello_world file.ogg