android emulator에서 serial port를 통해 embedded 장비와 통신하기

Date
Tags
android
serial port
부가 설명
분류
android device

에뮬레이터

실행

디바이스 목록 조회

$ emulator -list-avds # 결과 예시 Pixel_4_API_32_2

명령줄로 에뮬레이터 실행

$ emulator -avd avd_name [ {-option [value]} … ] or $ emulator @avd_name [ {-option [value]} … ] # 예시 $ emulator -avd Nexus_5X_API_23 -netdelay none -netspeed full

시리얼 포트 연결

시리얼 포트 지정 ( mac ) - 미완성

시리얼 포트 조회
$ ls /dev/tty.* $ ls /dev/cu.* $ ls /dev/{tty,cu}.* # 위 두개 커맨드 한번에 조회 # 결과 예시 /dev/tty.Bluetooth-Incoming-Port /dev/tty.usbserial-AD0JLURQ /dev/tty.PaMuSlide /dev/tty.wlan-debug /dev/cu.Bluetooth-Incoming-Port /dev/cu.PaMuSlide /dev/cu.usbserial-AD0JLURQ /dev/cu.wlan-debug
시리얼 포트 통신 내용 관찰
$ screen /dev/tty.[yourSerialPortName] [yourBaudRate] # 예시 $ screen /dev/tty.usbserial-A6004byf 9600
시리얼 포트 연결해서 에뮬레이터 켜기
notion image
# 예시 $ emulator -avd Pixel_2_API_30 -verbose -qemu -serial COM6 $ emulator -avd Pixel_4_API_32_2 -verbose -qemu -serial /dev/tty.usbserial-AD0JLURQ\ emulator -avd Pixel_4_API_32_2 -verbose -qemu -chardev tty,path=/dev/ttyUSB0,id=usbserial-AD0JLURQ -serial /dev/tty.usbserial-AD0JLURQ\ emulator -avd Pixel_4_API_32_2 -no-snapshot -qemu -device usb-ehci,id=ehci -device usb-host,bus=ehci.0,hostbus=1,hostport=4
VERBOSE | Starting hostapd main loop. VERBOSE | Android qemu version 30.9.4.0 (build_id 7759208) (CL:N/A) VERBOSE | Starting QEMU main loop VERBOSE | registered 'boot-properties' qemud service VERBOSE | Adding boot property: 'ro.opengles.version' = '196608' VERBOSE | Adding boot property: 'qemu.sf.fake_camera' = 'front' VERBOSE | Adding boot property: 'dalvik.vm.heapsize' = '512m' VERBOSE | Adding boot property: 'qemu.hw.mainkeys' = '0' VERBOSE | Adding boot property: 'qemu.sf.lcd_density' = '440' INFO | Rootcanal has **NOT** been activated. qemu-system-aarch64: -serial /dev/tty.usbserial-AD0JLURQ: 'serial' is not a valid char driver name qemu-system-aarch64: -serial /dev/tty.usbserial-AD0JLURQ: could not connect serial device to character backend '/dev/tty.usbserial-AD0JLURQ' VERBOSE | Done with QEMU main loop WARNING | Unknown tab selected.
 
 
 
 
brew update && \ brew tap jlhonora/lsusb && \ brew install lsusb # m1이라면 arch -arm64 brew install lsusb
lsusb Bus 001 Device 002: ID 1d5c:5510 Fresco Logic Inc. Frescologic USB2.0 HUB Bus 001 Device 005: ID 413c:c010 Dell Inc. Dell DA310 Serial: 11AD1D0AB3B53D19051D0B00 Bus 001 Device 003: ID 0853:0134 0853 Mini Keyboard Bus 001 Device 001: ID 0403:6001 Future Technology Devices International Limited FT232R USB UART Serial: AD0JLURQ Bus 000 Device 000: ID 1d5c:5510 Fresco Logic Inc. USB 3.1 Bus
 

시리얼 포트 지정 ( windows )

notion image
$ emulator.exe -avd Pixel_2_API_30 -verbose -qemu -serial COM6
notion image
notion image