Logo Search packages:      
Sourcecode: cbmlink version File versions  Download package

static int write_remote ( const struct comm comm,
unsigned  file,
char *  buf,
unsigned  len 
) [static]

write data to a remote file

comm the communication primitives
file the file number (2 for data, 15 for command)
buf the data (with buf[-3..-1] and buf[len] writable)
len the length of the data (1..256 bytes)
remote status code, or -1 on transfer failure

Definition at line 127 of file disk.c.

References checksum(), comm::comm_read, comm::comm_rs, comm::comm_sr, and comm::comm_write.

Referenced by command_remote(), disk_cread(), disk_mread(), disk_mwrite(), and disk_write().

  buf[-3] = file | 0x40;
  buf[-2] = len;
  buf[-1] = checksum (buf, len);
  buf[len] = 0;

  for (;;) {
    char c;
    if ((*comm->comm_write) (buf - 3, len + 4))
      return -1;
    (*comm->comm_sr) ();
    if ((*comm->comm_read) (&c, 1))
      return -1;
    (*comm->comm_rs) ();
    if (!c)
      return 0;
    else if (c == (char) 0xff)
      fputs ("\ndisk: checksum error on write, retrying\n", stderr);
      return c;

Generated by  Doxygen 1.6.0   Back to index