You get a lot of MEDIA_BUSY's from the IR - put the 
IrDiscoverReq()/switch() line in a loop, have it end the loop if it doesn't 
get a MEDIA_BUSY (either the PENDING or the ERROR should stop the loop).

(BTW, a good resource for IR programming at this level is Glen Bachmann's 
Palm Programming book - I believe he even has the chapter on IR programming 
on his web site at http://www.bachmannsoftware.com/)


At 11:41 AM 1/7/00 +0800, you wrote:
>I am trying to write a chat program using Irda between a Palm and PC.
>On the PC side, I use winsock2. I initialize the sock as follow:
>
>SOCKET cli_sock = socket(AF_IRDA, SOCK_STREAM, 0);
>SOCKADDR_IRDA srv_addr = {AF_IRDA, 0, 0, 0, 0, "PALMDEMO"};
>bind(cli_sock,(LPSOCKADDR)&cli_addr,sizeof(cli_addr));
>
>The code work well for 2 PC both have an Irda port.
>
>So I try to program the palm side. I start the Irda service as follow:
>
>  static UInt refNum;
>  static IrConnect IrCon;
>
>  static Byte MyDeviceInfo[] = {IR_HINT_PDA, IR_CHAR_ASCII,
>         'P','A','L','M','D','E','M','O'};
>  static Byte MyDeviceInfoLen = sizeof(MyDeviceInfo);
>
>err = SysLibFind(irLibName, &refNum);
>err = IrOpen(refNum, irOpenOptSpeed9600);
>err = IrBind(refNum, &IrCon, IrHandler);
>IrSetDeviceInfo(refNum, MyDeviceInfo, MyDeviceInfoLen);
>
>irStatus = IrDiscoverReq(refNum, &IrCon);
>switch (irStatus) {
>         case IR_STATUS_MEDIA_BUSY:
>                 SetStatus("IR Status Media Busy");
>                 break;
>         case IR_STATUS_FAILED:
>                 SetStatus("IR Status Failed");
>                 IrUnbind(refNum, &IrCon);
>                 IrClose(refNum);
>                 break;
>         case IR_STATUS_PENDING:
>                 SetStatus("IR Status Pending => Success");
>                 handled = true;
>}
>
>However, function IrDisvocerReq always return IR_STATUS_MEDIA_BUSY while I
>expect a IR_STATUS_PENDING should be returned. We can assume that the
>statements before IrDisvoverReq always return no error.
>
>Do I make any mistake in the statements above, what should I pay attention
>when I
>programming Irda?
>
>Thank you.
>Matchz.


__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com

Reply via email to