mcli@joker (Maurice Ling) (06/17/89)
Hello everyone again,
Thanks for the help on programming the serial port. What I have to figure
out now is what kind of values I should put in the flags struct to set up
various handshaking signals. I need this to be able to communicate with
a scanner.
Thanks again!
Maurice
************************************************************************
* *
* Optics... The wave of the future ** ** ** *
* * * * * * * *
* BITNET : MCLI_SS@UORDBV, MCLISS@UORVM * * * *
* UUCP : ...rochester!uhura!mcli ** ** ** *
* Internet: mcli@uhura.cc.rochester.edu *** *** *** *
* ***** ***** ***** *
************************************************************************
---------------------------------------------------------------------------
#include <stdio.h>
#include <serialDvr.h>
#include <DeviceMgr.h>
#include <MacTypes.h>
#include <strings.h>
#include <EventMgr.h>
EventRecord myEvent;
main()
{
Getinfo();
}
Getinfo()
{
int setup,stuff, err;
long int count;
char message[10];
SerShk flags;
flags.fXOn = '1';
flags.xOn = '0x17';
flags.xOff = '0x19';
flags.fCTS = '1';
flags.errs = '1';
flags.evts = '1';
flags.fInX = '1';
flags.fDTR = '1';
err = RAMSDOpen(sPortA);
SerSetBuf(-7,message, 1024);
printf("%d\n",err);
stuff = SerHShake (-7,&flags);
setup = baud300+data8+stop20+noParity;
printf("%d\n",SerReset(-7,setup));
while (message != "\n") {
while (1)
{
GetNextEvent(everyEvent,&myEvent);
if (myEvent.what == mouseDown) break;
getblock();
}
printf("Please enter your command> ");
scanf("%s", message);
strcat(message, "\r\n");
count = (long int)strlen(message);
stuff = FSWrite ( -7, &count, message);
printf("%d\n",stuff);
printf("%ld\n",count);
}
RAMSDClose(sPortA);
printf("%d\n",err);
}
getblock()
{
unsigned char c[1024]; /* big buffer */
int e; /* error codes */
register long i; /* index for chars */
long whatread; /* how many chars are actually waiting */
SerGetBuf(-6, &whatread); /* anything there? */
if (whatread > 0) {
if (whatread > 1024) whatread = 1024L;
/* if more than our buffer (shouldn't happen) coerce to
* the buffer size, so we don't go destroying memory.
* If there's more, it will have to wait until the next pass
*/
e = FSRead(-6, &whatread, c); /* Grab the chars */
if (e == 0) /* no error, print the characters */
for (i=0; i< whatread; i++) putch(c[i] & 0x7f);
/* we mask off the 8th bit, 'cause it doesn't really
* mean anything to us.
*/
}
}
************************************************************************
* *
* Optics... The wave of the future ** ** ** *