tags:

views:

168

answers:

1

I wasn't really sure if this was the right site to put this question on, but I put it here since this is sort of a programming question and I figured the SO crowd was the most Linux-oriented of the three sites.

Anyways, I'm trying to find out a way to simulate disconnecting a device from a software aspect, just as if a user physically disconnected it. So far I've made a udev rule in /etc/udev/rules.d called 10-nano.rules:

SYSFS{idVendor}=="05ac", OPTIONS+="ignore_device"

This rule works fine for ignoring devices, but only after they have been disconnected and reconnected. But what i want to do is to be able to write the rule, and then have the device ignored as if it were disconnected. I've tried "udevadm trigger" with and without sudo, but for some reason I cannot apply this rule while the device is connected. Any suggestions?

By the way, I am able to reconnect a device that has been ignored by removing 10-nano.rules, and then running "sudo udevadm trigger", but like said above, not the other way around. (for some reason my system time and internet get messed up when I run that command though)

A: 

Have you tried to rmmod the module that controls the device?

You can also simulate remove events with udevadm test, p.e:

sudo udevadm test --action="remove" <devpath>

You can see how the devpaths are taking a look to udevadm monitor when physically connecting or removing a device, or check them in /sys/<devpath>.

Jaime Soriano