Example #1
0
int main ()
{
  struct parport_list pl;
  ieee1284_find_ports (&pl, 0);
  test_deviceid (&pl);
  test_open (&pl);
  ieee1284_free_ports (&pl);
  return 0;
}
// -------------------------------------------------------------------------------------------------
ParportList* ParportList::instance(int flags) throw (ParportError)
{
    if (!m_theInstance)
    {
        parport_list* list = new parport_list;
        int err;
        
        if ((err = ieee1284_find_ports(list, flags)) != E1284_OK)
        {
            delete list;
            throw ParportError(err);
        }
        
        m_theInstance = new ParportList(list);
    }
    
    return m_theInstance;
}
Example #3
0
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
	struct parport_list ports;
	struct sr_config *src;
	const char *conn = NULL;
	GSList *devices, *option;
	gboolean port_found;
	int i;


	for (option = options; option; option = option->next) {
		src = option->data;
		if (src->key == SR_CONF_CONN) {
			conn = g_variant_get_string(src->data, NULL);
			break;
		}
	}

	if (!conn)
		return NULL;

	if (ieee1284_find_ports(&ports, 0) != E1284_OK)
		return NULL;

	devices = NULL;
	port_found = FALSE;
	for (i = 0; i < ports.portc; i++)
		if (!strcmp(ports.portv[i]->name, conn)) {
			port_found = TRUE;
			devices = scan_port(devices, di, ports.portv[i]);
		}

	if (!port_found) {
		sr_err("Parallel port %s not found. Valid names are:", conn);
		for (i = 0; i < ports.portc; i++)
			sr_err("\t%s", ports.portv[i]->name);
	}

	ieee1284_free_ports(&ports);

	return devices;
}
Example #4
0
int main(int argc, char **argv)
{
  if (argc < 2) {
    fprintf(stderr, "usage: %s <data>\n", argv[0]);
    return -1;
  }

  uint32_t status;
  uint32_t capability;

  int i;
	status = ieee1284_find_ports( &port_list, 0);

	if( status == E1284_NOMEM)
	{
		perror("There is not enought memory.\n");
		return -1;
	}

	printf("Number of ports: %d\n\n", port_list.portc);
/*	
	for(i = 0; i < port_list.portc; ++i)
	{
		curr_port = port_list.portv[i];
		printf("Name: \t\t%s\n", curr_port->name);
		printf("Base address: \t%d\n", curr_port->base_addr);
		printf("ERC address: \t%d\n", curr_port->hibase_addr);
		printf("Filename: \t%s\n\n", curr_port->filename);
		//break;
		
	}
*/
	curr_port = port_list.portv[1];
	capability = CAP1284_RAW;

	printf("Try to open port \"%s\"\n\n", curr_port->name);

	status = ieee1284_open(curr_port, 0, &capability);
	
	print_status_open(status);

	status = ieee1284_claim(curr_port);
	printf("Status: %d\n", status);

	write_number(atoi(argv[1]));

/*
	uint16_t info;

	sscanf(argv[1], "%x", &info);
	write_binary_data(info);
*/
	

	ieee1284_release(curr_port);
	status = ieee1284_close(curr_port);
	printf("Status: %d\n", status);

	ieee1284_free_ports(&port_list);

	return 0;
}