[comp.sys.mac.programmer] Serial Port problem

smd@media-lab.media.mit.edu (Steve Drucker) (02/20/90)

Can anyone tell me why the following code fragment causes the Mac to
hang until I pull out the cable that is connecting the mac to the
other computer? One other strange symptom....if I run Red Ryder in the
background afterwards, this code fragment works....so what am I
setting up wrong???

It's in Think C, and I'm just trying to write some stuff out the
serial port.  (I'd like to hear of the best way to do this too.)

#include <SerialDvr.h>
#include <stdio.h>

main()
{
int i, parm, errno;
long int length;
char astring[80];

	errno = RAMSDOpen(sPortA);
	if (errno != noErr) printf("problem opening serial port\n");
	parm = baud19200;
	errno = SerReset(AoutRefNum, parm | data8 | stop20 | noParity);
	if (errno != noErr) printf("problem setting up serial out\n");

	for (i=0;i<10;i++) {
		sprintf(astring, "count: %d\n",i);
		length = (long)strlen(astring);
		errno = FSWrite(AoutRefNum, &length, astring);
		if (errno != noErr) printf("error on writing\n");
	}
	RAMSDClose(sPortA);
	ExitToShell();
}






Thanx,
-Steve Drucker