2008-08-14 19:17:34 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <serial.h>
|
|
|
|
#include <conio.h>
|
|
|
|
#include <dbg.h>
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(__C64__)
|
|
|
|
#define DRIVERNAME "c64-swlink.ser"
|
|
|
|
#elif defined(__C128__)
|
|
|
|
#define DRIVERNAME "c128-swlink.ser"
|
|
|
|
#elif defined(__PLUS4__)
|
2013-05-09 11:56:54 +00:00
|
|
|
#define DRIVERNAME "plus4-stdser.ser"
|
2008-08-14 19:17:34 +00:00
|
|
|
#elif defined(__CBM610__)
|
2013-05-09 11:56:54 +00:00
|
|
|
#define DRIVERNAME "cbm610-std.ser"
|
2009-12-13 11:16:38 +00:00
|
|
|
#elif defined(__APPLE2ENH__)
|
2013-05-09 11:56:54 +00:00
|
|
|
#define DRIVERNAME "a2e.ssc.ser"
|
2013-06-17 19:34:08 +00:00
|
|
|
#elif defined(__APPLE2__)
|
|
|
|
#define DRIVERNAME "a2.ssc.ser"
|
2013-12-06 19:15:12 +00:00
|
|
|
#elif defined(__ATARIXL__)
|
|
|
|
#define DRIVERNAME "atrxrdev.ser"
|
|
|
|
#elif defined(__ATARI__)
|
|
|
|
#define DRIVERNAME "atrrdev.ser"
|
2008-08-14 19:17:34 +00:00
|
|
|
#else
|
2013-05-09 11:56:54 +00:00
|
|
|
#define DRIVERNAME "unknown"
|
2008-08-14 19:17:34 +00:00
|
|
|
#error "Unknown target system"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
static const struct ser_params Params = {
|
2013-12-06 19:15:12 +00:00
|
|
|
SER_BAUD_9600, /* Baudrate */
|
2008-08-14 19:17:34 +00:00
|
|
|
SER_BITS_8, /* Number of data bits */
|
|
|
|
SER_STOP_1, /* Number of stop bits */
|
|
|
|
SER_PAR_NONE, /* Parity setting */
|
|
|
|
SER_HS_HW /* Type of handshake to use */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void CheckError (const char* Name, unsigned char Error)
|
|
|
|
{
|
|
|
|
if (Error != SER_ERR_OK) {
|
|
|
|
fprintf (stderr, "%s: %d\n", Name, Error);
|
|
|
|
exit (EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main (void)
|
|
|
|
{
|
|
|
|
char Res;
|
|
|
|
char C;
|
|
|
|
CheckError ("ser_load_driver", ser_load_driver (DRIVERNAME));
|
|
|
|
CheckError ("ser_open", ser_open (&Params));
|
|
|
|
while (1) {
|
|
|
|
if (kbhit ()) {
|
|
|
|
C = cgetc ();
|
|
|
|
if (C == '1') {
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
CheckError ("ser_put", ser_put (C));
|
2013-12-06 19:49:57 +00:00
|
|
|
printf ("%c", C);
|
2008-08-14 19:17:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Res = ser_get (&C);
|
|
|
|
if (Res != SER_ERR_NO_DATA) {
|
|
|
|
CheckError ("ser_get", Res);
|
|
|
|
printf ("%c", C);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CheckError ("ser_unload", ser_unload ());
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|