serwrite

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

serwrite

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.bufPos<>0 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


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: serwrite

Marco van de Voort
> 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)

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal