Skip to content

N: SIO Command 'R' Read

Bill Kendrick edited this page May 27, 2022 · 4 revisions

SIO Command Read ($52) ['R']

This is a command for Devices $71-$78 - The N: Device (see SIO-Commands-for-Device-IDs-$71-to-$78).

Description

Fetch the number of bytes requested from the protocol channel opened previously by the OPEN command. an ERROR will result if too many bytes are requested, so a STATUS should be sent beforehand to determine the # of bytes to receive.

Parameters

ADAM

  • Use AdamNet Device 0x09 to 0x0C
  • Use EOS READ CHARACTER DEVICE, with a length and buffer of 1024 bytes.

ATARI

DCB Value
DDEVIC $71
DUNIT $01 - $04
DCOMND $52 'R'
DSTATS $40
DBUF NULL
DTIMLO $0F
DBYT # of bytes to return
DAUX1 # of bytes to return LO
DAUX2 # of bytes to return HI

Examples

ATARI

CC65

/**
 * io_main() - The IO main loop
 */
void io_main(void)
{
  if (xmit_buffer_len>0)
    {
      OS.dcb.ddevic=0x71;
      OS.dcb.dunit=1;
      OS.dcb.dcomnd='W';
      OS.dcb.dstats=0x80;
      OS.dcb.dbuf=&xmit_buffer;
      OS.dcb.dtimlo=0x0f;
      OS.dcb.dbyt=xmit_buffer_len;
      OS.dcb.daux1=xmit_buffer_len;
      OS.dcb.daux2=0;
      siov();

      xmit_buffer_len=0;
      return;
    }

  if (trip==0)
    return;

  // Get # of bytes waiting
  OS.dcb.ddevic=0x71;
  OS.dcb.dunit=1;
  OS.dcb.dcomnd='S';
  OS.dcb.dstats=0x40;
  OS.dcb.dbuf=&status;
  OS.dcb.dtimlo=0x0f;
  OS.dcb.dbyt=4;
  OS.dcb.daux=0;
  siov();

  bw=(status[1]<<8)+status[0];
  connected=status[2];

  // These functions are all I needed to change to port over to the N: device.

  if (bw>0)
    {
      // Do a read into into recv buffer and ShowPLATO
      OS.dcb.ddevic=0x71;
      OS.dcb.dunit=1;
      OS.dcb.dcomnd='R';
      OS.dcb.dstats=0x40;
      OS.dcb.dbuf=&recv_buffer;
      OS.dcb.dbyt=bw;
      OS.dcb.daux=bw;
      siov();
      ShowPLATO((padByte *)recv_buffer, bw);
      bw=trip=0;
    }

  if (connected==0)
    {
      io_done();
    }

  PIA.pactl |= 1;
}

ADAM

Z88DK C

/* This uses EOSLIB: http://github.com/tschak909/eoslib */

#define NET_DEV 0x09

unsigned char response[1024]; /* RESPONSE BUFFER */

void read(void)
{
    DCB *dcb = find_dcb(NET_DEV);
    if (eos_read_character_device(NET_DEV,response,1024) == 0x80)
    {
        for (int i=0;i < dcb->len; i++)
        {
            putchar(response[i]);
        }
    }
}

See Also

Put other related command links here.

Clone this wiki locally