Amiga-Development

Please login or register.

Login with username, password and session length
Advanced search  

News:

Created for developers of all Amiga camps

Author Topic: Serial device support on MorphOS  (Read 155 times)

0 Members and 1 Guest are viewing this topic.

asrael22

  • Newbie
  • *
  • Posts: 1
    • View Profile
Serial device support on MorphOS
« on: March 15, 2017, 04:47:10 PM »

Hi there.

Just a quick question as I'm looking into Free Pascal.
Is there support for serial device on MorphOS?


Manfred
Logged

ALB42

  • Moderator
  • Newbie
  • *****
  • Posts: 22
    • View Profile
Re: Serial device support on MorphOS
« Reply #1 on: March 15, 2017, 05:49:04 PM »

Hi asrael, welcome   :D

Yes it is possible to talk to serial device in freepascal (with my GPSTool, I do that, the GPS devices are serial devices, or USB serial devices, just the device name is different but still serial communication)

But the serial unit is not available for morphos. But not important because it just contains the io structures for serial device. So if you need it you can just download the one from Amiga (http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/amunits/src/coreunits/serial.pas?view=markup) and put to your project (uses serial; ) or copy the need structures to your code. If you search for serial examples in C you will most likely find some using CreateExtIO/ DeleteExtIO

here are the 2 functions:

Code: [Select]
function CreateExtIO(const Mp: PMsgPort; Size: Integer): PIORequest;
begin
  Result := nil;
  if not Assigned(mp) then
    Exit;
  Result := System.AllocMem(Size);
  if Assigned(Result) then
  begin
    Result^.io_Message.mn_Node.ln_Type := NT_REPLYMSG;
    Result^.io_Message.mn_ReplyPort := Mp;
    Result^.io_Message.mn_Length := Size;
  end;
end;

procedure DeleteExtIO(ioReq: PIORequest);
begin
  if Assigned(ioReq) then
  begin
    ioReq^.io_Message.mn_Node.ln_Type := Byte(-1);
    ioReq^.io_Device := Pointer(-1);
    ioReq^.io_Unit := Pointer(-1);
    System.FreeMem(ioReq);
  end;
end;

the rest is just create message port, createextio, opendevice, set communication params and ask for Data or send Data via DoIO/SendIO/WaitIO
Logged