Open justinianpopa opened 4 years ago
Such an option would make sense. I was not aware of adb -t
.
Would you be interested in implementing it?
I'm not familiar with this code, however i will try to put together a PR sometime next week
I don't have the same issue that OP is having (I'm only ever connecting to two devices, my phone and my tablet), but +1 to this idea. It would just be a nice small time-saving feature to have, being able to type something like scrcpy -t 1
instead of scrcpy -s 192.168.1.6:5555
.
@justinianpopa I am facing the same issues can you tell me what changes I can make to the source code to resolve this issue of target Id.
Example:
adb devices -l serial1111 device usb:3-3product:msm8953_64model:msm8953_for_arm64` device:msm8953_64 transport_id:1 serial1111 device usb:3-4 product:msm8953_64 model:msm8953_for_arm64 device:msm8953_64 transport_id:2
You should add a new option --transport-id
similar to --serial
.
You should add a new option
--transport-id
similar to--serial
.
Thanks for the info, which files in the source code do I refer to to add this option?.
Solution: (tested on a windows system for scrcpy 1.16
Find the transport ID of your devices using
adb devices -l
make a file named adb.bat and put the contents inside it (this will act like a wrapper to the real adb.exe)
call adb.exe -t your_transport_id %*
instead of your_transport_id in the above line use the one that you found in the 1st point.
create a new environment variable for your account with name "ADB" and value would be the path to your adb.bat file
run scrcpy at the command prompt and it would now connect to the device with the transport ID specified.
Greetings, is there any existing way implemented to address several devices connected via USB with their transport id instead of serial? In my development of a custom AOSP ROM i have an issue with distinct devices having the same serial when adb lists them (but different transport id).
ADB allows addressing devices with
-t transport_id
and it works fine for most adb commands except scrcpy which always errors with "more than one device" because i cannot specify -t in it's internal adb call.Using
scrcpy -s serial
is not an option because it consistently chooses the first of the two (or more) devices because they all have the same serial.example:
adb devices -l serial1111 device usb:3-3 product:msm8953_64 model:msm8953_for_arm64 device:msm8953_64 transport_id:1 serial1111 device usb:3-4 product:msm8953_64 model:msm8953_for_arm64 device:msm8953_64 transport_id:2
Right now i can work around around the issue by making a wrapper script that calls the real adb with
adb -t my_transport_id
internally (and by placing it first in PATH scrcpy will use it as if it was the adb binary) but it might be useful if it's not complicated to implement addressing by transport id directly within scrcpy.
Can you put the wrapper here?
For those who are still looking to find a usable solution to this current limitation of scrcpy. Here is what I am doing.
On Windows, in the directory where you have the scrcpy package files, create a new batch file (e.g. scrcpy4tid.bat) and put the following contents inside it:
@echo off
setlocal
set PATH=%PATH%;%CD%
set ADB=adb.exe -t %~1
set allargs=%*
set cmdargs=%%allargs:*%1=%%
call scrcpy.exe %cmdargs%
After that, you should be able to use scrcpy with a specific transport ID from adb, plus any other desired command line parameters of scrcpy added, as follows:
scrcpy4tid <transport ID> <command line argument(s) for scrcpy, if any>
As an example, if you need to run it with transport ID 4 and see display with logical display ID 1, you could use this command line:
scrcpy4tid 4 --display 1
It works well for me on Windows 10 (I did not try it on older Windows versions though). I hope that it will help some of you too.
In principle – in the absence of native support for transport IDs in scrcpy itself, at this point – I would think that including this or a similar batch script as part of the files packaged for Windows could be a viable temporary solution. If the team supporting scrcpy are reading this and like the proposal, please, let me know – I can prepare and push a commit for it sometime.
Thank you, guys, for this great utility. :heart:
For Linux, suggesting one more quick hack in-case if the alias method doesnt work, just connect to the shell of the other device using "adb -t TRANSPORT_ID" command, reboot the device, meanwhile in the second terminal just launch "scrcpy --display_id=id" quickly before the reboot happens. This is just a hack if someone wants a very quick solution remotely without disconnecting the device. Again, the proper method is using alias as suggested above.
Greetings, is there any existing way implemented to address several devices connected via USB with their transport id instead of serial? In my development of a custom AOSP ROM i have an issue with distinct devices having the same serial when adb lists them (but different transport id).
ADB allows addressing devices with
-t transport_id
and it works fine for most adb commands except scrcpy which always errors with "more than one device" because i cannot specify -t in it's internal adb call.Using
scrcpy -s serial
is not an option because it consistently chooses the first of the two (or more) devices because they all have the same serial.example:
Right now i can work around around the issue by making a wrapper script that calls the real adb with
adb -t my_transport_id
internally (and by placing it first in PATH scrcpy will use it as if it was the adb binary) but it might be useful if it's not complicated to implement addressing by transport id directly within scrcpy.