prn_status()

This function is called when the application interrogates the status of the (currently selected) POD. The global variable prn_device contains the number of the currently selected COD. The function should return either 0 (if no status information is available) or the address of a null-terminated status string which will be passed back to the application. You define the contents of the status string.

The length of the string returned by prn_status(), including the terminating binary zero, should not exceed the value STS_BUFSIZE defined in dip.h.

Note that this facility is not intended as a means for the application to discover any fatal errors which may have occurred: for this see Error Handling.

In our example, two of our CODs return status information - the Drawer (status is open or shut) and the Till Identification Value (the latter could be returned from prn_select() instead).

char *prn_status(void)
{
  char till_id[10];
 
  switch (prn_device)
  {
    /* "1" indicates open, "0" indicates closed */
    case 'D':
      if (drawer_opened)
        return "1";
      return "0";
 
    case 'T':
      prn_error = get_till_id(till_id);
      if (!prn_error)
        return till_id;
      break;
 
    default:
      break;
  }
  return 0;
}

The code of get_till_id() is operating-system dependent and not shown.