Skip to main content
Skip table of contents

serial_open(port=None, baudrate=115200, bytesize=DR_EIGHTBITS, parity=DR_PARITY_NONE, stopbits=DR_STOPBITS_ONE)

기능

Serial 통신 포트를 오픈합니다.

인수

인수명자료형기본값설명

port

string

None

  • D-SUB(9 pin) 연결 : “COM”
  • USB to Serial 연결 : “COM_USB”

baudrate

int

115200

Baud rate

2400, 4800, 9600, 19200, 38400, 57600, 115200

bytesize

int

8

데이터 bit

  • DR_FIVEBITS: 5
  • DR_SIXBITS: 6
  • DR_SEVENBITS: 7
  • DR_EIGHTBITS: 8

parity

str

"N"

Parity checking

  • DR_PARITY_NONE: "N"
  • DR_PARITY_EVEN: "E"
  • DR_PARITY_ODD: "O"
  • DR_PARITY_MARK: "M"
  • DR_PARITY_SPACE: "S"

stopbits

int

1

Stop bit의 수

  • DR_STOPBITS_ONE =1
  • DR_STOPBITS_ONE_POINT_FIVE = 1.5
  • DR_STOPBITS_TWO = 2

리턴

설명

serial.Serial instance

연결 성공

예외

예외설명

DR_Error (DR_ERROR_TYPE)

인수의 데이터형 오류 시

DR_Error (DR_ERROR_VALUE)

인수의 값이 유효하지 않을 시

DR_Error (DR_ERROR_RUNTIME)

Serial.SerialException 예외 발생

예제

PY
# 시리얼 포트 D-SUB(9 pin)에 연결한 경우 
ser = serial_open(port="COM", baudrate=115200, bytesize=DR_EIGHTBITS, 
parity=DR_PARITY_NONE, stopbits=DR_STOPBITS_ONE)
 
res = serial_write(ser, b"123ABC")
 
serial_close(ser)
 
 
# USB to serial 장비를 USB 포트에 연결한 경우 
ser = serial_open(port="COM_USB", baudrate=115200, bytesize=DR_EIGHTBITS, 
parity=DR_PARITY_NONE, stopbits=DR_STOPBITS_ONE)
 
res = serial_write(ser, b"123ABC")
 
serial_close(ser)
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.