Wie chatte ich mit ADBD über Port 5037 oder USB -FFS im Gerät?

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Wie chatte ich mit ADBD über Port 5037 oder USB -FFS im Gerät?

by Anonymous » 27 Feb 2025, 10:38

Ich arbeite an einem eingebetteten Linux-System (Kernel-5.10.188) mit BusyBox und ADBD im Dateisystem. Ich muss den ADBD von der Serienkonsole neu starten, um ADB -Shell funktionieren zu lassen.

Code: Select all

# lsof | grep adbd
201     /usr/bin/adbd   0       /dev/null
201     /usr/bin/adbd   1       /dev/console
201     /usr/bin/adbd   2       /dev/console
201     /usr/bin/adbd   3       socket:[3341]
201     /usr/bin/adbd   4       socket:[3342]
201     /usr/bin/adbd   5       socket:[3343]
201     /usr/bin/adbd   6       socket:[3344]
201     /usr/bin/adbd   7       socket:[3345]
201     /usr/bin/adbd   8       socket:[3346]
201     /usr/bin/adbd   9       /dev/usb-ffs/adb/ep0
201     /usr/bin/adbd   10      /dev/usb-ffs/adb/ep1
201     /usr/bin/adbd   11      /dev/usb-ffs/adb/ep2
201     /usr/bin/adbd   12      socket:[3943]
201     /usr/bin/adbd   13      socket:[3944]
201     /usr/bin/adbd   14      /dev/ptmx

# netstat -a
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 192.168.0.1:www         0.0.0.0:*               LISTEN
tcp        0      0 192.168.0.1:domain      0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:56797           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:56800           0.0.0.0:*               LISTEN
tcp        0      0 localhost:5037          0.0.0.0:*               LISTEN
udp        0      0 0.0.0.0:56797           0.0.0.0:*
udp        0      0 192.168.0.1:domain      0.0.0.0:*
udp        0      0 0.0.0.0:bootps          0.0.0.0:*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node Path
unix  2      [ ]         DGRAM                      1565 /var/run/hostapd/wlan0
unix  5      [ ]         DGRAM                      1212 /dev/log
unix  2      [ ACC ]     STREAM     LISTENING       3344 @jdwp-control
unix  3      [ ]         STREAM     CONNECTED       3346
unix  2      [ ]         DGRAM                      1553
unix  3      [ ]         STREAM     CONNECTED       3944
unix  3      [ ]         STREAM     CONNECTED       3341
unix  3      [ ]         STREAM     CONNECTED       3342
unix  2      [ ]         DGRAM                      1213
unix  3      [ ]         STREAM     CONNECTED       3345
unix  3      [ ]         STREAM     CONNECTED       3943
unix  2      [ ]         DGRAM                      1541
Ich habe versucht, mit ADBD im selben Gerät über 127.0.0.1:5037 zu kommunizieren, wie es folgt, um Host zu senden: Geräte , es ist fehlgeschlagen (wie erwartet).

Code: Select all

#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define ADB_HOST "127.0.0.1"
#define ADB_PORT 5037

void send_adb_command(const char *command) {
int sock = socket(AF_INET, SOCK_STREAM, 0);
struct sockaddr_in addr = {
.sin_family = AF_INET,
.sin_port = htons(ADB_PORT),
.sin_addr.s_addr = inet_addr(ADB_HOST)
};

struct timeval timeout = {2, 0};
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));

connect(sock, (struct sockaddr*)&addr, sizeof(addr));

char header[5];
snprintf(header, sizeof(header), "%04X", (unsigned int)strlen(command));
send(sock, header, 4, 0);
send(sock, command, strlen(command), 0);

char response[1024];
recv(sock, response, sizeof(response)-1, 0);
printf("Response: %s\n", response);

close(sock);
}

int main() {
send_adb_command("host:version");
send_adb_command("host:devices");
return 0;
}
Die oben genannten Codes konnten keine erwarteten Ergebnisse erhalten, wenn es im selben Gerät wie ADBD für adbd mit adb_host = 0 erstellt wurde. Das gleiche Gerät?
Aktualisiert mit Fragen zu Endpunkten von USB-FFS. Wenn ja, was ist das richtige Nachrichtenformat des Befehls adb Shell ?

Top