hi, Dave:
Thanks again for your help.
In fact, I did declare memory for buffer.
What I did was that
unsigned char x_source[512]; //declare x as memory for data
And in function
static void do_channel() //in the function, I was calling for getting data
from PC
{
Err serror;
// unsigned int x;
unsigned char COMM_REQUEST;
unsigned char SAMPLE_READY_FLAG;
UInt temp = 0;
SysLibFind("Serial Library",&SerL);
SerOpen(SerL,0,4800);
for (temp = 0; temp<2; temp++)
{
// SerReceiveFlush(serial_lib,0);
if (temp == 0) {
Get_Buffer_Data(1,25,x); // x is passed to function
SAMPLE_READY_FLAG = 0;
SerReceiveFlush(serial_lib,0);
}
else
Get_Buffer_Data(1,25,x);
}
Handle_Old_MF_Data();
SerSend(serial_lib,"LDUOK",5,&serror);
}
static Boolean Get_Buffer_Data (unsigned char buffer_num,unsigned int
num_bytes , void * buf )
{
Err serror;
unsigned char buffer_sent;
char* bufchar;
num_bytes = 25;
SerReceive(serial_lib,buf,num_bytes,SERIAL_TIMEOUT,&serror);
SAMPLE_READY_FLAG = 1;
bufchar=buf;
StrPrintF(reading_buf,"%s",bufchar);
fieldptr_ldu_ch3v = FrmGetObjectPtr(FrmGetActiveForm(),
FrmGetObjectIndex(FrmGetActiveForm(), fieldID_ldu_ch3v));
FldSetTextPtr(fieldptr_ldu_ch3v, reading_buf);
FldRecalculateField(fieldptr_ldu_ch3v, true);
return 1;
}
Rignt now there is one strange thing happen. No matter what kind of data I
type into PC (letters or numbers), there is number "1" which always appear
in the field I define. I don't understand at all, and I don't know what is
happening when I try to pass character or number to palm pilot.
Would you mind give me some hint for this??
Thank you
Allen
-----Original Message-----
From: Dave Lippincott [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 27, 1999 11:47 AM
To: [EMAIL PROTECTED]
Subject: Re: Please help with serial communication
>static Boolean Get_Buffer_Data (unsigned char buffer_num,unsigned int
num_bytes , void * buf )
The pointer passed as buf must point to memory, not just another pointer.
Good:
char MyBuffer[128];
Get_Buffer_Data(x,127,MyBuffer);
Bad:
char *MyBuffer;
Get_Buffer_Data(x,127,MyBuffer);
If buf points to a pointer without enough memory allocated, the best you
could hope for is strange results, the worse would be a program that crashes
constantly.
-----Original Message-----
From: Allen Yang <[EMAIL PROTECTED]>
To: '[EMAIL PROTECTED]' <[EMAIL PROTECTED]>
Date: Friday, August 27, 1999 10:36 AM
Subject: RE: Please help with serial communication
>Hi,Dave:
>Thank you for your email. I am not sure how to find the memory? Would you
>mind explain to me more?
>
>Thank you.
>
>Allen
>
>-----Original Message-----
>From: Dave Lippincott [mailto:[EMAIL PROTECTED]]
>Sent: Friday, August 27, 1999 9:03 AM
>To: [EMAIL PROTECTED]
>Subject: Re: Please help with serial communication
>
>
>Another thing to look at: you buffer variable...where are you allocating
>memory for it? The buffer is not allocated memory by SerReceive.
>
>-----Original Message-----
>From: Allen Yang <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
>Date: Thursday, August 26, 1999 8:18 PM
>Subject: Please help with serial communication
>
>
>>Hi,
>>I tried to get some data from PC. And my code just won't work. anyone can
>>help me with it?
>>
>>static void do_channel()
>>{
>> Err serror;
>>// unsigned int x;
>> unsigned char COMM_REQUEST;
>> unsigned char SAMPLE_READY_FLAG;
>> UInt temp = 0;
>>
>> for (temp = 0; temp<2; temp++)
>> {
>>
>> if (temp == 0) {
>> Get_Buffer_Data(1,25,x); // this is the function for
>>getting data
>> SAMPLE_READY_FLAG = 0;
>> SerReceiveFlush(serial_lib,0);
>> }
>> else
>> Get_Buffer_Data(1,25,x);
>>
>> }
>>}
>>
>>static Boolean Get_Buffer_Data (unsigned char buffer_num,unsigned int
>>num_bytes , void * buf )
>>{
>> Err serror;
>> unsigned char buffer_sent;
>> char* bufchar;
>> num_bytes = 25;s
>>
>>
>>
>> SerReceive(serial_lib,buf,num_bytes,SERIAL_TIMEOUT,&serror);
>> SAMPLE_READY_FLAG = 1;
>>
>> bufchar=buf;
>>
>> StrPrintF(reading_buf,bufchar);
>> fieldptr_ldu_ch3v = FrmGetObjectPtr(FrmGetActiveForm(),
>>FrmGetObjectIndex(FrmGetActiveForm(), fieldID_ldu_ch3v));
>> FldSetTextPtr(fieldptr_ldu_ch3v, reading_buf);
>> FldRecalculateField(fieldptr_ldu_ch3v, true);
>>
>> return 1;
>>}
>>
>>I really don't know what is wrong with my code, and what is the problem ?
>>
>>Please help me out.
>>
>>Thanks ad advance.
>>
>>Allen
>>
>
>
>