1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
/*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation;
* Look at the file LICENSE for details
*
*/
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <termios.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
/*
* defines:
*/
#define READ 1
#define WRITE 0
#define WAIT 1
#define NOWAIT 0
#define TIMEOUT 60500L
/*
* Control codes for handshake
*/
#if defined(Solaris2)
#define CR '\r'
#define LF '\n'
#else
#define CR 0x0d
#define LF 0x0a
#endif /* defined(Solaris2) */
#define XON 0x11
#define XOFF 0x13
#define ACK 0x23
#define NACK 0x3f
#define STOP 0x21
typedef unsigned char byte ;
typedef unsigned short word ;
/*
* Structure of a record header as it is
* exhanged with the CASIO
*/
typedef struct
{
byte marker ; /* ':' marks the start of a record */
word nbytes ; /* 2 digit ASCII, # databytes */
word type ; /* 2 digit ASCII, record type */
word low ; /* 2 digit ASCII, low memory address */
word high ; /* 2 digit ASCII, high memory address */
} CasioHeader ;
/*
* Internal representation of such a header
*/
typedef struct
{
byte nbytes ; /* number of databytes in the record */
byte type ; /* record type */
word address ; /* load address in memory */
} Header ;
/*
* function prototypes:
*/
void UpperCase (char *s);
int ReadByte (byte mode);
void ReadHeader (void);
void WriteByte (byte d);
void WaitForCasio (void);
void WriteLine (FILE * infile);
void WriteBuffer (int num);
byte ReadHex (void);
byte atoh (char c);
void ReadLine (void);
char htoa (byte c);
void DisplayStatus (void);
int kbhit (void);
int tty_cbreak (int fd); /* put stdin into a raw mode */
int tty_reset (int fd); /* restore stdins's mode */
static void sig_catch (int); /*signal catcher */
void terminate (); /* terminator */
|