Motorola i88s manual Connection Optional Parameters, Communicating on a Port

Page 19

Motorola Inc.

i88s J2ME Developers’ Guide

Although serial port access is integrated into the Generic Connection Framework, the URL parameters passed in deviates from the other networking protocols. The optional parameters, such as baud rate, parity, etc are appended to the base parameter of “comm.:0”. Optional parameters are listed below along with the default values when not explicitly specified:

Table 2-2: Connection Optional Parameters

Parameter

Syntax

Options

Default

baudrate

baudrate = x

[300,1200,2400,4800,9600,19200,38400,57600,115200]

19200

databits

databits = x

[8,7]

8

stopbits

stopbits = x

1

1

parity with

parity = x

[n,o,e,s,m] n=none, o = odd, e=even, s=space, m=mark

n

mapping

 

 

 

Flow

flowcontrol =

[n, s, h] / [n, s, h] n=none, s=software,h=hardware

N/n

control

outflow/inflow

 

 

Note - The following combinations of properties are not supported.

7 databits with none parity

8 databits with mark parity

8 databits with space parity

8 databits with odd parity

8 databits with even parity.

IOException will be thrown while trying to use any of the unsupported combinations in Connector.open().

All properties must be semicolon separated. If all properties are not passed, the remaining properties will be taken as default values. The order of properties in the argument does not matter.

name = "comm:0;baudrate=38400;"

Here, the flow control, parity, data bits and stop bits will use the default values.

For mode and timeout refer to the CLDC API specification for the Connector class. Note – The timeout period for Comm Port is 10000ms ~ 10 sec.

Communicating on a Port

The open method of the Connector class returns a StreamConnection object for the serial port. StreamConnection has methods for obtaining input and output streams from a port. The base interface, Connection, has a method to close the port. (Refer to the class hierarchy from StreamConnection from J2ME CLDC API specification).

There are five basic steps to communicating with a port:

1.Open the port using the open() method of Connector. If the port is available, this returns a StreamConnection object for Comm port. Otherwise, an IOException is thrown.

2.Get the output stream using the openOutputStream() method of OutputConnection.

Version 1.0 - Page 19

Image 19
Contents I88s Multi-Communication Device J2ME Developers’ Guide J2ME Networking Disclaimer Document OverviewAcronyms and Definitions Contact InformationAcronyms Used In This Guide Terminology Definition Overview Agps On The i88s PhoneAccuracy Position APIAssist Data Almanac Out Of Date PositionConnection ClassExample GetPositionString name Method DescriptionsRetrieving Position in Java GetPositionGetStatus Using Position in JavaExample Using PositionConnection Positionresponsenoalmanacoverride Addition, to obtain better accurate speed and direction Recommendation Http Https J2ME NetworkingClass Descriptions Https HttpSupported Protocols on the i88s Phone SSL Secure Sockets TCP SocketsServerSockets UDP Sockets Serial Port AccessCommunicating on a Port Connection Optional ParametersImplementation Notes Example using StreamConnectionConcurrent Connections For The i88s Phone Protocol Maximum TipsClass Description File I/OMethod Descriptions Opening a file Reading and Writing Deleting a fileCode Examples Example # 2 Complete MIDlet code Motorola Inc I88s J2ME Developers’ Guide Os = sc.openOutputStream //get InputStream Sc.close Caveats Motorola Inc I88s J2ME Developers’ Guide
Related manuals
Manual 43 pages 17.94 Kb