Monday, January 31, 2011
Power Grid System Study Notes.
Positive DPF indicates net energy flow is from source to load (configuring load direction is explained later in this document) and negative DPF indicates net energy flow is from ‘load’ back to the ‘source’. Similarly, positive phase angles indicate current is leading voltage (capacitive load) and negative phase angles indicate current is lagging voltage (inductive load).
Sunday, January 23, 2011
Constant string shared accross classes.
In C++ using g++
------------------------
#ifdef THREAD_CLASS_CPP
const GSN_S8 *SPI_BUS_SYNCH="tA"; //0x7441;
#else
extern const GSN_S8 *SPI_BUS_SYNCH;
#endif
In C using gcc
---------------------
#ifndef DWIFI_C
extern const char ATI_REPLY_OK[];
#else
const char ATI_REPLY_OK[]="I/OK";
#endif
------------------------
#ifdef THREAD_CLASS_CPP
const GSN_S8 *SPI_BUS_SYNCH="tA"; //0x7441;
#else
extern const GSN_S8 *SPI_BUS_SYNCH;
#endif
In C using gcc
---------------------
#ifndef DWIFI_C
extern const char ATI_REPLY_OK[];
#else
const char ATI_REPLY_OK[]="I/OK";
#endif
Sunday, January 9, 2011
Thursday, January 6, 2011
FW: Multiple inheritance (C++ only)
[1] http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Fcplr134.htm
class A { /* ... */ };
class B { /* ... */ };
class C { /* ... */ };
class X : public A, private B, public C { /* ... */ };
class L { /* ... */ }; // indirect base class
class B2 : public L { /* ... */ };
class B3 : public L { /* ... */ };
class D : public B2, public B3 { /* ... */ }; // valid
class A { /* ... */ };
class B { /* ... */ };
class C { /* ... */ };
class X : public A, private B, public C { /* ... */ };
class L { /* ... */ }; // indirect base class
class B2 : public L { /* ... */ };
class B3 : public L { /* ... */ };
class D : public B2, public B3 { /* ... */ }; // valid
Wednesday, January 5, 2011
GCC byte alignment for data structure
[1] http://www.velocityreviews.com/forums/t651650-does-gcc-has-compile-option-for-bytes-alignment.html
[2] detailed gcc user manual see http://gcc.gnu.org/onlinedocs/gcc-4.3.5/gcc.pdf
IN GCC
---------------------------------------------
__attribute__((aligned(4)))
__attribute__((packed))
#include
#include
struct struct_1{
unsigned char byte1;
unsigned short word2;
unsigned char byte3;
unsigned char byte4;
unsigned char byte5;
}__attribute__((aligned(1)));
struct struct_1_packed{
unsigned char byte1;
unsigned short word2;
unsigned char byte3;
unsigned char byte4;
unsigned char byte5;
}__attribute__((packed));
struct struct_2{
unsigned char byte1;
unsigned char byte2;
unsigned char byte3;
unsigned char byte4;
unsigned char byte5;
}__attribute__((aligned(1)));
int main (int argc, char *argv[])
{
struct struct_1 One;
struct struct_2 Two;
struct struct_1_packed Three;
printf("size of struct one is %d\n",sizeof(struct_1));
printf("size of struct two is %d\n",sizeof(struct_2));
printf("size of struct three is %d\n",sizeof(struct_1_packed));
}
ScreenPrint 'size of struct one is 8'
'size of struct two is 5'
'size of struct two is 6'
IN PIC32
------------------------------------------
typedef struct cableTrackerConfigFrHostStruct
{
S_CABLETRACKER_CONFIG_COM sComConfig;
S_CABLETRACKER_CONFIG_DAQ sDaqConfig;
GSNTYPES_USHORT iChkSum;
}
#ifdef TARGET
__attribute__((packed)) S_CABLETRACKER_CONFIG_IN_SDCARD;
#else
S_CABLETRACKER_CONFIG_IN_SDCARD;
#endif
[2] detailed gcc user manual see http://gcc.gnu.org/onlinedocs/gcc-4.3.5/gcc.pdf
IN GCC
---------------------------------------------
__attribute__((aligned(4)))
__attribute__((packed))
#include
#include
struct struct_1{
unsigned char byte1;
unsigned short word2;
unsigned char byte3;
unsigned char byte4;
unsigned char byte5;
}__attribute__((aligned(1)));
struct struct_1_packed{
unsigned char byte1;
unsigned short word2;
unsigned char byte3;
unsigned char byte4;
unsigned char byte5;
}__attribute__((packed));
struct struct_2{
unsigned char byte1;
unsigned char byte2;
unsigned char byte3;
unsigned char byte4;
unsigned char byte5;
}__attribute__((aligned(1)));
int main (int argc, char *argv[])
{
struct struct_1 One;
struct struct_2 Two;
struct struct_1_packed Three;
printf("size of struct one is %d\n",sizeof(struct_1));
printf("size of struct two is %d\n",sizeof(struct_2));
printf("size of struct three is %d\n",sizeof(struct_1_packed));
}
ScreenPrint 'size of struct one is 8'
'size of struct two is 5'
'size of struct two is 6'
IN PIC32
------------------------------------------
typedef struct cableTrackerConfigFrHostStruct
{
S_CABLETRACKER_CONFIG_COM sComConfig;
S_CABLETRACKER_CONFIG_DAQ sDaqConfig;
GSNTYPES_USHORT iChkSum;
}
#ifdef TARGET
__attribute__((packed)) S_CABLETRACKER_CONFIG_IN_SDCARD;
#else
S_CABLETRACKER_CONFIG_IN_SDCARD;
#endif
Tuesday, January 4, 2011
Linux Segmentation fault debugging.
[1] http://www.cprogramming.com/debugging/segfaults.html
[2] http://prefetch.net/blog/index.php/2006/12/21/generating-core-files-from-gdb/
% gdb example core
Some copyright info
Core was generated by `example'.
Program terminated with signal 11, Segmentation fault.
Some information about loading symbols
#0 0x0804838c in foo() () at t.cpp:4
4 *x = 3;
(gdb)run
(gdb)generate-core-file
Saved corefile core.2575
(gdb)detach
--------------------------------------------------
[3] https://stackoverflow.com/questions/8545931/using-gdb-to-convert-addresses-to-lines
addr2line -e /path/to/non-stripped/.../my-buggy-app 0x4a6889 0x4a8b43 0x4e8765
[2] http://prefetch.net/blog/index.php/2006/12/21/generating-core-files-from-gdb/
% gdb example core
Some copyright info
Core was generated by `example'.
Program terminated with signal 11, Segmentation fault.
Some information about loading symbols
#0 0x0804838c in foo() () at t.cpp:4
4 *x = 3;
(gdb)run
(gdb)generate-core-file
Saved corefile core.2575
(gdb)detach
--------------------------------------------------
[3] https://stackoverflow.com/questions/8545931/using-gdb-to-convert-addresses-to-lines
addr2line -e /path/to/non-stripped/.../my-buggy-app 0x4a6889 0x4a8b43 0x4e8765
------------------------------
qyang@lgm-pc:~/Git_Local_DnM_Dev/GitPro-Builder/builder$ addr2line -C -f -e ./build/exports/arm-angstrom-linux-gnueabi-release/bin/gem 0x7aeb8
CPlaybackTrackerManager::RemoveTracker(unsigned long)
??:?
$ addr2line -C -f -e ./build/exports/arm-angstrom-linux-gnueabi-release/bin/gem 0xf18cc
CDPMSClient::GetBugFixList(unsigned long, CCUXmlParser::_TBugFixInfo*)
??:?
---------------------------
/lib/libc-2.25.so(__default_rt_sa_restorer+0x0)[0xb5e59bd0]+0x2cbd0
/usr/lib/lib_resampler.so(ia_error_handler_log.part.0+0x70)[0xb6a886d0]+0x56d0
$ export PATH=$(pwd)/build/exports/host/toolchain/bin/arm-aios63-linux-gnueabi/bin:$PATH
$ arm-aios63-linux-gnueabi-addr2line -Cf -e build/exports/arm-aios63-linux-gnueabi-release/build/resampler/lib_resampler.so 56d0
ia_error_handler_log
/home/doug/current_dev/build/thirdparty/ittiam/src/ia_error_handler.c:85
$ arm-aios63-linux-gnueabi-addr2line -Cf -e build/exports/arm-aios63-linux-gnueabi-release/sysroot/lib/libc-2.25.so +0x2cbd0
__default_rt_sa_restorer
/home/doug/current_dev/build/exports/host/toolchain/src/.build/src/glibc-2.25/signal/../sysdeps/unix/sysv/linux/arm/sigrestorer.S:80
Subscribe to:
Posts (Atom)