Monday, June 16, 2014

Debug preprocessor, デバッグメッセージ

Debug message
#define SHOW_DEBUG_MSG
#ifdef SHOW_DEBUG_MSG
#include 
#include 

#define DEBUG(format, ...) fprintf (stdout, "[DEBUG] %s(%d): " format "\n", __FUNCTION__ ,__LINE__ ,##__VA_ARGS__)
#else
#define DEBUG(...)  (void)0
#endif // DEBUG

Thursday, May 22, 2014

Ubuntu Android sdk install memo

Androidの開発環境を lubuntuに入れる。
Eclipseはインストールする必要がなく、"adt-bundle-linux-x86-20140321.zip"をGoogleからダウンロードし、unzipしたらeclipseとSdkが入っている。eclipseはそのまま実行すれば、すべてADTなどが入っている。

sdkをPATHに入れる.bashrc:

export PATH=${PATH}:~/.../sdk/tools
export PATH=${PATH}:~/.../sdk/platform-tools
Opengles emulator:
sudo apt-get install libgles2-mesa-dev

Wednesday, May 21, 2014

Embedded Test framewrok

Embedded Test Frame work memo:
- embUnit
 #include 

- Test definition:

static void setup(void) {}
static void teardown(void {}

static void test_func1(void){
 // Test for funcA
 TEST_ASSERT_EQUAL_STRING(exp, actual)
 ...
}

static void test_func2(void){
 // Test for funcA
 TEST_ASSERT_EQUAL_STRING(exp, actual)
 ...
}
...

TestRef Testset_A(void){
 EMB_UNIT_TESTFIXTURE(fixture){
  new_TestFixture("test_func1", test_func1);
  new_TestFixture("test_func2", test_func2);
  ...
 }
 
 // Create a test called "Testname_A"
 EMB_UNIT_TESTCALLER(Testname_A, "Testname_A", setup, teardown, fixtures);
 
 return (TestRef)&Testname_A;
}

Run Test:
#include 

TestRef Testset_A(void);
...

int main(int argc, const char** argv)
{
 TestRunner_start();
 TestRunner_runTest( Testset_A () );
 ...
 TestRunner_end();
 return 0;
}




Thursday, April 17, 2014

Perl batch

Batchファイルを使って一連の処理を実行させたが、Batchはいろいろ不便でPerlスクリプトに切り替える。

1.外部コマンドの実行
$path = 'C:\';
$result = `dir \"$path\"`;
$result = system('dir', "$path");

if($result != 0){
    #ok 
}else{
    #ng
}

2.Yes/No
sub yesno{
  my $comment = shift;
  my $default = shift;
  
  if($default){
    $comment .= " ([y]/n): ";
  }else{
    $comment .= " (y/[n]): ";
    $default = 0;
  }
  my $prv = $|;
  $| = 1;
  print $comment;
  
  $| = $prv;
  my $ans = ;
  chomp($ans);
  $ans = uc($ans);
  
  if($ans eq 'Y'){
    return(1);
  }elsif($ans eq 'N'){
    return(0);
  }
  return($default);
}

Friday, April 04, 2014

My .vmimrc

set autoindent
set nocompatible
set wildmenu wildmode=list:full
set backupdir=$HOME/.vimbak
set shiftwidth=4
set tabstop=4
set smartindent

set whichwrap=b,s,h,l,<,>,[,]

set clipboard=unnamed,autoselect

"---------------------------------------------------
"
set ignorecase
set smartcase

"---------------------------------------------------
set tabstop=4
set noexpandtab
set autoindent
set backspace=indent,eol,start
set wrapscan
set showmatch
set formatoptions+=mM

"---------------------------------------------------
set number
set ruler
" show tab or newline
"set list
"set listchars=tab:>-,extends:<,trail:-,eol:<
"set listchars=eol:<
set nowrap
set laststatus=2
set cmdheight=1
set showcmd
set title
" set colorsheme
colorscheme desert

" hightlight search
set hlsearch

" set syntax
syntax on
"--------------------------------------------------
set nobackup

"--------------------------------------------------
" turn on filetype-plugin
filetype plugin on