I am having problems with some code to read serial i/o.
I only have to receive; don't need to transmit.
My parameters are 19200, None, 7 data bits, 1 stop bit.
I can see that the serial i/o does send but there
must be something I am missing in setting up the port.
I have a button that causes the following code to
execute. This is the only code related to the serial
i/o. I use char buffer[8] to hold the 7 characters
I receive.
Why wouldn't this code receive the 7 characters? Have
I missed something? Is there more setup required? What
should timeout parameters be? Don't think that is
the problem however.
// code used in button event handler
SerSettingsType serSettings;
UInt serRefNo;
SysLibFind("Serial Library", &serRefNo);
serError = SerOpen(serRefNo, 0, 19200);
SerGetSettings(serRefNo, &serSettings);
serSettings.flags = 100;
serSettings.baudRate = 19200;
SerSetSettings(serRefNo, &serSettings);
if(serError != 0) {
FrmCustomAlert(altNotice,"Error", "Open Error", " ");
}
SerSend(serRefNo, "Waiting...", sizeof("Waiting..."), &serError);
SerReceiveFlush(serRefNo, 30000);
serError = SerReceive(serRefNo, buffer, 6, 10000, &serError);
if(serError != 0) {
FrmCustomAlert(altNotice, "Error", "Receive error.", " ");
}
buffer[7]= 0; // terminate received string
SetFieldText(fldTrigger, buffer); // display received chars
SerClose(serRefNo);
handled = 1;
break;
Any help appreciated.
Mike
--
-----------------------------------------------------------------
Discussion Group: http://www.halcyon.com/ipscone/wwwboard/
Protect your constitutional rights. Your favorite one may be next!
-----------------------------------------------------------------