a) are you opening the serial port (its a silly question but I didn't see in
the code you posted)
b) You could use SerReceiveCheck to see if any chars are in the serial
buffer before using SerReceive
c) How long is the time out for SerReceive, I would suggest 0
also, be sure that you are calling SerReceiveFlush when you are positive
there are no chars in the serial buffer.


-----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