GE OMs;
> One could, with considerable effort, translate the program into C and make
> it run on Linux and Windows.
Here is a little C program that runs under Linux. I kind of expect it
should work on a Windows platform if you have a C compiler.
I wrote it to print out my e-mail to my 28-KSR.
It will take the ASCII file called msg_mail which is in the /rtty
directory and print it out the COM 1 port at 45.45 BAUD.
Suping it up to do other bauds is easy.
Let me know if any of you try it.
regards,
W6ESE - tony
NNNN
ZCZC
_______________________________________________________________________________
--
Tony J. Podrasky | I used to think that the brain was the most
| wonderful organ in my body.
| Then I realized who was telling me this...
| - Emo Phillips
-------------- next part --------------
/* Mon Apr 16 09:54:47 PDT 2012 - increase size of buffer from 64K to 96K */
/* Sat Sep 17 08:21:14 PDT 2011 - clean up some of the comments */
/* Fri Mar 25 17:18:56 PST 2011 - added the VERSION module */
/* Sat Aug 14 19:17:33 PDT 2010 - added command to print data to screen */
/* Sat Aug 14 19:35:33 PDT 2010 - removed it because it instantly prints the whole buffer */
#include <stdio.h> /* standard I/O file */
#include <stdlib.h> /* standard library */
#include <string.h> /* string library */
#include <unistd.h> /* symbolic constants */
#include <fcntl.h> /* function control */
#include <sys/types.h> /* function control */
#include <sys/stat.h> /* function control */
#include <sys/time.h> /* time function */
#include <unistd.h> /* UNIx STanDard header */
#define DATAOUT "/dev/ttyS0" /* Output file */
#define MAILFILE "/rtty/msg_mail" /* Inbox data message */
#define VERSION "Mon Apr 16 09:54:47 PDT 2012" /* version of program */
int main(int argc, char *argv[]) /* beginning of program */
{
if(argc == 2) /* | see if there were arguments on | */
{ /* | the command line. if so check | */
if(strcmp(argv[1], "-v") == 0) /* | to see if it was a "-v". if so | */
{ /* | print out the version number | */
printf("\n%s version: %s\n", argv[0], VERSION); /* | and exit the program. | */
return 0; /* | | */
} /* | | */
} /* | | */
int dataout; /* file pointer to data out file */
int f = 0; /* work character for canned message */
int dend = 0; /* work character for canned message */
int atoi[128]; /* array for ASCII to ITA#2 translation */
int sendshift = 0; /* case control for the transmitter */
int offset; /* atoi table offset character */
int autocrlf = 0; /* automatic carriage return / line feed counter */
int forcecrlf = 76; /* maximum characters per line before forcing cr/lf */
char mailbuf[98304]; /* buffer for canned message */
FILE *mailfile; /* file pointer to [DATAFILE] for canned message */
atoi[0] = 000; /* Translation table for ITA#2 characters */
atoi[1] = 000;
atoi[2] = 000;
atoi[3] = 000;
atoi[4] = 000;
atoi[5] = 000;
atoi[6] = 000;
atoi[7] = 005; /* BELL */
atoi[8] = 000;
atoi[9] = 000; /* TAB */
atoi[10] = 002; /* LINEFEED */
atoi[11] = 000;
atoi[12] = 000;
atoi[13] = 010; /* CARRIAGE RETURN */
atoi[14] = 000;
atoi[15] = 000;
atoi[16] = 000;
atoi[17] = 000;
atoi[18] = 000;
atoi[19] = 000;
atoi[20] = 000;
atoi[21] = 000;
atoi[22] = 000;
atoi[23] = 000;
atoi[24] = 000;
atoi[25] = 000;
atoi[26] = 000;
atoi[27] = 000; /* ESCAPE */
atoi[28] = 000;
atoi[29] = 000;
atoi[30] = 000;
atoi[31] = 000;
atoi[32] = 004; /* SPACE */
atoi[33] = 015; /* ! */
atoi[34] = 021; /* # */
atoi[35] = 024; /* " */
atoi[36] = 011; /* $ */
atoi[37] = 000;
atoi[38] = 032; /* & */
atoi[39] = 013; /* ' */
atoi[40] = 017; /* ( */
atoi[41] = 022; /* ) */
atoi[42] = 000;
atoi[43] = 000;
atoi[44] = 014; /* , */
atoi[45] = 003; /* - */
atoi[46] = 034; /* . */
atoi[47] = 035; /* / */
atoi[48] = 026; /* 0 */
atoi[49] = 027; /* 1 */
atoi[50] = 023; /* 2 */
atoi[51] = 001; /* 3 */
atoi[52] = 012; /* 4 */
atoi[53] = 020; /* 5 */
atoi[54] = 025; /* 6 */
atoi[55] = 007; /* 7 */
atoi[56] = 006; /* 8 */
atoi[57] = 030; /* 9 */
atoi[58] = 016; /* : */
atoi[59] = 036; /* ; */
atoi[60] = 017; /* < */
atoi[61] = 000;
atoi[62] = 022; /* > */
atoi[63] = 031; /* ? */
atoi[64] = 000;
atoi[65] = 003; /* A */
atoi[66] = 031; /* B */
atoi[67] = 016; /* C */
atoi[68] = 011; /* D */
atoi[69] = 001; /* E */
atoi[70] = 015; /* F */
atoi[71] = 032; /* G */
atoi[72] = 024; /* H */
atoi[73] = 006; /* I */
atoi[74] = 013; /* J */
atoi[75] = 017; /* K */
atoi[76] = 022; /* L */
atoi[77] = 034; /* M */
atoi[78] = 014; /* N */
atoi[79] = 030; /* O */
atoi[80] = 026; /* P */
atoi[81] = 027; /* Q */
atoi[82] = 012; /* R */
atoi[83] = 005; /* S */
atoi[84] = 020; /* T */
atoi[85] = 007; /* U */
atoi[86] = 036; /* V */
atoi[87] = 023; /* W */
atoi[88] = 035; /* X */
atoi[89] = 025; /* Y */
atoi[90] = 021; /* Z */
atoi[91] = 000; /* [ */
atoi[92] = 000;
atoi[93] = 000; /* ] */
atoi[94] = 000;
atoi[95] = 000;
atoi[96] = 000;
atoi[97] = 03; /* A */
atoi[98] = 031; /* B */
atoi[99] = 016; /* C */
atoi[100] = 011; /* D */
atoi[101] = 001; /* E */
atoi[102] = 015; /* F */
atoi[103] = 032; /* G */
atoi[104] = 024; /* H */
atoi[105] = 006; /* I */
atoi[106] = 013; /* J */
atoi[107] = 017; /* K */
atoi[108] = 022; /* L */
atoi[109] = 034; /* M */
atoi[110] = 014; /* N */
atoi[111] = 030; /* O */
atoi[112] = 026; /* P */
atoi[113] = 027; /* Q */
atoi[114] = 012; /* R */
atoi[115] = 005; /* S */
atoi[116] = 020; /* T */
atoi[117] = 007; /* U */
atoi[118] = 036; /* V */
atoi[119] = 023; /* W */
atoi[120] = 035; /* X */
atoi[121] = 025; /* Y */
atoi[122] = 021; /* Z */
atoi[123] = 000;
atoi[124] = 000;
atoi[125] = 033; /* FIGS (make believe offset) */
atoi[126] = 000;
atoi[127] = 037; /* LTRS */
system("/bin/setserial /dev/ttyS0 spd_cust divisor 2534"); /* system call to set serial port speed */
system("/bin/stty -F /dev/ttyS0 38400 cstopb cs5 raw -echo"); /* system call to stty to set port parms */
if ((dataout = open(DATAOUT, O_WRONLY, 0)) == -1) /* | create file pointer to tty port | */
{ /* | | */
printf("ERROR: can't open: %s \n", DATAOUT); /* | error out if file can't be opened | */
return 0; /* | | */
}
if ((mailfile = fopen(MAILFILE, "r")) == NULL) /* create file pointer to mail file */
{
printf("ERROR: could not open file: %s \n", MAILFILE); /* error out if file can't be opened */
return 0;
}
while (fscanf(mailfile, "%c", &mailbuf[dend]) == 1) /* | load the mail from the msg_mail file | */
++dend; /* | increment the buffer offset | */
while (f <= dend)
{
offset = mailbuf[f];
if (autocrlf >= forcecrlf) /* | have we reached the max number | */
{ /* | of characters per line? | */
autocrlf = 0; /* | if so, reset the counter, | */
offset = 13; /* | and send the carriage return, | */
write(dataout, &atoi[offset], 1); /* | carriage return, line feed, | */
write(dataout, &atoi[offset], 1); /* | | */
offset = 10; /* | letters, letters, sequence | */
write(dataout, &atoi[offset], 1); /* | | */
offset = 127; /* | | */
write(dataout, &atoi[offset], 1); /* | | */
write(dataout, &atoi[offset], 1); /* | | */
sendshift = 0; /* | and set SHIFT to 0 'cuz of LTRS | */
}
if ((offset > 32) && (offset < 65)) /* | check is the character is between | */
{ /* | an ASCII SPACE and ASCII A. | */
if (sendshift == 0) /* | if so, see if we're in LETTERS | */
{ /* | if so, load the FIGS offset into | */
offset = 125; /* | the buffer | */
write(dataout, &atoi[offset], 1); /* | go to xmit_data function & send | */
offset = mailbuf[f]; /* | now load the uppercase character. | */
sendshift = 1; /* | set the SHIFT variable to upper | */
} /* | | */
} /* | | */
if (offset >= 65) /* | check if it is a lower case char | */
{ /* | greater than or equal to A | */
if (sendshift == 1) /* | if so, see if we're in upper case | */
{ /* | if so, load the LTRS offset into | */
offset = 127; /* | the buffer | */
write(dataout, &atoi[offset], 1); /* | go to xmit_data function & send | */
offset = mailbuf[f]; /* | now load the lower case character | */
sendshift = 0; /* | set the SHIFT variable to lower | */
} /* | | */
} /* | | */
if (offset == 32) /* | check is the character a SPACE | */
{ /* | if so, see if we're in upper case | */
if (sendshift == 1) /* | if so, we'll need to send the | */
{ /* | SPACE character and then another | */
write(dataout, &atoi[offset], 1); /* | go to xmit_data function & send | */
offset = 125; /* | that will occur on some ttys | */
} /* | | */
} /* | | */
if (offset == 10) /* | check if the char is a LINEFEED | */
{ /* | if so, we're going to send a big | */
offset = 13; /* | sequence, starting with the send | */
write(dataout, &atoi[offset], 1); /* | of 2 CARRIAGE RETURN characters | */
write(dataout, &atoi[offset], 1); /* | of 2 CARRIAGE RETURN characters | */
offset = 10; /* | followed by a LINEFEED and then | */
write(dataout, &atoi[offset], 1); /* | | */
offset = 127; /* | 2 LTRS characters, | */
sendshift = 0; /* | and set SHIFT to 0 'cuz of LTRS | */
autocrlf = 0; /* | reset the automatic cr/lf counter | */
} /* | | */
write(dataout, &atoi[offset], 1); /* go to xmit_data function & send */
++autocrlf; /* bump the automatic cr/lf counter */
++f; /* bump the pointer and repeat this routine */
}
return 0;
}