Hi. I'm new in programming. I'm trying to read data serial port of ly through 
the Palm Vx's serial port. I've written ReadSerial() as below but it doesn't 
work. 

I've two forms, MainForm and TQForm. The application is suppose to send certain 
data to the server. It then reads an acknowledgement frm the server. After 
receiving that acknowledgment (the character 'Y'), it goes to the second form. 
I've also written an alert to display all the data received but that alert 
doesn't work too and regardless of whether the acknowledgement was received, i 
stil go to the next form. 

Pls help. Pls comment on what is wrong. Thanks. 

JSY 

___________ 

static void ReadSerial() 
{ 

char myBuffer; 
char *p; 
UInt32 dataIn; 



//Retrieves number of bytes queueing at the serial port 
Err error4 = SrmReceiveCheck(portID, &dataIn); 

if (error4) 
{ 
FrmAlert(ReadSerialAlert); 
SndPlaySystemSound(sndError); 
return; 
} 

//Retrieve data 
while (dataIn) 
{ 
SrmReceive(portID, &myBuffer, 1, 0, &error4); 


p = &myBuffer; // p points to address of myBuffer 


FrmAlert(IncomingDataAlert); 

//View data coming in 
FrmAlert(*p); 

if (*p == 'Y') 
{ 
FrmAlert(RxSuccessfull); 
break; 
} 
else 
FrmAlert(NothingRx); 

} dataIn--; 

} 

______________________ 

static void WriteSerial(string myString) 
{ 

Err error2 = errNone; 

/*SrmSend returns the number of bytes actually sent. 
*numSent=SrmSend(portID, pointer to the data to send, 
* length of buffer in bytes, returns type of error) 
*/ 
SrmSend(portID, myString.c_str(), 128, &error2); 

if (error2) 
{ 
FrmAlert(WriteSerialAlert); 
SndPlaySystemSound(sndError); 
FrmGotoForm(MainForm); 
} 
else 
ReadSerial(); 
FrmGotoForm(TQForm); 


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

Reply via email to