2015年11月19日 星期四

hexdump - format output

hexdump -s 0x2f -n 7 -e '7 1 "%c" ' 1 7  repeat 7 times 1  each time for 1 byte

2015年10月13日 星期二

Linux C dev tips

errno.h strerror (errno) dlfcn.h void *handle; handle = dlopen("libkido.so", RTLD_LAZY); if (!handle) { fprintf(stderr, "%s \n", dlerror()); exit(EXIT_FAILURE); } int (*test)() = dlsym (handle,"test3"); if (!test) { fprintf(stderr, "%s \n", dlerror()); exit(EXIT_FAILURE); } int a; a=(*test)();

Linux C program tips

compile object files gcc -c 1.c --> automatically generate 1.o file link object files and generate binary file gcc -o app 1.o 2.o main.o build archives -- static library ar cr libkido.a 1.o 2.o main.o gcc -L . -lkido -o app build shared library gcc -c -fPIC 1.c --> automatically generate 1.o file gcc -shared -fPIC -o libkido.so main.o 1.o 2.o gcc -o app -L . -lkido -Wl,-rpath,./ <-- if rpath is not defined, LD_LIBRARY_PATH need to be defined in environment variable to have the binary locate library file

2015年1月23日 星期五

PMbus access

1st byte of rtn is length and last byte is for nothing if you want to read 9bytes data, you need to specify length 11 in i2c master write-read command, when length is set to 0, BMC will perform i2c write.

gcc object file linking

gcc -c xxx.c --> automatically generate xxx.o gcc yyy.c xxx.o --> automatically generate a.out You can use functions defined in xxx.c without including any header files in yyy.c