Page 208 - PDA Robotics Using Your Personal Digital Assistant to Control Your Robot
P. 208
PDA 09 5/27/03 8:50 AM Page 184
// Display the error in the status indicator
// PDA Robotics
int last_error = WSAGetLastError();
_itoa(last_error, &err_buff[0], 10);
msg = "socket error";
msg += err_buff;
this->m_status_window.SetWindowText( (LPCTSTR) msg);
return;
}
//
// Set the status inidcator that we are moving forward
//
this->m_status_window.SetWindowText( (LPCTSTR) msg);
}
void CPDABotDlg::OnRange()
{
// Below is how you would query for the range data
char err_buff[10];
char irda_buffer[128];
u_long numbytes;
int ret;
//
// Send PDA Robot the command prompting it to get the range data and
// forward it to us
//
ret = send( Infrared_Socket, (const char *) "d", 1 , MSG_DONTROUTE);
if ( ret == SOCKET_ERROR)
{
int last_error = WSAGetLastError();
_itoa(last_error, &err_buff[0], 10);
return;
}
//
// You may want to get this data in the timer after giving PDA Robot some time to
respond
//
//
// Ensure that we won't be blocked waiting here on the function
184