Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com
Return Value:
When the device is opened successfully it
will return a file descriptor which can be
used to read、write and select the device
otherwise it will returns -1.
int write(
int fd,
byte[] data)
fd: file descriptor
data: data to write to the device
Return Value:
When the operation succeeds it will
return the number of characters written
otherwise it will return -1.
Write data to an opened device.
int read(
int fd,
byte[] buf,
int len)
fd: file descriptor
buf: data buffer
len: number of characters to read
Return Value:
When the operation succeeds it will
return the number of characters read
otherwise it will return -1. If before the
read function is called the file pointer
already reaches the end of the device it
will return 0
Read data from an opened device.
int select(
int fd,
int sec,
int usec)
fd: file descriptor
sec: seconds allowed to wait
usec: useconds allowed to wait(1ms =
1000us)
Return Value:
If the device has data it will return 1
otherwise it will return 0. If this operation
fails it will return -1.
Query whether an opened device has
data for reading.
fd: file descriptor
Return Value: No
Notes:
First you need to open a serial device with “openSerialPort”, then your can call
“select” to query if is has available data. When it has data you can call “read” to read
data.
To write data to a device you can call “write”. If you don’t need to use a device
remember to “close” it.