Skip to content

Finding SmartPort Devices

Thomas Cherryhomes edited this page Dec 26, 2022 · 2 revisions

With the SmartPort Slot and Dispatcher found, devices can be enumerated and found using STATUS code $00.

C Implemenation

int8_t sp_find_fuji()
{
  // const char fuji[9] = "THE_FUJI";
  const char fuji[14] = "FUJINET_DISK_0";
  const uint8_t fuji_len = sizeof(fuji);
  int8_t err, num, i, j;

  err = sp_status(0x00, 0x00); // get number of devices
	if (err)
    return -err;
  num = sp_payload[0];
	num++;
	for (i = 1; i < num; i++)
	{
    //do
      err = sp_status(i, 0x03); // get DIB
    //while (err);
    if (sp_payload[4] == fuji_len)
    {
      for (j = 0; j < fuji_len; j++)
        if (fuji[j]!=sp_payload[5+j])
          return 0;
      sp_dest = i; // store the fuji unit #
      return i;
    }
	}
  return 0;
}

int8_t sp_find_network()
{
  const char net[7] = "NETWORK";
  const uint8_t net_len = sizeof(net);
  int8_t err, num, i, j;

  err = sp_status(0x00, 0x00); // get number of devices

  if (err)
    return -err;

  num = sp_payload[0];
  num+=2;

  for (i = 1; i < num; i++)
    {
      err = sp_status(i, 0x03); // get DIB

      if (sp_payload[4] == net_len)
	{
	  for (j = 0; j < net_len; j++)
	    if (net[j]!=sp_payload[5+j])
	      return 0;

	  return i;
	}
    }
  printf("NET NOT FOUND");
  cgetc();
  return 0;
}

Clone this wiki locally