Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!swrinde!mips!spool.mu.edu!think.com!samsung!crackers!m2c!wpi.WPI.EDU!nuk From: nuk@wpi.WPI.EDU (Jacob W Anderson) Newsgroups: comp.sys.mac.programmer Subject: SerialDriver programming Message-ID: <1991Apr9.002744.28880@wpi.WPI.EDU> Date: 9 Apr 91 00:27:44 GMT Organization: Worcester Polytechnic Institute Lines: 95 I have been trying to program my serial port on a MacSE with 128k ROMs using a Hayes compatible modem, but have found that the protocol used in the following program does not work properly. In fact, it does not work at all it does not generate any run-time errors, but rather does nothing that it should (like dialing). Please, if you have any idea what I am doing wrong, please tell me. I possible please tell me in 'C' for I am using both Think Pascal and Think C, but the final project is to be in 'C'. Thanks in adavance. please E-mail. nuk@wpi.wpi.edu ================================================ program serial trial; const baud2400 = 46; noParity = 0; data8 = 3072; stop10 = 16384; var Error: OSErr; PortIn: Integer; PortOut: Integer; SerConfig: Integer; csParamPtr: Ptr; Buffer: Ptr; procedure DoError; begin if Error <> 0 then begin writeln('Error:', Error, ' has occured in accessing serial d river.'); ExitToShell; end; end; {this procedure sends data to the modem} procedure Send (Data: Str255); var Count: LongInt; begin Count := LongInt(Length(Data)); writeln('Sending ', Data, ' &', count, 'bytes'); Buffer := @Data; Error := FSWrite(PortOut, count, Buffer); DoError; end; procedure TalkToModem; var count: LongInt; DataIn: Str255; begin Send('ATE1 V1'); Send(chr(13)); writeln('..........Talking to Modem'); Readln(DataIn); Send(DataIn); writeln('getting feedback'); DataIn := ' '; count := 2; Error := FSRead(PortIn, count, @DataIn); DoError; writeln(DataIn, ' ....waiting'); for count := 1 to 150 do write('.'); writeln; send('ATH1'); Send(chr(13)); writeln('sending dial command'); Readln(DataIn); Send(DataIn); Send(chr(13)); end; begin SerConfig := baud2400 + noParity + data8 + stop10; writeln('Opening driver for Input'); Error := OpenDriver('.AIn', PortIn); DoError; writeln('Opening driver for output'); Error := OpenDriver('.AOut', PortOut); DoError; writeln('Resetting input channels'); Error := Control(PortIn, 8, pointer(SerConfig)); DoError; writeln('Resetting output channels'); Error := Control(PortOut, 8, pointer(SerConfig)); DoError; TalkToModem; writeln('Closing serial port channels'); end.