How to use Emulator's serial port

5,366 views
Skip to first unread message

coolio

unread,
Jan 26, 2009, 12:35:06 AM1/26/09
to android-platform
Hi,

I am trying to do debug my bluetooth development on emulator. As David
pointed out, emulator's /dev/ttyS2 can be mapped to serial port on
host.

I have a test program that is running very well with G1/ADP1. However,
the same program does not work well when running on emulator. The
following is what I have done so far,

1) emulatro -qemu -serial /dev/ttyS0

I can see HCI reset command works and few other commands in the
process of device reset. However, the test program can not run further
because it detected hardware error.

2) I added an FTDI usb serial port to the host and started emulator
again, emulator -qemu -serial /dev/ttyUSB0. Running the test program
have the same result.

Is there anyother processes in emulator that also use /dev/ttyS2? Can
I map /dev/ttyS3 to /dev/ttyUSB0 on host? Any help would be greatly
appreciated.

Thanks

coolio

unread,
Jan 28, 2009, 6:06:03 PM1/28/09
to android-platform
I have run the emulator on Windows with the following command,

emulator -qemu -serial COM1

It prompt me to configure COM1. So I choose my configuration with
hardware flow control.

The same program that have problem when it was running the Android
emulator on Ubuntu-8.10 now is working without a glitch, just as it is
running on Ubuntu-8.10.

In my test program, I always configured the device with hardware flow
control with CRTSCTS bit, so I suspect maybe /dev/ttyS0 on my Ubuntu
is not confiugred with crtscts. I used stty to turn on the flow
control everytime I run emulator and adb shell.

I still have the same problem. The program will hang after serval
write and read to/from /dev/ttyS2. After serval write calls of writing
about 2K bytes, it just stoped.

Findally, running emulator and adb shell, I can do "cat <file> > /dev/
ttyS2" with a file as large as 200kb.

It doesn't look like that it is a problem in Android Emulator, more
likely is qemu does not work well with Ubuntu. In this case, Windows
prevails.

Appreciate if anybody can help me to solve this problem.

Thanks,

kotaro

unread,
Feb 20, 2009, 8:10:27 AM2/20/09
to android-platform
It can read over 2K bytes on Ubuntu-8.10. can't it ?
I'm not too sure if I can help you out, but could I just ask you two
questions.

-How to access /dev/ttyS2/
I think that your program uses 'FileOutput/InputStream' and write/
read method.
Is it correct ?

-Behavior of the emulator on Windows
Can your program write/read over 2K bytes data in the emulator on
Windows ?


Thanks,



On 1月29日, 午前8:06, coolio <justinca...@gmail.com> wrote:
> I have run the emulator on Windows with the following command,
>
> emulator -qemu -serial COM1
>
> It prompt me to configure COM1. So I choose my configuration with
> hardware flow control.
>
> The same program that have problem when it was running the Android
> emulator on Ubuntu-8.10 now is working without a glitch, just as it is
> running on Ubuntu-8.10.
>
> In my test program, I always configured the device with hardware flow
> control with CRTSCTS bit, so I suspect maybe /dev/ttyS0 on my Ubuntu
> is not confiugred with crtscts. I used stty to turn on the flow
> control everytime I run emulator and adb shell.
>
> I still have the same problem. The program will hang after serval
> write and read to/from /dev/ttyS2. After serval write calls of writing
> about 2K bytes, it just stoped.
>
> Findally, running emulator and adb shell, I can do "cat <file> > /dev/ttyS2" with a file as large as 200kb.
>
> It doesn't look like that it is a problem in Android Emulator, more
> likely is qemu does not work well with Ubuntu. In this case, Windows
> prevails.
>
> Appreciate if anybody can help me to solve this problem.
>
> Thanks,
>
> On Jan 25, 9:35 pm, coolio <justinca...@gmail.com> wrote:
>
>
>
> > Hi,
>
> > I am trying to do debug my bluetooth development on emulator. As David
> > pointed out, emulator's /dev/ttyS2can be mapped to serial port on
> > host.
>
> > I have a test program that is running very well with G1/ADP1. However,
> > the same program does not work well when running on emulator. The
> > following is what I have done so far,
>
> > 1) emulatro -qemu -serial /dev/ttyS0
>
> > I can see HCI reset command works and few other commands in the
> > process of device reset. However, the test program can not run further
> > because it detected hardware error.
>
> > 2) I added an FTDI usb serial port to the host and started emulator
> > again, emulator -qemu -serial /dev/ttyUSB0. Running the test program
> > have the same result.
>
> > Is there anyother processes in emulator that also use /dev/ttyS2? Can
> > I map /dev/ttyS3 to /dev/ttyUSB0 on host? Any help would be greatly
> > appreciated.
>
> > Thanks- 引用テキストを表示しない -
>
> - 引用テキストを表示 -
Reply all
Reply to author
Forward
0 new messages