serial
Module for interfacing with serial ports. This module uses wjwwood/serial C++ library as its backend.
flowcontrol_hardware
— Flow control type (hardware) for the serial portflowcontrol_none
— Flow control type (none) for the serial portflowcontrol_software
— Flow control type (software) for the serial portparity_even
— Parity type (even) for the serial portparity_mark
— Parity type (mark) for the serial portparity_none
— Parity type (none) for the serial portparity_odd
— Parity type (odd) for the serial portparity_space
— Parity type (space) for the serial portstopbits_one
— Stop bits type (one) for the serial portstopbits_one_point_five
— Stop bits type (one point five) for the serial portstopbits_two
— Stop bits type (two) for the serial port
list_ports()
— Get the list of all available serial ports
serial
— This class provides a serial port interface
construct()
— The constructor. Create an instance of class serial
and open the port close()
— Close the serial port get_error()
— Get the error string is_open()
— Get the open status of the serial port read()
— Read a given amount of bytes from the serial port and then return a string containing the data readln()
— Read from the serial port until eol_char
is received write()
— Write a string to the serial port serial_port
— This class stores serial port data from function list_ports()
import serial
arduino = serial("/dev/ttyACM0")
if !arduino.is_open()
exit(arduino.get_error())
endif
arduino.write("Hello")
data = arduino.readln()
writeln(data)
arduino.close()