Hi Thomas,
Am Mittwoch, den 10.05.2006, 07:46 +0200 schrieb Thomas Viehmann:
> Joachim Breitner wrote:
> > You are probably right. What is upstreams' position on that? Maybe they
> > can implement that in the near future.
> Well, last time something like this came up (with ttyusb detection), it
> was "patches accepted", which is why I tagged this bug accordingly.
I have hacked something up, based on your ttyusb code, and it seems to
work here. I have attached the pcmciascanner* files I created. I hope
you can use them and maybe forward them upstream.
Greetings,
Joachim
--
Joachim "nomeata" Breitner
Debian Developer
[EMAIL PROTECTED] | ICQ# 74513189 | GPG-Keyid: 4743206C
JID: [EMAIL PROTECTED] | http://people.debian.org/~nomeata
/***************************************************************************
$RCSfile$
-------------------
cvs : $Id: usbttyscanner.c 178 2006-04-28 22:22:36Z martin $
begin : Mon Mar 01 2004
copyright : (C) 2004 by Martin Preuss
email : [EMAIL PROTECTED]
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "pcmciascanner_p.h"
#include <gwenhywfar/debug.h>
#include <gwenhywfar/misc.h>
#include <gwenhywfar/directory.h>
#include <gwenhywfar/buffer.h>
#include <gwenhywfar/stringlist.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <errno.h>
#ifdef USE_LIBSYSFS
# include <sysfs/libsysfs.h>
#endif
LC_DEVSCANNER *LC_PcmciaScanner_new() {
LC_DEVSCANNER *sc;
#ifdef USE_LIBSYSFS
char sysfspath[256];
#endif
sc=LC_DevScanner_new();
LC_DevScanner_SetReadDevsFn(sc, LC_PcmciaScanner_ReadDevs);
#ifdef USE_LIBSYSFS
if (! sysfs_get_mnt_path(sysfspath, sizeof(sysfspath))) {
DBG_NOTICE(0, "Will use sysfs to scan for ttyUSB devices")
}
#endif
return sc;
}
/* this function has been submitted by Thomas Viehmann. Thanks ;-) */
int LC_PcmciaScanner_ScanSysFS_Pcmcia(LC_DEVICE_LIST *dl) {
#ifndef USE_LIBSYSFS
DBG_INFO(0, "LibSysFS not supsknumed");
return -1;
#else
struct sysfs_bus *bus = NULL;
struct sysfs_device *curdev = NULL;
#ifndef HAVE_SYSFS2
struct sysfs_device *temp_device = NULL;
#endif
struct sysfs_attribute *cur = NULL;
struct dlist *devlist = NULL;
struct dlist *attributes = NULL;
int sknum=0, vendorId=0, productId=0;
LC_DEVICE *currentDevice;
bus = sysfs_open_bus("pcmcia");
if (bus == NULL) {
DBG_ERROR(0,"Error accessing sysfs");
return -1;
}
devlist = sysfs_get_bus_devices(bus);
if (devlist != NULL) {
dlist_for_each_data(devlist, curdev,
struct sysfs_device) {
sknum = strtol(curdev->bus_id, NULL, 16);
attributes = sysfs_get_device_attributes(curdev);
dlist_for_each_data(attributes, cur,
struct sysfs_attribute) {
if (strcmp(cur->name,"manf_id")==0) {
if (cur->value != NULL) {
vendorId = strtol(cur->value, NULL, 16);
}
else {
DBG_ERROR(0,"manf_id empty");
}
}
if (strcmp(cur->name,"card_id")==0) {
if (cur->value != NULL) {
productId = strtol(cur->value, NULL, 16);
}
else {
DBG_ERROR(0, "card_id empty");
}
}
}
currentDevice=LC_Device_new(LC_Device_BusType_Pcmcia,
0,
sknum,
vendorId, productId);
DBG_DEBUG(0, "Adding device %d (%04x/%04x)",
sknum,
vendorId,
productId);
LC_Device_SetDevicePos(currentDevice, sknum);
LC_Device_List_Add(currentDevice, dl);
}
}
sysfs_close_bus(bus);
return 0;
#endif
}
int LC_PcmciaScanner_ReadDevs(LC_DEVSCANNER *sc, LC_DEVICE_LIST *dl) {
if ( LC_PcmciaScanner_ScanSysFS_Pcmcia(dl) ) {
DBG_DEBUG(0, "here");
return -1;
}
return 0;
}
/***************************************************************************
$RCSfile$
-------------------
cvs : $Id: pcmciascanner_l.h 123 2005-10-22 00:45:35Z aquamaniac $
begin : Mon Mar 01 2004
copyright : (C) 2004 by Martin Preuss
email : [EMAIL PROTECTED]
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
#ifndef CHIPCARD_SERVER_PCMCIASCANNER_L_H
#define CHIPCARD_SERVER_PCMCIASCANNER_L_H
#include "devmonitor.h"
LC_DEVSCANNER *LC_PcmciaScanner();
#endif /* CHIPCARD_SERVER_PCMCIASCANNER_L_H */
/***************************************************************************
$RCSfile$
-------------------
cvs : $Id: usbttyscanner_p.h 123 2005-10-22 00:45:35Z aquamaniac $
begin : Mon Mar 01 2004
copyright : (C) 2004 by Martin Preuss
email : [EMAIL PROTECTED]
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
#ifndef CHIPCARD_SERVER_PCMCIAMONITOR_P_H
#define CHIPCARD_SERVER_PCMCIAMONITOR_P_H
#include "pcmciascanner_l.h"
static int LC_PcmciaScanner_ScanSysFS_Pcmcia(LC_DEVICE_LIST *dl);
static int LC_PcmciaScanner_ReadDevs(LC_DEVSCANNER *sc, LC_DEVICE_LIST *dl);
#endif /* CHIPCARD_SERVER_USBTTYMONITOR_P_H */