Page 187 - PDA Robotics Using Your Personal Digital Assistant to Control Your Robot
P. 187
PDA 08 5/27/03 8:47 AM Page 163
Chapter 8 / PDA Robot Palm OS Software Using Code Warrior 8.0
StartApplication loads the IR library, opens and binds a port, saving
the information in the variable irref so it can be used elsewhere. This
is the first step in creating the IrDA link.
//
// Loads the Infrared Library and opens and binds the port.
//
static Boolean StartApplication(void )
{
if (SysLibFind(irLibName,&irref) != 0)
{
FrmAlert(IrLibProblemAlert);
return false;
}
else
{
if (IrOpen(irref,irOpenOptSpeed115200) != 0)
{
FrmAlert(IrLibProblemAlert);
return false;
}
}
IrSetConTypeLMP(&connect);
packet.buff = (unsigned char *)"Data";
packet.len = 4;
IrBind(irref,&connect,callback);
return true;
}
StopApplication unbinds the port, disconnects, and closes the IR con-
nection.
//
// Shut down connections, close the library
//
static void StopApplication(void)
{
IrUnbind(irref,&connect);
if (IrIsIrLapConnected(irref))
IrDisconnectIrLap(irref);
IrClose(irref);
}
163