3.7.0 3.6.0 3.5.0 3.4.0 3.3.0 3.2.2 3.2.1 3.2.0 Korean English Chinese Czech Dutch French German Hungarian Italian Japanese Polish Portuguese Spanish
3.7.0 3.6.0 3.5.0 3.4.0 3.3.0 3.2.2 3.2.1 3.2.0 Korean English Chinese Czech Dutch French German Hungarian Italian Japanese Polish Portuguese Spanish

serial_write()

정의

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)

인수의 데이터형 오류 시

예제

Python
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)

Keyword

serial_ / write