11/20: How to debug a segfault from dmesg log

LinuxShawnNo Comments

When presented with a segfault like this:

segfault at 0 ip b7a64b57 sp bf8fda58 error 4
in libc-2.9.so[b79f1000+13f000]


Problem happened within libc-2.9.so at 0x73b57 in the function strncmp because of a user-mode read access error trying to access 0x0 (NULL)

Read the rest of this entry »

3/6: Quick Wildcard String Compare

UncategorizedShawnNo Comments

Here is a quick function the will allow wildcard comparison.

#include < stdio.h >
int striwildcmp( const char *test, const char *value )
  int result = 0;
  if( test == value ) {
    return 0;
  if( !test ) {
    return -1;
  if( !value ) {
    return 1;
  while( result == 0 ) {    
    // Skip '?' wildcard
    if( *test != '?' ) {
      result = tolower( *test ) - tolower( *value );
    // Break once you compare a null terminator
    if( (*test == '\0') ||  *value == '\0'  ) {
  return result;

Read the rest of this entry »

10/1: Who is Calling Whom?

C, LinuxShawnNo Comments

Have you ever wanted to know which function is calling a specific function. This snippet will help in digging up those pesky dependencies at runtime.

#include < stdio.h >
// Fn Function
void Fn( char* val )
  printf("Ahoy World! %s\n", val);
// Debug Call Conversion
#define Fn(...) \
  printf( "%s:%d %s()\n",__FILE__, __LINE__, __FUNCTION__); \
int main( void )
  return 0;

Read the rest of this entry »

2/3: Auto Update Date Column on Row Change

UncategorizedShawnNo Comments

I was needing a method to automatically update a date field when I adjusted my worksheet row.

Auto Date Worksheet

This is what I ended up with. Change ? to what column you want to track updates on.

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.Count = 1 And Target.Cells.Column = ? Then
        Target(1, 2) = Date
        Target(1, 2).EntireColumn.AutoFit
    End If
End Sub

1/29: Sorting Dates in Access with Nulls

AccessShawnNo Comments

If you need to get a report sorted and grouped by date but your query contains null values use this expression to solve your dilemma.

=IIf([Ship Date] Is Null,1,0)

Within your Group, Sort, and Total Window set the Sort by to expression:


Add in our code. Ok to finish and your nulls are now at the end of the list.

Expression Builder

5/24: Safe Interrupt Enable / Disable

Axiom, HC12ShawnNo Comments

Having trouble switching from cooperative tasking? One of the easiest oversights is your “sei” and “cli” sections.

The diagram below shows how you can run into problems within the critical sections of code. In this example when the memory allocation ends the interrupts are enabled with “cli” removing the critical section around the linked list manager. Once this happens RTI ISR fires and switches in thread 2. This example shows thread 2 popping an item from this list breaking the flow inside of thread 1.

Read the rest of this entry »

4/29: Threading

Axiom, HC12ShawnNo Comments

Threading allows functions to execute concurrently. The example below shows two threads switching between running and sleeping. As the RTI ISR executes it takes the current process off the schedule (list of processes) and switches in the next process on the schedule. Once all processes have been removed from the schedule the “Scheduler” steps in and creates a new schedule.

Read the rest of this entry »

4/16: Hex Memory Dump

UncategorizedShawnNo Comments

Here is a nice looking hex dump for those interested.

ADDR | B0 B1 B2 B3 B4 B5 B6 B7  B8 B9 BA BB BC BD BE BF | 0123456789ABCDEF
0000 | FF D8 FF E0 00 10 4A 46  49 46 00 01 02 01 00 48 | ......JFIF.....H
0010 | 00 48 00 00 FF ED 0A 96  50 68 6F 74 6F 73 68 6F | .H......Photosho
0020 | 70 20 33 2E 30 00 38 42  49 4D 04 04 07 43 61 70 | p 3.0.8BIM...Cap

Read the rest of this entry »

4/7: HC12 Read String or Char

Axiom, HC12Shawn2 Comments

Use this to read a string on the HC12. What this function does is check to see if there is an available character in the HC12’s Serial Communication Interface Port 0 Data Register. If you need to use this function with 9bit values the function needs to be adjusted to incorporate SC0DRH. Similarity if you would like to use Port 1 change SC0 to SC1.

UPDATE: I added the single char version because thats more basic.
Read the rest of this entry »

1/17: ExtUSB AV Cable

HTCShawnNo Comments

HTC ExtUSB Connector

A – USB Ground
B – +5V allows phone to suck 1000mA to charge faster
C – +USB Data Line
D – -USB Data Line
E – +5V @ 1000mA (If you only have 500mA ground B)
1 – Video Out
2 – Audio Right
3 – Ground (Video Sense)
4 – No connection otherwise you loose video
5 – Audio Ground
6 – Audio Left
Shield – Ground / Cable Shield