Hi guys
I want to append serial data to a buffer, but I am not really sure how to allocate memory to the buffer; the buffer seems to crash just after a few lines of data.
My code:
ascii * buffer;
.
.
.
void appli_entry_point()
{
buffer = adl_memGet ( 50000 );
V24Handle = adl_fcmSubscribe ( USED_FLOW, V24CtrlHandler, V24DataHandler );
}
bool V24CtrlHandler ( u8 Event )
{
bool bReturn = TRUE;
s32 sReturn;
TRACE (( 1, "serial event %d", Event ));
switch ( Event )
{
case ADL_FCM_EVENT_FLOW_OPENNED :
sReturn = adl_fcmSwitchV24State ( V24Handle, ADL_FCM_V24_STATE_DATA );
TRACE (( 1, "serial switch to datamode %d ", sReturn ));
bFCMIsReady = TRUE;
break;
case ADL_FCM_EVENT_RESUME :
break;
case ADL_FCM_EVENT_MEM_RELEASE :
break;
}
return bReturn;
}
bool V24DataHandler ( u16 Length, u8 * Data )
{
int nwrite;
u16 i;
TRACE (( 1, "Serial data event"));
wm_strcat ( ( ascii * ) buffer, ( ascii * ) Data);
wm_strcat ( ( ascii * ) buffer, ( ascii * ) "\n");
TRACE (( 1, buffer ));
return TRUE;
}
I input this serial string: “$GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CS” line by line.
My results in terminal emulator:
Trace DEV 1 Unable to find the string of the remote trace in the file (ID = 12654)
Trace CUS4 1 Embedded Application : Main
Trace RLU 1 Unable to find the string of the remote trace in the file (ID = 528)
Trace CUS4 1 fcm subscribe
Trace CUS4 1 timer subscribe
Trace CUS4 1 serial event 0
Trace CUS4 1 serial switch to datamode 0
Trace CUS4 1 serial event 2
Trace RLU 1 Unable to find the string of the remote trace in the file (ID = 528)
Trace CUS4 1 Serial data event
Trace CUS4 1 $GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CS
Trace CUS4 1 Serial data event
Trace CUS4 1 $GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CS
$GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CSp/
Trace CUS4 1 Serial data event
Trace CUS4 1 $GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CS
$GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CSp/
$GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CSp/
.
.
.
Trace CUS4 1 Serial data event
Trace CUS4 1 $GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CS
$GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CSp/
$GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CSp/
$GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CSp/
$GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CS[
$GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CSp/
Trace CUS4 1 Serial data event
Trace CUS4 1 $GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CS
$GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CSp/
$GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CSp/
$GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CSp/
$GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CS[
$GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CSp/
$GPZDG,POS_GPS, ...
Trace CUS4 1 Serial data event
Trace CUS4 1 $GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CS
$GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CSp/
$GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CSp/
$GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CSp/
$GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CS[
$GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CSp/
$GPZDG,POS_GPS, ...
Trace RTK 1 Except RTK ....161 57a080 1
The error messages windows I got from the terminal emulator:
Error messages: FATAL ERROR: buffer:Except RTK….%d%x%d
RTK Exception:status:161 param:57a080 taskid:1
What is wrong with my code? Advance thanks!