Hello
Can you give me some comments rather guidelines on the
following code.
My problem is when i am try to get the total number of
bytes in the receiveing buffer using SerReveiveCheck
error= SerReceiveCheck (refNumP,  &numBytesP);

numBytesP always gives 0.

Can you tell me the way on which i am going to open
the port is currect or not?


thanks

case MainOpenButton :
        if (IsLibFound)
        {
                SerOpenError= SerOpen (refNumP,  port, baud);
                if (SerOpenError==0)  
                {
                        IsPortOpen=true;
                        SerReceiveFlush(refNumP, 200);
                    CommFlags = serSettingsFlagBitsPerChar8 |
serSettingsFlagStopBits1;
                                    
                    SerCommSettings.baudRate = 9600;                                   
                 
                    SerCommSettings.flags = CommFlags;                                 
                         
                    SerCommSettings.ctsTimeout  =
serDefaultCTSTimeout;
                                                    
            error = SerSetSettings(refNumP,
&SerCommSettings);              
                }       
                else if (SerOpenError==serErrAlreadyOpen) 
                {
                        MsgBox("Port is Already Open"," "," ");
                        SerCloseError= SerClose (refNumP);
                }       
                else
                        MsgBox("Error during opening Port...."," "," ");        
        }       
        else
                MsgBox("Serial Library Not Found"," "," ");
                break;  
case MainCloseButton :
        if (IsLibFound)
        {
                SerCloseError= SerClose (refNumP);
                if (SerCloseError==0)  
                {
                        IsPortOpen=false;
                }       
                else if (SerCloseError==serErrNotOpen) 
                        MsgBox("Port was not Opened"," "," ");
                else
                        MsgBox("Error during closing Port...."," "," ");        
        }       
        else
                MsgBox("Serial Library Not Found"," "," ");
                                        break;
case MainSendButton :
    if (IsPortOpen)
    {
                Len= StrLen(GetFieldText(MainSendField));
                NumData=SerSend(refNumP,
GetFieldText(MainSendField),Len, &error);
                if (error == serErrLineErr)
                {
                        MsgBox("Line Error during sending data..."," ","
");
                        SerClearErr(refNumP);                   
                }
                else if (error) MsgBox("Error during sending
data..."," "," ");                                              
        }
        else    
                MsgBox("Port was not Opened"," "," ");
        break;
        
case MainReceiveButton :
        if (IsPortOpen)
        {
                error= SerReceiveWait (refNumP, Len, 500) ;
                if(error==serErrLineErr)
                {
                        MsgBox("Line Error"," "," ");
                        SerClearErr(refNumP);   
                }       
                error= SerReceiveCheck (refNumP,  &numBytesP);
                if (error == serErrLineErr)
                {
                        MsgBox("Line Error during receiving data..."," ","
");
                        SerClearErr(refNumP);                   
                }
                else if (error) MsgBox("Error during Reveiving
data..."," "," ");                                              
                else if(numBytesP>0)
                {
                        NumData= SerReceive (refNumP,
ReceiveBuffer,numBytesP, -1, &error);
                        if(error==serErrLineErr)
                        {
                                MsgBox("Line Error"," "," ");
                                SerClearErr(refNumP);   
                        }       
                        if (error==serErrTimeOut)
                                MsgBox("Time out error"," "," ");
                        else
                        {               
                                SetFieldText(MainReceiveField,ReceiveBuffer);
                                FldDrawField(GetObjectPtr(MainReceiveField)); 
                        }
                }
        }
        break;

--- pjmitchell <[EMAIL PROTECTED]> wrote:
> I have converted an application from the 3.0 SDK to
> 3.5 and have run into 
> some problems around the serial communications. Any
> help/pointers would 
> be greatly appreciated.
> 
> I read that applications should be using the new
> serial manager but I 
> have not been able to find any sample code using it.
> The only sample I 
> found uses the old calls. Are there any examples
> anywhere with the new 
> calls? After converting to the new SDK my
> application seems to get stuck 
> in a loop sending the same data over and over. Under
> the old SDK my app 
> worked fine. And I am having trouble debugging to
> locate the problem.
> 
> I am developing with CW 7 on a Mac using the latest
> POSE. Before 
> converting to these versions I didn't have any
> problems debugging the 
> serial communications with POSE, but now that I have
> converted I can't 
> seem to debug the serial comms. Again, any samples
> that show this working 
> would be really helpfull.
> 
> Thanks,
> Peter
> 
> -- 
> For information on using the Palm Developer Forums,
> or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to