Monthly Archives: January 2014

Byte Stream to Hex String

Perl one-liner

00c03a701e7900c03a702d2908004500
00602cc000003c11ba74c0a80b05c0a8
0b03043059d9004c0000000000000000
000000000000000000000001549606c8
5f9b0000004400000000000000000000
00000000000000000000000000040002
$ cat message.txt | perl -pe 's/([0-9a-f]{2})/0x$1, /g'
0x00, 0xc0, 0x3a, 0x70, 0x1e, 0x79, 0x00, 0xc0, 0x3a, 0x70, 0x2d, 0x29, 0x08, 0x00, 0x45, 0x00, 
0x00, 0x60, 0x2c, 0xc0, 0x00, 0x00, 0x3c, 0x11, 0xba, 0x74, 0xc0, 0xa8, 0x0b, 0x05, 0xc0, 0xa8, 
0x0b, 0x03, 0x04, 0x30, 0x59, 0xd9, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x54, 0x96, 0x06, 0xc8, 
0x5f, 0x9b, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 

jEdit BeanShell

26 08 00 11 00 00 00 00 00 00 00 1c 72 65 73 74
72 69 63 74 20 31 39 32 2e 31 36 38 2e 37 2e 38
20 76 65 72 73 69 6f 6e 00 00 00 0a 86 be ad 02
89 51 bb 99 9d 7f 15 71 c6 a2 cf d4
Search: [0-9a-z][0-9a-z]
Replace: "0x"+_0+","
0x26, 0x08, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x72, 0x65, 0x73, 0x74,
0x72, 0x69, 0x63, 0x74, 0x20, 0x31, 0x39, 0x32, 0x2e, 0x31, 0x36, 0x38, 0x2e, 0x37, 0x2e, 0x38,
0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x0a, 0x86, 0xbe, 0xad, 0x02,
0x89, 0x51, 0xbb, 0x99, 0x9d, 0x7f, 0x15, 0x71, 0xc6, 0xa2, 0xcf, 0xd4,

Eclipse Indigo SP2 doesn’t know uint8_t

How do I test the current version of GCC?

__GNUC__              = 4 // major
__GNUC_MINOR__        = 8 // minor
__GNUC_PATCHLEVEL__   // patch

Multiple “could not be resolved” problems using Eclipse with minGW

Go to Project -> Properties -> C/C++ General -> Preprocessor Include Paths, Macros, etc. -> Providers -> CDT GCC built-in compiler settings, deactivate Use global provider shared between projects and add the command line argument -std=c++11.

Eclipse 3.7.0 Indigo with CDT shows many false compilation errors

/usr/include/c++/4.6.1
/usr/include/                
/usr/include/c++             
/usr/include/c++/4.6         
/usr/include/x86_64-linux-gnu
/usr/include/asm-generic
/usr/include/c++/4.6.1/x86_64-linux-gnu/
File doesn't include these definitions
/opt/altera12.1sp1/nios2eds/bin/gnu/H-i686-pc-linux-gnu/nios2-elf/include/sys/config.h

__LONG_LONG_MAX__ = 9223372036854775807LL
__LONG_MAX__      = 2147483647L
__WCHAR_MAX__     = 2147483647L
__INT_MAX__       = 2147483647L
__SHRT_MAX__      = 32767L
__SCHAR_MAX__     = 127L

Eclipse CDT Project Properties (nios2_limits.xml)

Vi / Vim “VIsual IMproved”

:%s/foo/bar/g        Find each occurrence of 'foo' (in all lines), and replace it with 'bar'. 

:s/foo/bar/g         Find each occurrence of 'foo' (in the current line only), and replace it with 'bar'. 

:%s/foo/bar/gc       Change each 'foo' to 'bar', but ask for confirmation first. 

:%s/\<foo\>/bar/gc   Change only whole words exactly matching 'foo' to 'bar'; ask for confirmation. 

:%s/foo/bar/gci      Change each 'foo' (case insensitive) to 'bar'; ask for confirmation. 
                     This may be wanted after using :set noignorecase to make searches case sensitive (the default). 

:%s/foo/bar/gcI      Change each 'foo' (case sensitive) to 'bar'; ask for confirmation. 
                     This may be wanted after using :set ignorecase to make searches case insensitive. 

Search and replace

Convert the line endings from DOS to UNIX format

CR = Carriage Return
LF = Line Feed

Betriebssystem Zeichensatz Abkürzung Code Hex Code Dezimal Escape-Sequenz
Unix, Linux, Android, Mac OS X, AmigaOS, BSD ASCII LF 0A 10 \n
Windows, DOS, OS/2, CP/M, TOS (Atari) ASCII CR LF 0D 0A 13 10 \r\n
Mac OS bis Version 9, Apple II, C64 ASCII CR 0D 13 \r
AIX OS & OS/390 EBCDIC NEL 15 21 \025

sed

NAME          sed - stream editor for filtering and transforming text
DESCRIPTION   Sed is a stream editor. A stream editor is used to perform
              basic text transformations on an input stream.
# DOS => UNIX
# replace every "\r" with ""
$ sed "s/\r//" infile >outfile

# UNIX => DOS
# add in every line-end (RegEx $) before \n the character \r
$ sed "s/$/\r/" infile >outfile

How to convert DOS/Windows newline to Unix newline in bash script?
sed Tutorium – Eine Einführung in sed
Useful one-line scripts for sed

tr

NAME          tr - translate or delete characters
DESCRIPTION   Translate, squeeze, and/or delete characters
              from standard input, writing to standard output.
# delete every "\r"
tr -d \r <infile >outfile

SDRAM Timings

Mit der Column Address Strobe Latency (englisch, kurz CL oder CAS Latency), auch Speicherlatenz genannt, wird die Verzögerung zwischen der Adressierung in einem DRAM-Baustein und der Bereitstellung der an dieser Adresse gespeicherten Daten bezeichnet. Die CL gibt an, wie viele Taktzyklen der Speicherbaustein benötigt, um die während des CAS gelieferten Daten zu verarbeiten, bevor er weitere Befehle entgegennehmen, bzw. das Ergebnis mitteilen kann. Je höher der CL-Wert, desto mehr Taktzyklen werden für die Verarbeitung benötigt, womit auch die davon abhängende Verzögerung größer wird.

Wikipedia

Column Address Strobe Latency
Dymanic Random Access Memory (DRAM) # CAS