Skip to main content
Skip table of contents

serial_write(ser, tx_data)

기능

Serial 포트에 데이터(tx_data)를 기록합니다.

인수

인수명자료형기본값설명

ser

serial.Serial

-

Serial instance

tx_data

byte

-

송신할 데이터

  • 데이터 타입 byte 형이어야 합니다.
  • 하기 예제 참조 바랍니다.

리턴

설명

0

성공

-1

Port가 open 상태가 아닙니다.

-2

serial.SerialException 예외 발생

예외

예외설명

DR_Error (DR_ERROR_TYPE)

인수의 데이터형 오류 시

예제

PY
ser = serial_open(port="COM", baudrate=115200, bytesize=DR_EIGHTBITS, 
	parity=DR_PARITY_NONE, stopbits=DR_STOPBITS_ONE)

serial_write(ser, b"123456789") #b는 bytes 형을 의미합니다.

# string을 byte 형으로 변환 
msg = “abcd”               # msg는 string 변수
serial_write(ser, msg.encode()) # encode()는 string형을 byte형으로 변환  

serial_close(ser)
JavaScript errors detected

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

If this problem persists, please contact our support.