Other Parts Discussed in Thread: AM3352
Tool/software: TI C/C++ Compiler
Chip: am3359
compiler: ti v5.2.5
ide CCS8.2.0
screenshots:
1. My senior colleague said that if those error info appear on console windows, that means system is crushed.
2. And he said that setting a breakpoint to function "Exception_Fun" such that one can trace the bug. Unfortunately, I'm not able to understand those instructions by now.
3. So I take another way, I looked debug console to check where is the last location before jumping into "Exception_Fun". It seems to be function "DNM_contain".
4. I then decided to comment this line 74, where DNM_contain is only called here.
Then I built the program again and run about 1 minute more. No error appeared on console. I guess I can make a conclusion that something goes wrong in function "DNM_contain".
Here is the test case:
/* * DNM_Manager.c * * Created on: 2019�~1��8�� * Author: no95 */ /* * DNM_Manager.h * * Created on: 2019�~1��8�� * Author: no95 */ /* * typecast.h * * Created on: 2018�~12��27�� * Author: no95 */ void DNMObject_ctor(void* _this, void* name, unsigned int ip, unsigned int sn, unsigned int subMask); void* DNMObject_new(void); void* DNMSet_new(void); void* DNM_contain(const void* _set, const void* _element); /*****************************************************************************/ /* STDIO.H v15.4.0I15142 */ /* */ /* Copyright (c) 1993-2015 Texas Instruments Incorporated */ /* http://www.ti.com/ */ /* */ /* Redistribution and use in source and binary forms, with or without */ /* modification, are permitted provided that the following conditions */ /* are met: */ /* */ /* Redistributions of source code must retain the above copyright */ /* notice, this list of conditions and the following disclaimer. */ /* */ /* Redistributions in binary form must reproduce the above copyright */ /* notice, this list of conditions and the following disclaimer in */ /* the documentation and/or other materials provided with the */ /* distribution. */ /* */ /* Neither the name of Texas Instruments Incorporated nor the names */ /* of its contributors may be used to endorse or promote products */ /* derived from this software without specific prior written */ /* permission. */ /* */ /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ /* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ /* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ /* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* */ /*****************************************************************************/ /*****************************************************************************/ /* linkage.h v15.4.0I15142 */ /* */ /* Copyright (c) 1998-2015 Texas Instruments Incorporated */ /* http://www.ti.com/ */ /* */ /* Redistribution and use in source and binary forms, with or without */ /* modification, are permitted provided that the following conditions */ /* are met: */ /* */ /* Redistributions of source code must retain the above copyright */ /* notice, this list of conditions and the following disclaimer. */ /* */ /* Redistributions in binary form must reproduce the above copyright */ /* notice, this list of conditions and the following disclaimer in */ /* the documentation and/or other materials provided with the */ /* distribution. */ /* */ /* Neither the name of Texas Instruments Incorporated nor the names */ /* of its contributors may be used to endorse or promote products */ /* derived from this software without specific prior written */ /* permission. */ /* */ /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ /* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ /* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ /* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* */ /*****************************************************************************/ #pragma diag_push #pragma CHECK_MISRA("-19.4") /* macros required for implementation */ /* No modifiers are needed to access code or data */ /*--------------------------------------------------------------------------*/ /* Define _IDECL ==> how inline functions are declared */ /*--------------------------------------------------------------------------*/ #pragma diag_pop /*****************************************************************************/ /* stdarg.h v15.4.0I15142 */ /* */ /* Copyright (c) 1996-2015 Texas Instruments Incorporated */ /* http://www.ti.com/ */ /* */ /* Redistribution and use in source and binary forms, with or without */ /* modification, are permitted provided that the following conditions */ /* are met: */ /* */ /* Redistributions of source code must retain the above copyright */ /* notice, this list of conditions and the following disclaimer. */ /* */ /* Redistributions in binary form must reproduce the above copyright */ /* notice, this list of conditions and the following disclaimer in */ /* the documentation and/or other materials provided with the */ /* distribution. */ /* */ /* Neither the name of Texas Instruments Incorporated nor the names */ /* of its contributors may be used to endorse or promote products */ /* derived from this software without specific prior written */ /* permission. */ /* */ /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ /* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ /* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ /* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* */ /*****************************************************************************/ #pragma diag_push #pragma CHECK_MISRA("-20.2") /* standard headers must define standard names */ #pragma CHECK_MISRA("-19.10") /* need types as macro arguments */ typedef struct __va_list { void * __ap; } va_list; #pragma diag_pop #pragma diag_push /* using declarations must occur outside header guard to support including both C and C++-wrapped version of header; see _CPP_STYLE_HEADER check */ /* this code is for C++ mode only and thus also not relevant for MISRA */ #pragma CHECK_MISRA("-19.15") #pragma diag_pop /*---------------------------------------------------------------------------*/ /* Attributes are only available in relaxed ANSI mode. */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* A header file conforming to ARM CLIB ABI (GENC-003539), should */ /* define _AEABI_PORTABLE when _AEABI_PORTABILITY_LEVEL is defined. */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* The macro definition that guards CLIB ABI (GENC-003539) requirements. */ /*---------------------------------------------------------------------------*/ /****************************************************************************/ /* TYPES THAT ANSI REQUIRES TO BE DEFINED */ /****************************************************************************/ typedef unsigned size_t; typedef struct { int fd; /* File descriptor */ unsigned char* buf; /* Pointer to start of buffer */ unsigned char* pos; /* Position in buffer */ unsigned char* bufend; /* Pointer to end of buffer */ unsigned char* buff_stop; /* Pointer to last read char in buffer */ unsigned int flags; /* File status flags (see below) */ } FILE; typedef long fpos_t; /****************************************************************************/ /* DEVICE AND STREAM RELATED MACROS */ /****************************************************************************/ /****************************************************************************/ /* MACROS THAT DEFINE AND USE FILE STATUS FLAGS */ /****************************************************************************/ /****************************************************************************/ /* MACROS THAT ANSI REQUIRES TO BE DEFINED */ /****************************************************************************/ /******** END OF ANSI MACROS ************************************************/ /****************************************************************************/ /* DEVICE AND STREAM RELATED DATA STRUCTURES AND MACROS */ /****************************************************************************/ extern FILE _ftable[10]; extern char __TI_tmpnams[10][16]; /****************************************************************************/ /* FUNCTION DEFINITIONS - ANSI */ /****************************************************************************/ /****************************************************************************/ /* OPERATIONS ON FILES */ /****************************************************************************/ extern int remove(const char *_file); extern int rename(const char *_old, const char *_new); extern FILE *tmpfile(void); extern char *tmpnam(char *_s); /****************************************************************************/ /* FILE ACCESS FUNCTIONS */ /****************************************************************************/ extern int fclose(FILE *_fp); extern FILE *fopen(const char *_fname, const char *_mode); extern FILE *freopen(const char *_fname, const char *_mode, register FILE *_fp); extern void setbuf(register FILE *_fp, char *_buf); extern int setvbuf(register FILE *_fp, register char *_buf, register int _type, register size_t _size); extern int fflush(register FILE *_fp); /****************************************************************************/ /* FORMATTED INPUT/OUTPUT FUNCTIONS */ /****************************************************************************/ extern int fprintf(FILE *_fp, const char *_format, ...) __attribute__((__format__ (__printf__, 2, 3))); extern int fscanf(FILE *_fp, const char *_fmt, ...) __attribute__((__format__ (__scanf__, 2, 3))); extern int printf(const char *_format, ...) __attribute__((__format__ (__printf__, 1, 2))); extern int scanf(const char *_fmt, ...) __attribute__((__format__ (__scanf__, 1, 2))); extern int sprintf(char *_string, const char *_format, ...) __attribute__((__format__ (__printf__, 2, 3))); extern int snprintf(char *_string, size_t _n, const char *_format, ...) __attribute__((__format__ (__printf__, 3, 4))); extern int sscanf(const char *_str, const char *_fmt, ...) __attribute__((__format__ (__scanf__, 2, 3))); extern int vfprintf(FILE *_fp, const char *_format, va_list _ap) __attribute__((__format__ (__printf__, 2, 0))); extern int vfscanf(FILE *_fp, const char *_fmt, va_list _ap) __attribute__((__format__ (__scanf__, 2, 0))); extern int vprintf(const char *_format, va_list _ap) __attribute__((__format__ (__printf__, 1, 0))); extern int vscanf(const char *_format, va_list _ap) __attribute__((__format__ (__scanf__, 1, 0))); extern int vsprintf(char *_string, const char *_format, va_list _ap) __attribute__((__format__ (__printf__, 2, 0))); extern int vsnprintf(char *_string, size_t _n, const char *_format, va_list _ap) __attribute__((__format__ (__printf__, 3, 0))); extern int vsscanf(const char *_str, const char *_fmt, va_list _ap) __attribute__((__format__ (__scanf__, 2, 0))); /****************************************************************************/ /* CHARACTER INPUT/OUTPUT FUNCTIONS */ /****************************************************************************/ extern int fgetc(register FILE *_fp); extern char *fgets(char *_ptr, register int _size, register FILE *_fp); extern int fputc(int _c, register FILE *_fp); extern int fputs(const char *_ptr, register FILE *_fp); extern int getc(FILE *_p); extern int getchar(void); extern char *gets(char *_ptr); extern int putc(int _x, FILE *_fp); extern int putchar(int _x); extern int puts(const char *_ptr); extern int ungetc(int _c, register FILE *_fp); /****************************************************************************/ /* DIRECT INPUT/OUTPUT FUNCTIONS */ /****************************************************************************/ extern size_t fread(void *_ptr, size_t _size, size_t _count, FILE *_fp); extern size_t fwrite(const void *_ptr, size_t _size, size_t _count, register FILE *_fp); /****************************************************************************/ /* FILE POSITIONING FUNCTIONS */ /****************************************************************************/ extern int fgetpos(FILE *_fp, fpos_t *_pos); extern int fseek(register FILE *_fp, long _offset, int _ptrname); extern int fsetpos(FILE *_fp, const fpos_t *_pos); extern long ftell(FILE *_fp); extern void rewind(register FILE *_fp); /****************************************************************************/ /* ERROR-HANDLING FUNCTIONS */ /****************************************************************************/ extern void clearerr(FILE *_fp); extern int feof(FILE *_fp); extern int ferror(FILE *_fp); extern void perror(const char *_s); /*****************************************************************************/ /* stdlib.h v15.4.0I15142 */ /* */ /* Copyright (c) 1993-2015 Texas Instruments Incorporated */ /* http://www.ti.com/ */ /* */ /* Redistribution and use in source and binary forms, with or without */ /* modification, are permitted provided that the following conditions */ /* are met: */ /* */ /* Redistributions of source code must retain the above copyright */ /* notice, this list of conditions and the following disclaimer. */ /* */ /* Redistributions in binary form must reproduce the above copyright */ /* notice, this list of conditions and the following disclaimer in */ /* the documentation and/or other materials provided with the */ /* distribution. */ /* */ /* Neither the name of Texas Instruments Incorporated nor the names */ /* of its contributors may be used to endorse or promote products */ /* derived from this software without specific prior written */ /* permission. */ /* */ /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ /* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ /* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ /* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* */ /*****************************************************************************/ #pragma diag_push #pragma CHECK_MISRA("-6.3") /* standard types required for standard headers */ #pragma CHECK_MISRA("-8.5") /* need to define inline function */ #pragma CHECK_MISRA("-19.1") /* #includes required for implementation */ /*---------------------------------------------------------------------------*/ /* Attributes are only available in relaxed ANSI mode. */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* A header file conforming to ARM CLIB ABI (GENC-003539), should */ /* define _AEABI_PORTABLE when _AEABI_PORTABILITY_LEVEL is defined. */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* The macro definition that guards CLIB ABI (GENC-003539) requirements. */ /*---------------------------------------------------------------------------*/ #pragma diag_push #pragma CHECK_MISRA("-5.7") /* keep names intact */ typedef struct { int quot, rem; } div_t; typedef struct { int quot, rem; } ldiv_t; typedef struct { long long quot, rem; } lldiv_t; #pragma diag_pop typedef unsigned short wchar_t; /*---------------------------------------------------------------*/ /* NOTE - Normally, abs, labs, and fabs are expanded inline, so */ /* no formal definition is really required. However, ANSI */ /* requires that they exist as separate functions, so */ /* they are supplied in the library. The prototype is */ /* here mainly for documentation. */ /*---------------------------------------------------------------*/ #pragma diag_push #pragma CHECK_MISRA("-16.4") /* false positives due to builtin declarations */ int abs(int _val); long labs(long _val); long long llabs(long long _val); #pragma diag_pop int atoi(const char *_st); long atol(const char *_st); long long atoll(const char *_st); int ltoa(long val, char *buffer); extern double atof(const char *_st); long strtol(const char *_st, char **_endptr, int _base); unsigned long strtoul(const char *_st, char **_endptr, int _base); long long strtoll(const char *_st, char **_endptr, int _base); unsigned long long strtoull(const char *_st, char **_endptr, int _base); float strtof(const char *_st, char **_endptr); double strtod(const char *_st, char **_endptr); long double strtold(const char *_st, char **_endptr); int rand(void); void srand(unsigned _seed); void *calloc(size_t _num, size_t _size) __attribute__((malloc)); void *malloc(size_t _size) __attribute__((malloc)); void *realloc(void *_ptr, size_t _size) __attribute__((malloc)); void free(void *_ptr); void *memalign(size_t _aln, size_t _size) __attribute__((malloc)); void abort(void); typedef void (*__TI_atexit_fn)(void); int atexit(__TI_atexit_fn _func); typedef int (*__TI_compar_fn)(const void *_a,const void *_b); void *bsearch(const void *_key, const void *_base, size_t _nmemb, size_t _size, __TI_compar_fn compar); void qsort(void *_base, size_t _nmemb, size_t _size, __TI_compar_fn compar); void exit(int _status); div_t div(int _numer, int _denom); ldiv_t ldiv(long _numer, long _denom); lldiv_t lldiv(long long _numer, long long _denom); char *getenv(const char *_string); int system(const char *_name); int mblen(const char *_s, size_t _n); size_t mbstowcs(wchar_t *_dest, const char *_src, size_t _n); int mbtowc(wchar_t *_dest, const char *_src, size_t _n); size_t wcstombs(char *_dest, const wchar_t *_src, size_t _n); int wctomb(char *_s, wchar_t _wc); #pragma diag_pop #pragma diag_push /* using declarations must occur outside header guard to support including both C and C++-wrapped version of header; see _CPP_STYLE_HEADER check */ /* this code is for C++ mode only and thus also not relevant for MISRA */ #pragma CHECK_MISRA("-19.15") #pragma diag_pop #pragma diag_push /* C2000-specific additions to header implemented with #include */ #pragma CHECK_MISRA("-19.1") #pragma CHECK_MISRA("-19.15") #pragma diag_pop typedef struct { unsigned int Addr; unsigned int SerialNo; unsigned int SubnetMask; unsigned char Name[40]; }DNM; DNM DNMSet[32]; DNM DNMTemp; /* * * * */ void* DNM_contain(const void* _set, const void* _element) { DNM(*set)[32] = (DNM(*)[32])_set; //set is a pointer to array[32] DNM* element = (DNM*)_element; unsigned char i = 0; while(i <= 31) { if(element->Addr == (set[0]+i)->Addr) { return (set[0]+i); } // printf("%d\n", i); i++; } // printf("%d\n", i); return 0; } void* DNMSet_new(void) { return &DNMSet[0]; } void* DNMObject_new(void) { return &DNMTemp; // u8 i = 0; // while(i <= 33) // { // if (DNMSet[i].Addr == 0) return (&DNMSet[i]); // else i++; // } // return NULL; } void DNMObject_ctor(void* _this, void* name, unsigned int ip, unsigned int sn, unsigned int subMask) { DNM* this = (DNM*)_this; memcpy(&this->Name, name, 40); this->Addr = ip; this->SerialNo = sn; this->SubnetMask = subMask; } void* DNMObject_find(void *_element) { DNM* element = (DNM*)_element; unsigned char i = 0; while(i <= 32) { if (element->Addr == DNMSet[i].Addr) return &DNMSet[i]; else i++; } return 0; } //void DNMObject_update(void* _dest, void* _src) //{ // DNM* dest = (DNM*)_dest; // DNM* src = (DNM*)_src; // dest->Addr = src->Addr; // dest->Name = src->Name; // dest->SerialNo = src->SerialNo; // dest->SubnetMask = src->SubnetMask; //}
"C:/ti/ccsv8/tools/compiler/ti-cgt-arm_5.2.5/bin/armcl" -mv7A8 --code_state=32 --float_support=VFPv3 --abi=eabi -me --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-arm_5.2.5/include" --include_path="C:/ti/ccsv8/ATEIS AM335X/Include" --include_path="C:/ti/ccsv8/ATEIS AM335X/Include/uCOS Include" --include_path="C:/ti/ccsv8/ATEIS AM335X/Include/NandFlash Include" --include_path="C:/ti/ccsv8/ATEIS AM335X/Include/lwip Include" --include_path="C:/ti/ccsv8/ATEIS AM335X/Include/FatSystem" --include_path="C:/ti/ccsv8/ATEIS AM335X/Include/MP3" --include_path="C:/ti/ccsv8/ATEIS AM335X/Include/OSIP" --include_path="C:/ti/ccsv8/ATEIS AM335X/Include/RTP" --include_path="C:/ti/ccsv8/ATEIS AM335X/Include/mmcsdlib" --include_path="C:/ti/ccsv8/ATEIS AM335X/Source Code/Include" --include_path="C:/ti/ccsv8/ATEIS AM335X/Source Code/Include/hw" --include_path="C:/ti/ccsv8/ATEIS AM335X/Source Code/Include/armv7a" --include_path="C:/ti/ccsv8/ATEIS AM335X/Source Code/Include/armv7a/am335x" --include_path="C:/ti/ccsv8/ATEIS AM335X/NANDFlash_Programmer/BurnIN_NAND/Web/httpserver_raw" -g --preproc_with_comment --preproc_with_compile --define=am3352 --define=AM335X --define=_FUNCTION_PERFORMANCE_xx --diag_warning=225 --diag_wrap=off --display_error_number --neon --enum_type=int --wchar_t=16 -k --src_interlist --obj_directory="MCU/DNM" "../MCU/DNM/DNM_Object.c"
Finished building: "../MCU/DNM/DNM_Object.c"
compiler: ti 5.2.5
Source code:
DNM_Object.c: typedef struct { u32 Addr; u32 SerialNo; u32 SubnetMask; u8 Name[40]; }DNM; DNM DNMSet[32]; DNM DNMTemp; void* DNMSet_new(void) { return &DNMSet[0]; } void* DNMObject_new(void) { return &DNMTemp; } void* DNM_contain(const void* _set, const void* _element) { DNM(*set)[32] = (DNM(*)[32])_set; //set is a pointer to array[32] DNM* element = (DNM*)_element; u8 i = 0; while(i <= 31) { if(element->Addr == (set[0]+i)->Addr) { return (set[0]+i); } i++; } return NULL; } void DNMObject_ctor(void* _this, void* name, u32 ip, u32 sn, u32 subMask) { DNM* this = (DNM*)_this; memcpy(&this->Name, name, NAME_SIZE); this->Addr = ip; this->SerialNo = sn; this->SubnetMask = subMask; } ----------------------------------------------------------------------------- Payload_Object.c: void Payload_dtor(void* _this) { free(_this); } ----------------------------------------------------------------------------- void static DNMCmdHndlr_Main(void* p_arg) { OS_ERR err; CPU_TS ts; OS_MSG_SIZE msgSize = 0; OS_SEM_CTR ctr = 0; ATEIS_Payload_s* pl_p = NULL; void* DNM_temp = NULL; void* DNM_set = DNMSet_new(); while(1) { pl_p = OSTaskQPend(0, OS_OPT_PEND_BLOCKING, &msgSize, &ts, &err); //wait for a message if(err == OS_ERR_NONE) { switch(pl_p->Cmd){ case DNM_CMD_HEARTBEAT: DNM_temp = DNMObject_new(); //get one DNM if(DNM_temp != NULL) { DNMObject_ctor(DNM_temp, //initialize this DNM &pl_p->Data[NAME], pl_p->Addr, *(u32*)&pl_p->Data[SN],\ *(u32*)&pl_p->Data[SUBMASK]); DNM_set = DNM_contain(DNM_set, DNM_temp); //check that this DNM is in Set or not } else{ printf("DNM_temp is null\n"); } break; default: break; } Payload_dtor(pl_p); } else{ printf("err is %d\n", err); } ctr = OSTaskSemPost(&DNMPktXcvrTCB, OS_OPT_POST_NONE, &err); //post semaphore } }
<edit>
Hi, there. I've changed
if(element->Addr == (set[0]+i)->Addr) { return (set[0]+i); }
to
if(element->Addr == (*(*set+i)).Addr) { return (*set+i); }
I believe this is no mistake, and system is still crushed.
I now turn my attention to somewhere else because I started to print behavior of both threads(one thread for posting the queue and another for pending the queue) , and somehow found some behavior unexpected.
I'll give a follow-on info if I still can't fix it.