Marc Santhoff schrieb:

sDefaultPort: string = '/dev/cuaa0'; { this would be /dev/ttyS2 for you }

fPort = sDefaultPort;

{ Init }
fCom := SerOpen(fPort);
if (fCom > -1) then begin
  SerSetParams(fCom, 1200, 7, NoneParity, 2, []);
end else begin
  writeln('Metex: failed to open port');
  n := GetLastOSError;
end

{ Reading }
var
  inbuf: array[0..14] of char;
begin
  fillchar(inbuf, sizeof(inbuf), #0);
  res := SerRead(fCom, inbuf[0], 14); { last figure would be 1000 for you, 
bytes to read }
  if (res < 0) then
    { signal error }
...

That way I use serial ports successfully on FreeBSD and Windows.


This helps a lot. Thank you. This was the example I was looking for. My fault was the declaration of inbuffer: array of char, and I guess, I did not understand how to deal with hidden pointers. Now I've got this idea from you and hope so far, I can move on.

Best regards, Holger


_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to