How to Find the dev path in which usb device is connected? - linux

I have connected two data cards in my server. One is connected in port dev/ttyUSB2. I want to find the other's port.
There are four ports
ttyUSB0,
ttyUSB1,
ttyUSB2,
ttyUSB3.
I already tried lsusb -vv and found out this:
Bus 001 Device 005: ID 19d2:2003

You can look it up in dmesg logs
dmesg|less

Related

assign static ttyUSB

I have 2 USB devices connected to raspberry pi,
CP2108 USB to serial converter which has 4 ports, when I connect to usb I get 4 ttyUSBx
EC25 GSM modem, for this also same case. when I connect I get 4 ports.
How do I assign a static name to all of them?
I have used bellow method but no result.
SUBSYSTEM=="tty", ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0125", SYMLINK+="ttyUSB_EC25_Modem_%s{devpath}"
SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea71", SYMLINK+="ttyUSB_CP2108X_%s{devpath}"
Connect the devices and look under /dev/serial/by-id/. You should have symlinks to these ttyUSBx devices with longer and more descriptive names. No need to use udev rules.

What's the difference between Jackdaw and KillerBee on RZ Raven USB Stick

What is the difference between Jackdaw and KillerBee on ZigBee USB Stick, both seem to be sniffing packet, but Jackdaw can act as a network interface, and KillerBee is only used for pentest? As far as I understand it, you can't use either to connect to like a hub or Wireless router, but only to ZigBee based devices, which would be the IoT devices such as sensors or smart socket etc.
Thank you

Determine USB device file Path

How can i get USB device file path correctly in Linux.
I used command: find / -iname "usb" and got the result as below:
/dev/bus/usb
/sys/bus/usb
/sys/bus/usb/drivers/usb
/sys/kernel/debug/usb
Under /dev/bus/usb i see:
001 002 003 004 005 006
But I think they aren't files as i need.
Under /sys/bus/usb/devices/:
sh-3.2# ls /sys/bus/usb/devices/
1-0:1.0 1-1:1.0 3-0:1.0 5-0:1.0 usb1 usb3 usb5
1-1 2-0:1.0 4-0:1.0 6-0:1.0 usb2 usb4 usb6
And Under /sys/bus/scsi/devices/ when i pluged an USB i see:
2:0:0:0 host0 host2 target2:0:0
And when i removed USB i see:
sh-3.2# ls
host0
So which device file is used for USB? How can i indentify it? I need to make a C program with USB device file...
Further more, could you explain to me the number 1-1:1.0? What does it mean?
Thank you.
So which device file is used for USB? How can i indentify it?
What you see behind /sys/ is mainly configuration/information about devices. /dev/bus/usb is what you are looking for. I think that the following article can help you
http://www.linuxjournal.com/article/7466?page=0,0
Is quite old, but still it can help you. (In the article they speak about /proc/bus/usb, today we have /dev/bus/usb)
Further more, could you explain to me the number 1-1:1.0? What does it mean?
The generic form is
X-Y.Z:A.B
Each field identify the connection point of your device. The first two field are mandatory:
X is the USB bus of your motherboard where is connected the USB system.
Y is the port in use on the bus system
So the USB device identified with the string 3-3 is the device connected on the port 3 of the bus 3.
If you connect an USB hub, you are extending the connection capability of a single USB port. The Linux kernel identify this situation by appending the Z field.
Z is the port is use on an hub
So, the USB device identified with the string 1-2.5 is the device connected on the port 5 of the hub connected on the port 2 of the bus 1.
USB specification allow you to connect in cascade more then one USB hub, so the Linux kernel continue to append the port in use on the different hubs. So, the USB device identified with the string 1-2.1.1 is the device connected on the port 1 of the hub connected on the port 1 of the hub connected to the port 2 of the bus 1.
A fast way to retrieve these information is to read the kernel messages (if you can).
$ dmesg | grep usb
[... snip ...]
[ 2.047950] usb 4-1: new full-speed USB device number 2 using ohci_hcd
[ 2.202628] usb 4-1: New USB device found, idVendor=046d, idProduct=c318
[ 2.202638] usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 2.202643] usb 4-1: Product: Logitech Illuminated Keyboard
[ 2.202648] usb 4-1: Manufacturer: Logitech
[... snip ...]
Then, the last two fields of the pattern (after colon) identify an internal section of an USB device :
A is the configuration number of the device
B is the interface number of a configuration
So, the string 4-1:1.1 means: the interface 1, on configuration 1 that is connected on the port 1 of the bus 4.
You can retrieve these information with the command lsusb.

How to switch wifi channel without dropping connection?

We are developing small internet connected device that connects via wifi and does some work. It is controlled via mobile app.
For configuration purposes we use wi-fi module that can work in both STA + AP modes simultaneously via two interfaces wlan0 and wlan1. One of the interfaces works in Master mode. Phone connects to the device via wlan1 and sends command for the device to connect to another network and waits for result. Device in turn connects to another wi-fi network using wlan0 and notifies the phone if connection was successful or not.
But there is one issue. Both interfaces (wlan0 and wlan1) must work on the same channel as we have single hardware module. This causes channel of wlan1 to change in order to match of channel for wlan0.
Here comes the problem. When channel changes phone looses connection with the device. Is there a way to change wi-fi channel but keep connection between the device and mobile phone?
Our wi-fi module is rtl8723bu.
Linux 3.4.103.
Wifi daemons: hostapd v0.8.x_rtw_r7475.20130812_beta, wpa_supplicant v2.3.
UPDATE
Here is more clearly description what is going on on device.
Let's assume that the phone already connected to Device wlan1 interface with essid DeviceAp which is on channel 1. We have a Router with essid RouterAp which is on channel 6. Device interface wlan0 is not configured and not running.
(Step1 on image below).
Then the phone sends a request to the device to connect to RouterAp.
(Step2 on image below).
When wlan0 starts connecting to RouterAp it changes working channel. Because WiFi module can work only on one channel. The channel of wlan1 also changes (maybe in hard way). Therefore Phone lost DeviceAp and starts roaming.
(Step3 on image below).
SO the update question is:
Is there a way to tell the Phone (or other device) about network change? Or perhaps increase the likelihood that the phone is connected back to DeviceAP.
This behavior is very similar to the process of setting up Google Chromecast.
Chromecast also has two wireless interfaces and change the channel, but the Phone does not lose connection with it.
Image:
http://postimg.org/image/soh78vd17/

EBTABLES. Type of packets "otherhost"

I've got a question concerning ebtables.
The question is concerned with --pkttype-type option.
In description of this option (MAN) I see there are four possible values:
broadcast
multicast
host
otherhost (non of the above)
Please explain me what 4-th option otherhost means. As I know packet can be broadcast, multicast and unicast. Perhaps more packet types exist which I don't know? What happens when I use option --pkttype-type otherhost?
From man ebtables:
a) broadcast (MAC destination is the broadcast address)
b) multiā€cast (MAC destination is a multicast address)
c) host (MAC destination is the receiving network device) This is your MAC address.
d) otherhost (none of the above). MAC addresses of other devices.
What does otherhost mean?
For Ethernet networks, for example when using Ethernet hubs, data going to some computer (with its own MAC address) connected to the Ethernet hub may be seen by any other device (with different MAC address) connected to the same Ethernet hub. You can check this behaviour using wireshark or tcpdump. With Hubs, Ethernet frames going to your computer (MAC addres of your network device as destination) may be seen by any other computer using the same Hub as you.
By default, your network device will pass to your CPU the Ethernet frames that the controller is intended to receive (broadcast, multicast or with your MAC address as destination) even if it is receiving many others (case of using Ethernet hubs)
You can change the default behaviour of your network device by means of the promiscuous mode (wireshark and tcpdump make use of this configuration)
What happens when you use option --pkttype-type otherhost?
Data intended to be received by other devices will match the ebtables rule.

Resources