Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-05

serwrite

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Carsten Bager

I have written this function where I use serwrite (unit serial). If I call

  serial.serwrite(prn,pchar(f.bufptr),f.bufPos);

like this, it puts out garbage.

How do I trick the compiler not to "convert a pointer to a pointer"?

This works.

Function rs232DeviceInout(var f:textRec):integer32;
Var
 buffer:array[0..79] of char;
Begin
  if f.bufPos0 then
  begin
    buffer:=pchar(f.bufptr);
    serial.serwrite(prn,buffer,f.bufPos);
  end;
  f.bufPos:=0;
  rs232DeviceInout:=0;
End;

Carsten
Med venlig hilsen
Carsten Bager

BEAS A/S
Brørupvænget 10
DK-7650 Bøvlingbjerg
Tlf. : +45 9788 5222 Fax : +45 9788 5434
www.beas.dk

Marco van de Voort
to Carsten Bager
Show quoted text 6 lines
I have written this function where I use serwrite (unit serial). If I call serial.serwrite(prn,pchar(f.bufptr),f.bufPos); like this, it puts out garbage.

That's odd. It is supposed to write "bufpos" bytes, the first 4 (or 8 on 64-bit) are the exact values of the pointer (p.bufptr) you want to write.

In the case you want to write the content the pointer points TO, try

pchar(f.bufptr)[0] or f.bufptr^ if that is allowed (I don't know what bufptr exactly is)