/* Remote serial interface for local (hardwired) serial ports for Macintosh.
Copyright 1994 Free Software Foundation, Inc.
+ Contributed by Cygnus Support. Written by Stan Shebs.
This file is part of GDB.
#include <Types.h>
#include <Devices.h>
-#include <Serial.h>
+/* This is the regular Mac Serial.h, but copied to a different name
+ so as not to get confused with the GDB serial.h above. */
+#include "MacSerial.h"
/* This is unused for now. We just return a placeholder. */
}
else
{
+ error ("You must specify a valid serial port name; your choices are `modem' or `printer'.");
errno = ENOENT;
return (-1);
}
int timeout;
{
int status, n;
- /* time_t */ unsigned long starttime, now;
+ /* time_t */ unsigned long start_time, now;
OSErr err;
CntrlParam cb;
IOParam pb;
if (scb->bufcnt-- > 0)
return *scb->bufp++;
- time (&starttime);
+ time (&start_time);
while (1)
{
else
{
time (&now);
- if (now > starttime + timeout) {
- printf_unfiltered ("start %u, now %u, timeout %d\n", starttime, now, timeout);
+ if (now > start_time + timeout)
return SERIAL_TIMEOUT;
- }
}
+ PROGRESS (1);
}
}
return;
}
+/* If there is a tricky formula to relate real baud rates
+ to what the serial driver wants, we should use it. Until
+ we get one, this table will have to do. */
+
+static struct {
+ int real_rate;
+ int bits;
+} mac_baud_rate_table[] = {
+ { 57600, baud57600 },
+ { 38400, 1 },
+ { 19200, baud19200 },
+ { 9600, baud9600 },
+ { 7200, baud7200 },
+ { 4800, baud4800 },
+ { 3600, baud3600 },
+ { 2400, baud2400 },
+ { 1800, baud1800 },
+ { 1200, baud1200 },
+ { 600, baud600 },
+ { 300, baud300 },
+ { 0, 0 }
+};
+
static int
mac_set_baud_rate (scb, rate)
serial_t scb;
int rate;
+{
+ int i, bits;
+
+ for (i = 0; mac_baud_rate_table[i].real_rate != 0; ++i)
+ {
+ if (mac_baud_rate_table[i].real_rate == rate)
+ {
+ bits = mac_baud_rate_table[i].bits;
+ break;
+ }
+ }
+ SerReset (input_refnum, stop10|noParity|data8|bits);
+ SerReset (output_refnum, stop10|noParity|data8|bits);
+}
+
+static int
+mac_set_stop_bits (scb, num)
+ serial_t scb;
+ int num;
{
return 0;
}
+int first_mac_write = 0;
+
static int
mac_write (scb, str, len)
serial_t scb;
OSErr err;
IOParam pb;
+ if (first_mac_write++ < 4)
+ {
+ sleep (1);
+ }
pb.ioRefNum = output_refnum;
pb.ioBuffer = (Ptr) str;
pb.ioReqCount = len;
}
static void
-mac_close (scb)
- serial_t scb;
+mac_close (serial_t scb)
{
if (input_refnum)
{
mac_print_tty_state,
mac_noflush_set_tty_state,
mac_set_baud_rate,
+ mac_set_stop_bits,
};
void