incubus - an obsession in computing
  • rss
  • Home
  • Linux Apps
    • C&G 4250 Linux Extension
  • C&G 4240
    • Overview
    • Validate Program
    • Sort Program
    • Update / Merge Program
    • Report Program
    • Downloads
  • C&G 4250
    • Overview
    • Data Entry Program
    • Validate Program
    • Sort Program
    • Customer Update / Merge Program
    • Customer Report Program
    • Stock Update / Merge Program
    • Stock Report Program
    • Downloads
  • About
  • Contact

ODB2 Connectors

inc | November 16, 2008 | 7:07 pm

ODB2 (J1962)

Work is still keeping me out of trouble. Found a nice cheap source of OBDII 16 Pin Connectors the other week and they are UK based (Devon). These connectors are well built and low priced (you will have to build your own lead though).

So if you are ever in need of ODB2 (J1962) Connectors then please consider Talk To My Car.
—

Comments
No Comments »
Categories
Linux
Comments rss Comments rss
Trackback Trackback

CLI Battery Status (Acer Aspire One)

inc | October 22, 2008 | 7:10 pm

Found a nice python script for displaying current battery status on the command line, I use this on my Acer Aspire One (110) under Gentoo (spend too much time in console mode). Here is a link to the script (many thanks to Tyler Gates the original author of this script):

http://pastebin.ca/205655

Here is some sample output from the script:

               << BAT1 >>
SIMPLO - UM08A73 | LION | rechargeable
Remaining Charge           : 32.23 %
Time Left                  : 02:30 Hrs
Charging State             : discharging
Rated Capacity Deviation   : -1.79 %
Charge Alert               : ok

The battery installed in the Acer is a nice (but big) 6 Cell 6600mAh available from Amazon at the link below.

Extended Battery for ACER Aspire One Blue ZG5 UM08A73 6600mAh
Extended Battery for ACER Aspire One White ZG5 UM08A73 6600mAh

The battery is big but worth it for the extended usage (well over 7 hours), Below is a picture of the Extended Battery with my Acer Aspire One attached…

Update 16/11/2008:

Just a quick update, this battery is still going strong, the only real issue with it is that it does cause the Acer One to slide about a bit if used on a slippery surface (could do with a couple of anti-slip pads on the base of the battery). Other than that no issues with this thing at all (unlike the issues I’m experiencing with the Acer Store at present … 2 months and counting for a refund to a product that was delayed and the order cancelled?)

—

Comments
1 Comment »
Categories
4240, 4250, Linux, Tips & Tricks
Comments rss Comments rss
Trackback Trackback

Spawning a Process (QNX vs Linux)

inc | October 16, 2008 | 7:43 am

Well work has been keeping me very busy over the last month or so, and will continue to do so way into Christmas. Any way here is a little QNX to Linux porting tip (nothing major)…

When using QNX it was quite easy to start another process from your code:

pid = spawnlp ( P_NOWAIT, "app_name", "app_name", "arg1", "arg_2", ..., NULL);

However under Linux the spawn() family of functions does not exist, so we have to use the fork() and exec() functions:

switch ((pid = fork()))
{ case  0:
    if ((execlp ( "app_name", "app_name",  "arg_1", "arg_2", ..., NULL) == -1))
        _exit(1);
    break;
  case -1:
    break;
}

Also you must also be aware that your process may continue in the running state, so if you wish to make use of the newly forked process you may wish to put a forced delay/yield within the parent process to help produce a context switch to the newly created child process. You will also have to handle the SIGCHLD signal too (signal (SIGCHLD, SIG_IGN), will have the same effect as the QNX NO Zombie option).

—

Comments
No Comments »
Categories
Linux, Tips & Tricks
Comments rss Comments rss
Trackback Trackback

GNOME BitTorrent Client (GTK+)

inc | October 11, 2008 | 12:42 pm

There is an excellent BitTorrent client for the GNOME desktop (GTK+), and it goes by the name Transmission. It’s nice and easy to set-up & configure and it’s already contained with Gentoo’s portage:

emerge -av transmission

Currently standing at version 1.33 it’s been really stable on my system for several months now, a recommended BitTorrent client for Linux / GTK+.

Transmission

Update - 11/11/2008:
Version 1.40 has been released that has improved various elements of the applicaion including more accurate bandwidth limiting (no longer going above the defined upload/download limits). This is a worthy upgrade, so go get it now =))

—

Comments
No Comments »
Categories
Linux
Comments rss Comments rss
Trackback Trackback

Linked Lists (Code)

inc | September 23, 2008 | 12:20 pm

Here is some code that may help with creating a linked list, and also adding and removing elements from it. The code below is for a double linked list, for a single linked list all you have to update is the next pointer as the previous pointer will not be needed (as that is the difference between the two types of list). I shall be using the following data structures throughout the following code examples.

/*-- Stock Master Record ---------------------------------------------------*/
typedef struct
{ char  key[7];
  char  partDesc[20];
  short suppCode;
  long  freeStk;
  short minStk;
  char  moveDate[7];
  float price;
}STOCK_REC;
/*-- Double Linked List ---------------------------------------------------*/
typedef struct STOCK_LIST
{ STOCK_REC rec;
  struct STOCK_LIST *prev; /*-- Pointer to the previous element --*/
  struct STOCK_LIST *next; /*-- Pointer to the next element     --*/
}STOCK_LIST;

Creation of a linked list:

Declare two global pointers that will be used to keep track of the start and end of the linked list (with a single linked list you should only need to to keep a record of the start of the list):

STOCK_LIST *RecFirst  = NULL; /*-- Pointer to start of the link list. --*/
STOCK_LIST *RecFinish = NULL; /*-- Pointer to finish of the link list --*/

Declare a pointer to a list element, this is used to allocate memory for each element in the list.

STOCK_LIST *recElement;

Now follows the actual code that allocates memory for a list element and than adds this element to the end of the list (updating the list pointers as it goes). This is not full code but will do as it says and maybe used in a complete program.

/*-- Allocate memory for the next element in the list --*/
if ((recElement = (STOCK_LIST *)malloc(sizeof(STOCK_LIST))) != NULL)
{ /*-- Populate stock list elements data --*/
  strcpy(recElement->rec.key,      "123456");
  strcpy(recElement->rec.partDesc, "A PART");
  strcpy(recElement->rec.moveDate, "220670");
  recElement->rec.suppCode = 'A';
  recElement->rec.freeStk  = 100;
  recElement->rec.minStk   = 50;
  recElement->rec.price    = 5.99;
  recElement->next         = NULL;

  /*-- If start of list is empty, set this element as the start --*/
  if (RecFirst == NULL)
  { /*-- This element is the start of the list --*/
    RecFirst = recElement;

    /*-- No element precedes this element --*/
    RecFirst->prev = NULL;
  }else
  { /*-- This element is now the final element --*/
    RecFinish->next  = recElement;

    /*-- The element prior to this one is the previous final element --*/
    recElement->prev = RecFinish;
  }
  /*-- Keep the end of list pointer up-to-date --*/
  RecFinish = recElement;

}else
{ printf("Error Creating Linked List - Memory allocation error!\n");
  exit(EXIT_FAILURE);
}

To start with the above may seem quite complicated but when you actually use the code and get used to shifting pointers you will become at ease and fully understand linked list creation. As with all things in life practice makes prefect (I’m far from that).

Inserting an element into a linked list:

If the list is in order then you will want the element inserted into the correct place within the list, to do this you must search the list and locate the element where you want the insertion to follow.

static STOCK_LIST *searchList (char *partNum)
{ STOCK_LIST *recList,
             *prevRec;
  int         res;

  for (recList=RecFirst, prevRec=NULL; recList!=NULL; recList=recList->next)
  { res = strcmp(recList->index.key,partNum);
    if (res == 0)
      return recList;
    else if (res > 0)
      return prevRec;

    /*-- Keep track of the previous record --*/
    prevRec = recList;
  }

  if (prevRec != NULL && prevRec != recFirst)
  { /*-- Element is to be inserted at the end of the list --*/
    return prevRec;
  }else
  { /*-- Element is to be inserted at the start of the list --*/
    return NULL;
  }
}

Now the recList pointer will either point to no where or the element where the insertion is to follow. If the pointer is NULL the element will be inserted at the start of the list. Here is some code that will hopefully show this in action.

/*-- Search the list for the given part number ----------------*/
/*-- Return the previous record if the part num is not found --*/
recList = searchList(partNum);

/*-- Allocate memory for new stock record element --*/
if ((newRec = (STOCK_LIST *) malloc (sizeof(STOCK_LIST))) != NULL)
{ /*-- Populate stock list elements data --*/
  strcpy(recElement->rec.key,      "123457");
  strcpy(recElement->rec.partDesc, "B PART");
  strcpy(recElement->rec.moveDate, "220670");
  recElement->rec.suppCode = 'A';
  recElement->rec.freeStk  = 100;
  recElement->rec.minStk   = 50;
  recElement->rec.price    = 5.99;
  recElement->next = NULL;

  /*-- Insert element in correct position of the list --*/
  if (recList == NULL)            /*-- Start of List --*/
  { newRec->next    = RecFirst;
    newRec->prev    = NULL;
    RecFirst->prev  = newRec;
    RecFirst        = newRec;
  }else if (recList == recFinish) /*-- End of list   --*/
  { RecFinish->next = newRec;
    newRec->prev    = RecFinish;
    newRec->next    = NULL;
    RecFinish       = newRec;
  }else                          /*-- Middle of list --*/
  { newRec->next    = recList->next;
    newRec->prev    = recList;
    recList->next   = newRec;
    newRec->next->prev = newRec;
  }
}else
{ printf("Error Adding to List - Memory allocation error!\n");
  exit(EXIT_FAILURE);
}

Notice the lack of code to handle if the element already exists within the list, this is quite straight forward to add so I will leave for you to complete.

Deleting an element from a linked list:

Again we must search the list for the correct element to remove, we use the same function as used above. Note again I have not included any code to deal with the element not being in the list.

/*-- Search the list for the given part number ----------------*/
/*-- Return the previous record if the part num is not found --*/
recList = searchList(partNum);

/*-- The record was found in the linked list --*/
if(!strcmp(recList->index.key, partNum))
{ zapRec = recList;

  if (recList == recFirst)        /*-- Remove first element --*/
  { recFirst = recList->next;
    recFirst->prev = NULL;
  }else if (recList == recFinish) /*-- Remove last element --*/
  { recFinish = recList->prev;
    recFinish->next = NULL;
  }else                           /*-- Remove middle element --*/
  { recList->prev->next = recList->next;
    recList->next->prev = recList->prev;
  }
  /*-- Free deleted elements memory --*/
  free(zapRec);
}
Comments
1 Comment »
Categories
Code, Linux
Comments rss Comments rss
Trackback Trackback

Linked Lists (Diagrams)

inc | September 22, 2008 | 8:00 pm

OK here is a blast from the past … some diagrams that may help a little with the linked lists and their manipulation. These were originally drawn / written when I was studying for the City & Guilds 4250 course, I hope someone someday finds them of some use.

Insertion at the start of the List:
* Before Insertion into List
* After Insertion into List

Insertion at the end of the List:
* Before Insertion into List
* After Insertion into List

Insertion in the middle of the List:
* Before Insertion into List
* After Insertion into List

Deletion from the start of the List:
* Before Deletion from List
* After Deletion from List

Deletion from the end of the List:
* Before Deletion from List
* After Deletion from List

Deletion from the middle of the List:
* Before Deletion from List
* After Deletion from List

Comments
No Comments »
Categories
Linux, Tips & Tricks
Comments rss Comments rss
Trackback Trackback

Nautilus / GNOME Empty Trash

inc | September 18, 2008 | 6:59 pm

I had some trouble emptying my Trash with Nautilus/GNOME the other day. So here is the trick for removing stubborn items from your Trash (GNOME 2.22.3) if you ever experience the same:

sudo rm -Rf ~/.local/share/Trash/*

If the ‘File Operations’ window is also stuck displaying a non-moving progress bar then you will also need to perform the following action:

killall nautilus

Comments
No Comments »
Categories
Linux, Tips & Tricks
Comments rss Comments rss
Trackback Trackback

Secure Online Backup (GNOME Support)

inc | September 16, 2008 | 7:15 pm

Dropbox is pure magic, no it is honestly. Dropbox provides 2GB of free online storage with the added ability to keep your files synchronised across machines (and operating systems). The sync process is where I think the magic lies, it just works, try it for yourself if you do not believe me …

http://www.getdropbox.com

I have this installed on 1 Windows Machine and 2 Linux Machines, and files get sync instantly  with no user interaction necessary. The Linux version integrates nicely with the Nautilus file manager. You copy files (or delete / modify them) into the Dropbox directory and they get synced for you.

There is an online tour of the features provided by Dropbox, go take a look !!!

http://www.getdropbox.com/tour#1

For Gentoo follow these simple instructions on getting Dropbox installed:

Download the Dropbox source archive from the Dropbox site.
tar -xjvf nautilus-dropbox-x.x.x.tar.bz2
cd nautilus-dropbox-x.x.x
./configure
make
make install
killall nautilus

Dropbox

UPDATE: There appears to be an open Gentoo Bug and attached ebuild for the latest version of Dropbox.

Comments
No Comments »
Categories
Linux
Comments rss Comments rss
Trackback Trackback

« Previous Entries

Recent Posts

  • ODB2 Connectors
  • CLI Battery Status (Acer Aspire One)
  • Spawning a Process (QNX vs Linux)
  • GNOME BitTorrent Client (GTK+)
  • Linked Lists (Code)

Links

  • Demonoid
  • Engadget
  • Gentoo Linux
  • Gentoo Planet
  • Gentoo Universe
  • GNOME
  • GNOME Planet
  • ISO Hunt
  • KernelTrap
  • OS News
  • Piratebay

Archives

  • November 2008 (1)
  • October 2008 (3)
  • September 2008 (7)
  • August 2008 (16)

Navigation

  • Register
  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

Categories

  • 4240 (2)
  • 4250 (2)
  • Code (7)
  • Linux (21)
  • Tips & Tricks (8)
  • Uncategorized (1)
rss Comments rss design by jide powered by Wordpress get firefox
© Copyright 1999-2008 @incubus. All Rights Reserved. All trademarks acknowledged.
incubus.co.uk || zenithpaints.co.uk || rankinstine.co.uk