MID ÇÁ·ÎÇÊ

javax.microedition.io
Interface CommConnection

All Superinterfaces:
Connection, InputConnection, OutputConnection, StreamConnection

public interface CommConnection
extends StreamConnection

ÀÌ ÀÎÅÍÆäÀ̽º´Â ³í¸®Àû Á÷·Ä Æ÷Æ® ¿¬°áÀ» Á¤ÀÇÇÕ´Ï´Ù. "³í¸®Àû" Á÷·Ä Æ÷Æ®´Â ¹ÙÀÌÆ®¸¦ ¿¬¼ÓÀûÀ¸·Î Àü¼ÛÇÏ´Â ³í¸®Àû ¿¬°á·Î Á¤Àǵ˴ϴÙ. ³í¸®Àû Á÷·Ä Æ÷Æ®´Â ±âº» ¿î¿µ üÁ¦ ³»¿¡¼­ Á¤ÀÇµÇ¸ç ¹°¸®Àû RS-232 Á÷·Ä Æ÷Æ®¿¡ ÀÏÄ¡ÇÏÁö ¾ÊÀ» ¼öµµ ÀÖ½À´Ï´Ù. ¿¹¸¦ µé¾î, IrDA IRCOMM Æ÷Æ®´Â "³í¸®Àû" Á÷·Ä Æ÷Æ®·Î ÀÛµ¿ÇÒ ¼ö ÀÖµµ·Ï ¿î¿µ üÁ¦ ³»¿¡¼­ ³í¸®Àû Á÷·Ä Æ÷Æ®·Î ±¸¼ºÇÒ ¼ö ÀÖ½À´Ï´Ù.

Åë½Å Æ÷Æ®´Â ¸í½ÃÀû Æ÷Æ® ½Äº°ÀÚ¿Í ³»ÀåµÈ ±¸¼º ¸Å°³ º¯¼ö°¡ °¢°¢ ¼¼¹ÌÄÝ·Ð(;)À¸·Î ±¸ºÐµÈ ÀÏ¹Ý ¿¬°á ÇÁ·¹ÀÓ¿öÅ© ¹®ÀÚ¿­À» »ç¿ëÇÏ¿© ¾×¼¼½ºÇÕ´Ï´Ù.

ƯÁ¤ Á÷·Ä Æ÷Æ®¿¡ ¿©·¯ ÀÀ¿ë ÇÁ·Î±×·¥À» µ¿½Ã¿¡ ¿¬°áÇÒ ¼ö´Â ¾ø½À´Ï´Ù. ¿¬°áÀÌ ÀÌ¹Ì ¿­·Á ÀÖÀ» ¶§ Connector.open()À» »ç¿ëÇÏ¿© Á÷·Ä Æ÷Æ®¸¦ ¿­·Á°í ½ÃµµÇϸé java.io.IOExceptionÀÌ ¹ß»ýÇÕ´Ï´Ù.

¿¬°áÀ» ¿­ ¶§´Â À¯Çü°ú ¸Å°³ º¯¼ö°¡ ÀÖ´Â URI¸¦ »ç¿ëÇÕ´Ï´Ù. RFC 2396¿¡ Á¤ÀÇµÈ Ã¼°è´Â ´ÙÀ½°ú °°½À´Ï´Ù.
comm:<port identifier>[<optional parameters>]

ù ¹øÂ° ¸Å°³ º¯¼ö´Â ³í¸®Àû ÀåÄ¡ À̸§ÀÎ Æ÷Æ® ½Äº°ÀÚ¿©¾ß ÇÕ´Ï´Ù. ÀÌ·¯ÇÑ ½Äº°ÀÚ´Â ÀåÄ¡º°·Î ´Ù¸¥ °æ¿ì°¡ ¸¹±â ¶§¹®¿¡ ÁÖÀÇÇØ¼­ »ç¿ëÇØ¾ß ÇÕ´Ï´Ù.

ƯÁ¤ ÀåÄ¡¿Í ¿î¿µ üÁ¦¿¡ À¯È¿ÇÑ ½Äº°ÀÚ´Â "microedition.commports" ۸¦ »ç¿ëÇÏ¿© System.getProperty() ¸Þ¼Òµå·Î Äõ¸®ÇÒ ¼ö ÀÖ½À´Ï´Ù. comm: Á¢µÎ¾î¿Í °áÇյǾî Á÷·Ä Æ÷Æ® ¿¬°áÀ» ¿©´Â µ¥ »ç¿ëÇÒ ¼ö ÀÖ´Â URL ¹®ÀÚ¿­À» ¸¸µå´Â ½°Ç¥·Î ±¸ºÐµÈ Æ÷Æ® ¸ñ·ÏÀÌ ¹ÝȯµË´Ï´Ù(¾Æ·¡ÀÇ Æ÷Æ® À̸§ ÁöÁ¤ ±Ô¾à ÂüÁ¶).

Ãß°¡ ¸Å°³ º¯¼ö´Â ¼¼¹ÌÄÝ·Ð(;)À¸·Î ±¸ºÐÇØ¾ß ÇÏ¸ç ¹®ÀÚ¿­¿¡ °ø¹éÀº »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù. ƯÁ¤ ¼±Åà ¸Å°³ º¯¼ö°¡ ƯÁ¤ Æ÷Æ®¿¡ ÀûÇÕÇÏÁö ¾ÊÀ¸¸é ÀÌ ¸Å°³ º¯¼ö´Â ¹«½ÃµÉ ¼öµµ ÀÖ½À´Ï´Ù. Æ÷Æ® ½Äº°ÀÚ¿¡ ¼¼¹ÌÄÝ·Ð(;)À» »ç¿ëÇØ¼­´Â ¾È µË´Ï´Ù.

À¯È¿ÇÑ ¸Å°³ º¯¼ö´Â ¾Æ·¡ÀÇ ¸Å°³ º¯¼ö Á¤ÀÇ¿¡ µû¶ó Á¤Àǵ˴ϴÙ. À¯È¿ÇÏÁö ¾Ê°Å³ª ÀνĵÇÁö ¾Ê´Â ¸Å°³ º¯¼ö¸¦ »ç¿ëÇϸé IllegalArgumentExceptionÀÌ ¹ß»ýÇÕ´Ï´Ù. ¸Å°³ º¯¼ö °ªÀÌ ÀåÄ¡¿¡¼­ Áö¿øµÇ¸é ÀÌ °ªÀ» »ç¿ëÇØ¾ß ÇÕ´Ï´Ù. ¸Å°³ º¯¼ö °ªÀÌ Áö¿øµÇÁö ¾ÊÀ¸¸é java.io.IOExceptionÀÌ ¹ß»ýÇÕ´Ï´Ù. baudrate ¸Å°³ º¯¼ö¸¦ ¿äûÇϸé setBaudRate ¸Þ¼Òµå°¡ º¸ ¼Óµµ¸¦ ó¸®ÇÏ´Â °Í°ú µ¿ÀÏÇÑ ¹æ½ÄÀ¸·Î 󸮵˴ϴÙ. ¿¹¸¦ µé¾î, ¿äûµÈ º¸ ¼Óµµ°¡ Áö¿øµÇÁö ¾ÊÀ¸¸é ½Ã½ºÅÛÀÌ À¯È¿ÇÑ º¸ ¼Óµµ·Î ´ëüÇÒ ¼ö ÀÖÀ¸¸ç ÀÌ °ªÀº getBaudRate ¸Þ¼Òµå·Î °Ë»öÇÒ ¼ö ÀÖ½À´Ï´Ù.

¼±Åà ¸Å°³ º¯¼ö

¸Å°³ º¯¼ö ±âº»°ª ¼³¸í
baudrate platform dependent Æ÷Æ® ¼Óµµ
bitsperchar 8 ¹®ÀÚ´ç ¼ýÀÚ ºñÆ®(7 ¶Ç´Â 8)
stopbits 1 ¹®ÀÚ´ç ÁßÁö ºñÆ® ¼ö(1 ¶Ç´Â 2)
parity none ÆÐ¸®Æ¼´Â odd, even ¶Ç´Â noneÀÌ µÉ ¼ö ÀÖ½À´Ï´Ù.
blocking on ÀÌ ¸Å°³ º¯¼ö°¡ onÀ̸é Àбâ Àü¿¡ ¹öÆÛ°¡ °¡µæÂû ¶§±îÁö ´ë±âÇÕ´Ï´Ù.
autocts on ÀÌ ¸Å°³ º¯¼ö°¡ onÀÌ¸é ¾²±â Àü¿¡ CTS ÇàÀÌ È°¼ºÈ­µÉ ¶§±îÁö ´ë±âÇÕ´Ï´Ù.
autorts on ÀÌ ¸Å°³ º¯¼ö°¡ onÀ̸é ÀÔ·Â ¹öÆÛ°¡ °¡µæÂ÷Áö ¾ÊÀº °æ¿ì RTS ÇàÀ» Ȱ¼ºÈ­ÇÕ´Ï´Ù. offÀ̸é RTS ÇàÀÌ Ç×»ó Ȱ¼ºÈ­µË´Ï´Ù.

Connector.open() ¹®ÀÚ¿­ÀÇ BNF Çü½Ä

URI´Â ¾Æ·¡¿¡ ÁöÁ¤µÈ BNF ±¸¹®°ú ÀÏÄ¡ÇØ¾ß ÇÕ´Ï´Ù. URI°¡ ÀÌ ±¸¹®¿¡ ÀÏÄ¡ÇÏÁö ¾ÊÀ¸¸é IllegalArgumentExceptionÀÌ ¹ß»ýÇÕ´Ï´Ù.

<comm_connection_string> ::= "comm:"<port_id>[<options_list>] ;
<port_id> ::= ¿µ¼ýÀÚ ¹®ÀÚ¿­
<options_list> ::= *(<baud_rate_string>| <bitsperchar>| <stopbits>| <parity>| <blocking>| <autocts>| <autorts>) ;
; ÇÑ ¿É¼ÇÀÌ ¿É¼Ç ¸ñ·ÏÀÇ ÀÌÀü ¿É¼Ç°ú Áߺ¹µÇ´Â °æ¿ì
; ÇØ´ç ¿É¼ÇÀÌ ÀÌÀü ¿É¼ÇÀ»
; ¹«½ÃÇÕ´Ï´Ù.
<baud_rate_string> ::= ";baudrate="<baud_rate> TR_
<baud_rate> ::= ¼ýÀÚ ¹®ÀÚ¿­ TR_
<bitsperchar> ::= ";bitsperchar="<bit_value>
<bit_value> ::= "7" | "8"
<stopbits> ::= ";stopbits="<stop_value>
<stop_value> ::= "1" | "2"
<parity> ::= ";parity="<parity_value>
<parity_value> ::= "even" | "odd" | "none"
<blocking> ::= ";blocking="<on_off>
<autocts> ::= ";autocts="<on_off>
<autorts> ::= ";autorts="<on_off>
<on_off> ::= "on" | "off"

º¸¾È

Á÷·Ä Æ÷Æ®¿¡ ´ëÇÑ ¾×¼¼½º´Â ±ÇÇÑ ¾ø´Â µ¥ÀÌÅÍ Àü¼ÛÀ̳ª ¼ö½ÅÀ» ¹æÁöÇϱâ À§ÇØ Á¦Çѵ˴ϴÙ. Á÷·Ä Æ÷Æ® ¿¬°á¿¡ Àû¿ëµÇ´Â º¸¾È ¸ðµ¨Àº ±¸Çö ÇÁ·ÎÇÊ¿¡¼­ Á¤ÀÇÇÕ´Ï´Ù. º¸¾È ¸ðµ¨Àº À¯È¿ÇÑ Á÷·Ä Æ÷Æ® ¿¬°á ¹®ÀÚ¿­À» »ç¿ëÇÑ Connector.open() ¸Þ¼Òµå È£Ã⠽à Àû¿ëµÉ ¼ö ÀÖ½À´Ï´Ù. ÇÁ·ÎÇÊ ±ÇÇÑ ºÎ¿© ü°è¸¦ ÅëÇØ ÀÀ¿ë ÇÁ·Î±×·¥¿¡ Á÷·Ä Æ÷Æ®¿¡ ´ëÇÑ ¾×¼¼½º ±ÇÇÑÀ» ºÎ¿©ÇÏÁö ¾ÊÀ¸¸é Connector.open() ¸Þ¼Òµå¿¡¼­ java.lang.SecurityExceptionÀÌ ¹ß»ýÇÕ´Ï´Ù. º¸¾È ¸ðµ¨Àº ½ÇÇà Áß¿¡, ƯÈ÷ openInputStream(), openDataInputStream(), openOutputStream() ¹× openDataOutputStream() ¸Þ¼Òµå È£Ã⠽à Àû¿ëµÉ ¼öµµ ÀÖ½À´Ï´Ù.

¿¹

¾Æ·¡ ¿¹¿¡¼­´Â CommConnectionÀ» »ç¿ëÇÏ¿© »ùÇà ·çÇÁ¹é ÇÁ·Î±×·¥¿¡ ¾×¼¼½ºÇÏ´Â ¹æ¹ýÀ» º¸¿© ÁÝ´Ï´Ù.

 CommConnection cc = (CommConnection)
            Connector.open("comm:com0;baudrate=19200");
 int baudrate = cc.getBaudRate();
 InputStream is  = cc.openInputStream();
 OutputStream os = cc.openOutputStream();
 int ch = 0;
 while(ch != 'Z') {
     os.write(ch);
     ch = is.read();
     ch++;
 }
 is.close();
 os.close();
 cc.close();

¾Æ·¡ ¿¹¿¡¼­´Â CommConnectionÀ» »ç¿ëÇÏ¿© ÀÌ¿ë °¡´ÉÇÑ Åë½Å Æ÷Æ®¸¦ °Ë»öÇÏ´Â ¹æ¹ýÀ» º¸¿© ÁÝ´Ï´Ù.

 String port1;
 String ports = System.getProperty("microedition.commports");
 int comma = ports.indexOf(',');
 if (comma > 0) {
     // Parse the first port from the available ports list.
     port1 = ports.substring(0, comma);
 } else {
     // Only one serial port available.
     port1 =ports;
 }

±ÇÀåµÇ´Â Æ÷Æ® À̸§ ÁöÁ¤ ±Ô¾à

³í¸®Àû Æ÷Æ® À̸§Àº ¿µ¼ýÀÚ ¹®ÀÚÀÇ Á¶ÇÕÀ» »ç¿ëÇÏ¿© Ç÷§Æû À̸§ ÁöÁ¤ ±Ô¾à°ú ÀÏÄ¡Çϵµ·Ï Á¤ÀÇÇÒ ¼ö ÀÖ½À´Ï´Ù. ÇÏÁö¸¸ Á¦¾ÈµÈ ±Ô¾à¿¡ µû¶ó ÀÌ Å¬·¡½ºÀÇ °¢ ±¸Çö¿¡¼­ Àϰü¼º ÀÖ°Ô Æ÷Æ® À̸§À» ÁöÁ¤ÇÏ´Â °ÍÀÌ ÁÁ½À´Ï´Ù. °¡»ó ¸Ó½Å ±¸Çö ½Ã ´ÙÀ½ ±Ô¾àÀ» µû¶ó¾ß ÇÕ´Ï´Ù.
Æ÷Æ® À̸§¿¡´Â Æ÷Æ® ±â´ÉÀ» ³ªÅ¸³»´Â ÅØ½ºÆ® ¾à¾î°¡ Æ÷ÇÔµÇ¸ç ±× µÚ¿¡´Â Æ÷Æ®ÀÇ ÀÏ·Ã ¹øÈ£°¡ ¿É´Ï´Ù. ´ÙÀ½°ú °°Àº ÀåÄ¡ À̸§ À¯ÇüÀ» »ç¿ëÇØ¾ß ÇÕ´Ï´Ù.

ÀÌ À̸§ ÁöÁ¤ ü°è¿¡¼­´Â API »ç¿ëÀÚ°¡ ¿øÇÏ´Â Æ÷Æ® À¯ÇüÀ» °áÁ¤ÇÒ ¼ö ÀÖ½À´Ï´Ù. ¿¹¸¦ µé¾î, ÀÀ¿ë ÇÁ·Î±×·¥ÀÌ µ¥ÀÌÅÍ Á¶°¢À» "ºö"ÇÏ·Á´Â °æ¿ì¿¡´Â ¿¬°áÀ» ¿­ "IR#" Æ÷Æ®¸¦ ãÀ» ¼ö ÀÖ½À´Ï´Ù. ¶Ç´Â »ç¿ë °¡´ÉÇÑ ¸ðµç Æ÷Æ®¸¦ ½ÃµµÇØ º¼ ¼öµµ ÀÖ½À´Ï´Ù.

Since:
MIDP 2.0

Method Summary
 int getBaudRate()
          Á÷·Ä Æ÷Æ® ¿¬°áÀÇ º¸ ¼Óµµ¸¦ °¡Á®¿É´Ï´Ù.
 int setBaudRate(int baudrate)
          Á÷·Ä Æ÷Æ® ¿¬°áÀÇ º¸ ¼Óµµ¸¦ ¼³Á¤ÇÕ´Ï´Ù.
 
Methods inherited from interface javax.microedition.io.InputConnection
openDataInputStream, openInputStream
 
Methods inherited from interface javax.microedition.io.Connection
close
 
Methods inherited from interface javax.microedition.io.OutputConnection
openDataOutputStream, openOutputStream
 

Method Detail

getBaudRate

public int getBaudRate()
Á÷·Ä Æ÷Æ® ¿¬°áÀÇ º¸ ¼Óµµ¸¦ °¡Á®¿É´Ï´Ù.

Returns:
¿¬°áÀÇ º¸ ¼Óµµ
See Also:
setBaudRate(int)

setBaudRate

public int setBaudRate(int baudrate)
Á÷·Ä Æ÷Æ® ¿¬°áÀÇ º¸ ¼Óµµ¸¦ ¼³Á¤ÇÕ´Ï´Ù. ¿äûÇÑ baudrate°¡ Ç÷§Æû¿¡ Áö¿øµÇÁö ¾ÊÀ¸¸é ½Ã½ºÅÛÀÌ À¯È¿ÇÑ ¼³Á¤À¸·Î ´ëüÇÒ ¼öµµ ÀÖ½À´Ï´Ù. ´ëü °ªÀº getBaudRate ¸Þ¼Òµå·Î ¾×¼¼½ºÇÒ ¼ö ÀÖ½À´Ï´Ù.

Parameters:
baudrate - ¿¬°áÀÇ º¸ ¼Óµµ
Returns:
¿¬°áÀÇ ÀÌÀü º¸ ¼Óµµ
See Also:
getBaudRate()

MID ÇÁ·ÎÇÊ

ÀǰßÀ̳ª Á¦¾È »çÇ× º¸³»±â MID ÇÁ·ÎÇÊ »ç¾ç ¹öÀü 2.0
Java´Â ¹Ì±¹ ¹× ´Ù¸¥ ±¹°¡¿¡¼­ Sun Microsystems, Inc.ÀÇ »óÇ¥ ¶Ç´Â µî·Ï »óÇ¥ÀÔ´Ï´Ù. Copyright 1993-2002 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. ¸ðµç ±Ç¸®´Â ÀúÀÛ±ÇÀÚÀÇ ¼ÒÀ¯ÀÔ´Ï´Ù.