Re: parrallel port null modem

new topic     » goto parent     » topic index » view thread      » older message » newer message

Hi,

I have written a program to interface a PC with an Oric Atmos through the
parallel port.

The routines on the PC side may help you. ports.e and keys.e from Jacques
Deschesnes are needed.

Regards

Jean-Marc

Here they are:

= = = = = =

include ports.e
include keys.e
include get.e
include graphics.e
include sort.e

  global constant KEYB = 0, SCREEN = 1, ERR = 2

  -- adresse des registres du port imprimante
  atom DataAddress,        -- adresse du registre de donnees
       StatusAddress,        -- adresse du registre de statut
       ControlAddress        -- adresse du registre de controle

  atom OldData,        -- sauvegarde du registre de donnees
       OldReg2        -- sauvegarde du registre de controle

  sequence Liste
  atom Liste_courante
  global sequence TextAttr

procedure Delay(atom n)
  atom t0

  t0 = time()
  while (time() - t0) < n do
  end while
end procedure

-----------------------------------------------------------
--      Transforme deux octets en un mot de 16 bits
-----------------------------------------------------------

function ByteToWord(atom l, atom h)
  return h*#100+l
end function

-----------------------------------------------------------
--    Extrait l'octet de poids fort d'un mot de 16 bits
-----------------------------------------------------------

function Hi(atom x)
  return floor(x / #100)
end function

-----------------------------------------------------------
--   Extrait l'octet de poids faible d'un mot de 16 bits
-----------------------------------------------------------

function Lo(atom x)
  return remainder(x, #100)
end function

procedure Init(atom address)
  -- definit les addresses des registres du port
  -- et efface l'ecran
  clear_screen()
  DataAddress = address
  StatusAddress = address + 1
  ControlAddress = address + 2
  -- sauve les contenus des registres
  OldData = Input(DataAddress)
  OldReg2 = Input(ControlAddress)
  Output(#FD, ControlAddress)
end procedure

-- restaure les contenus des registres
procedure Restor()
  Output(OldData, DataAddress)
  Output(OldReg2, ControlAddress)
end procedure

-- genere l'impulsion de strobe
procedure Strobe()
  atom i

  i = Input(ControlAddress)
  Output(i and #1E, ControlAddress)        -- strobe a 0
  Output(i or 1, ControlAddress)        -- strobe a 1
end procedure

-- ecrit un octet sur le port imprimante
procedure PortOut(atom PortData)
  atom i

  Output(PortData, DataAddress)
  Strobe()
end procedure

-- lit un quartet sur le port imprimante
function InPort()
  atom PortData

  PortData = Input(StatusAddress)
  return xor_bits(floor(or_bits(PortData, 7) / 8), #10)
end function

-- attend qu'une donnee soit presente et lit un octet sur le port imprimante
function ReadByte()
  atom PortDat, Data

  -- boucle
  PortDat = #10
  while  and_bits(PortDat, #10) = #10 do
    -- lit le premier quartet sur le port imprimante
    -- jusqu'a ce que la ligne Busy soit activee = donnee presente
    PortDat = InPort()
  end while
  -- Stocke le quartet de poids faible
  Data = and_bits(PortDat, #0F)
  -- Active D1 = selection poids fort / poids faible
  PortOut(#02)
  -- lit le second quartet sur le port imprimante
  PortDat = InPort()
  -- Stocke le quartet de poids fort
  PortDat = or_bits(Data, (and_bits(PortDat, #0F) * 16))
  -- RAZ D1, active D0 et D2 = RAZ tampon U1 et Ack vers Oric
  PortOut(#05)
  Delay(10)        -- fait durer le signal ack pour l'Oric
  -- RAZ D0 et D2 = retour a la normale
  PortOut(#00)
  return PortDat
end function

-- lit un mot de 16 bits sur le port imprimante
function ReadWord()
  atom PortDat, Result

  PortDat = ReadByte()
  Result = PortDat * 256
  PortDat = ReadByte()
  return Result + PortDat
end function

-- lit une chaine de caracteres sur le port imprimante
function ReadString()
  atom PortDat
  sequence Result

  Result = {}
  PortDat = 1
  while PortDat != 0 do
    PortDat = ReadByte()
    if PortDat != 0 then
      Result = append(Result, PortDat)
    end if
  end while
  return Result
end function


----- Original Message -----
From: Rudy Toews <rltoews at PANGEA.CA>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Thursday, May 11, 2000 8:46 PM
Subject: parrallel port null modem


> hi
> has anyone created a routine to transfer data on the printer port?
> windows d.c.c. only recognizes the serial ports on the old computer.
> so i was thinking of a simple one way transfer out to the printer port and
> a simple reading of the printer port on the newer computer.
>
> thanks for your help
> rudy
>
> p.s. keep  up the good work, i have been downloading lots of source to
learn
> from.  my project still in progress.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu