Patch for Gammu's DCT3 Debug Trace

I’ve written a quick and dirty patch for Gammu’s nokiadebug command. Normally, nokiadebug writes debug traces to a hardcoded out.xml file, which is not really practical.

With my patch applied to gammu-1.24.0, the output of nokiadebug that was previously sent to stdout is now written to stderr. The debug traces are now written to stdout. This way it is much easier to follow the debug traces ‘live’.

You might need to rebuffer gammu’s stdout to emit the complete protocol hierarchy per message at once. The following (pretty ugly) awk does this for you, to add some clarity I’ve added line breaks to what was an even uglier one-liner before:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
hessch@c3:~/gsm$ gammu nokiadebug nhm5_587.txt v18-19 2>/dev/null | awk '
        /^\<l1/ {i=0}
        /^\<\/l1/ { end = 1 }
        {
                if ( i>=0 ) {
                        buf[i] = $0;
                        i++
                };
                if (end == 1){
                        end = 0;
                        for (j = 0; j < i; j++) {
                                print buf[j];
                        };
                        i = 0;
                }
        }
'

You can download my patch from here.

Comments