David,

The Ir send operation is asynchronous. That is, it does not complete the send
operation before it returns from the IrDataReq function. In this case it appears
that you have declared local data on the stack as your send buffer. You queue
the data up to be sent and then return from the function. By the time the IrDA
stack gets around to really sending the data, the location on the stack you gave
it for a buffer is probably being used by another function. The constant string
value works because that memory location will not change over time. You should
either allocate your send buffer globally, or allocate it with MemPtrNew and
free it after the send operation completes. Send buffers should not be allocated
on the stack.

--- Gavin

>   char newmessage[30];
>   StrPrintF(newmessage,"1");
>   IR_Send(newmessage);

>IR_Send (CharPtr sendbuf)
>{
>  irPack.len = StrLen(sendbuf);
>  irPack.buff = (BytePtr) sendbuf;
>  IrDataReq ( refNum, &IrCon, &irPack );
>}

>Can anyone see what I'm doing wrong?  I'm just trying to send a simple
>integer back and forth and somehow I'm getting some kind of poinDter
>problem.  Any ideas?  Thanks for the help.


Reply via email to