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
>


Reply via email to