> Hi all,
> i am trying to write a serial port routine to send some data. Using MW5 and the 
>latest emulator on a win95  machine.
>
> basic code is.... minus error checking..
>
> err = SerOpen(SerialPortRef, 0, 9600);
> byte_check = SerSend(SerialPortRef, message_string, byte_count, &err);
> err = SerSendWait(SerialPortRef, -1);
> SerClose(SerialPortRef);
>
> This all happens on a button press event.
> Looking at what it sends on a oscilliscope you see 3 low going pulses but  no data.
>
> If I put a break point in after the SerSend then it works fine. If it seems to be 
>losing the last couple of bytes. (Doesn't seem to work on the Palm III either)
>
> Any ideas what I am doing wrong?
>

It's possible that the CTS timeout is happening in SerSendWait():

>From the docs...
"SerSendWait blocks until all data is transferred or a timeout error
(if CTS handshaking is enabled) occurs. This routine observes the
current CTS timeout setting if CTS handshaking is enabled (see
SerGetSettings and SerSend)."

This would explain why the breakpoint on the SerSend() makes it work,
since you give it plenty of time to send the data.

When I open the serial port, I set up the CTS timeout using something
like this:

  SerSettingsType serSettings;
  serSettings.baudRate = 19200;
  serSettings.flags =
   serSettingsFlagBitsPerChar8 |
   serSettingsFlagStopBits1 |
   serSettingsFlagRTSAutoM | serSettingsFlagCTSAutoM;

 serSettings.ctsTimeout = (SysTicksPerSecond() / 2);
 err = SerSetSettings (refNum, &serSettings);

This sets a 1/2 second timeout for CTS. What's your CTS timeout?


--

   John Schettino - http://members.tripod.com/schettino/
  CORBA For Dummies, AppleScript Applications, and more.


Reply via email to