Article View: comp.sys.mac
Article #34795Re: FSRead problem on MacII
From: Patrick C Beard
Date: Fri, 25 Nov 1988 23:24
Date: Fri, 25 Nov 1988 23:24
53 lines
2144 bytes
2144 bytes
In article <4793@leadsv.UUCP> ereed@leadsv.UUCP (Ed Reed) writes:
>
>
>I am having a problem with the FSRead command on a Macintosh II. The
>problem is as follows:
>
>I have three processors, the Mac II, a Force single board computer, and a high
>speed processor board. The Force is the traffic cop of the system. When the
>system is running the HSP sends data to a register which the Force reads. The
>Force then takes that data and sends it to the Mac II. The problem is in order
>to maintain a realtime system, the Force sends a byte of data to the Mac II
>every iteration of the control loop. Now FSRead appears to be only getting part
>of the data. In a test case 0 to 255 was sent from the Force to the Mac II, and
>approximately every 3rd byte was read. The other bytes where zeroed. Any
>suggestions. The actual Mac code is:
>
>FSRead (InPort, 256, &DataIn);
>
>and was written in C using Lightspeed C ver 3.0.
>
>Please reply to Joe Hughes
>
>Joe Hughes
>pyramid!leadsv!jhughes
Ack!! and double Ack!!
Read Inside Mac carefully! I have used this routine so many times that
I always do the code the same way:
foo(InPort, DataIn)
int InPort;
Ptr DataIn;
{
OSErr err;
long bytes_to_read;
bytes_to_read=256;
err=FSRead(InPort, &bytes_to_read, DataIn);
return(err);
}
The problem with your code is that you aren't passing a pointer
to the number of bytes to read. Inside Mac Volume II-92:
FSRead(refNum: INTEGER; VAR count: LONGINT; buf: Ptr);
In C, one should always interpret a VAR as meaning requiring '&'.
I hope this helps.
Patrick Beard
Lawrence Berkeley Laboratory
Technical Details
Message-ID:
<1314@helios.ee.lbl.gov>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!ux1.lbl.gov!beardReferences:
<4793@leadsv.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!ux1.lbl.gov!beard From: beard@ux1.lbl.gov (Patrick C Beard) Newsgroups: comp.sys.mac,comp.sys.mac.programmer Subject: Re: FSRead problem on MacII Keywords: FSRead Message-ID: <1314@helios.ee.lbl.gov> Date: 25 Nov 88 23:24:01 GMT References: <4793@leadsv.UUCP> Sender: usenet@helios.ee.lbl.gov Reply-To: beard@ux1.lbl.gov (Patrick C Beard) Distribution: na Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 52