Lua Read Write Serial Port
There is any other way to read from a serial port? If you don't want to touch a compiler I suggest the ser2net daemon which can be installed via opkg. It handles mappings between terminal files and tcp sockets and forwards data between them.
Native ports class serial. Serial __init__ ( port=None, baudrate=9600, bytesize=EIGHTBITS, parity=PARITY_NONE, stopbits=STOPBITS_ONE, timeout=None, xonxoff=False, rtscts=False, write_timeout=None, dsrdtr=False, inter_byte_timeout=None, exclusive=None ) Parameters: • port – Device name or None. • baudrate () – Baud rate such as 9600 or 115200 etc. • bytesize – Number of data bits. Possible values:,,, • parity – Enable parity checking.
Possible values:,,, • stopbits – Number of stop bits. Possible values:,, • timeout () – Set a read timeout value.
• xonxoff () – Enable software flow control. • rtscts () – Enable hardware (RTS/CTS) flow control. • dsrdtr () – Enable hardware (DSR/DTR) flow control. • write_timeout () – Set a write timeout value. • inter_byte_timeout () – Inter-character timeout, None to disable (default). • exclusive () – Set exclusive access mode (POSIX only). A port cannot be opened in exclusive access mode if it is already open in exclusive access mode.
Raises: • – Will be raised when parameter are out of range, e.g. Baud rate, data bits. • – In case the device can not be found or can not be configured. The port is immediately opened on object creation, when a port is given. It is not opened when port is None and a successive call to is required. Port is a device name: depending on operating system.
/dev/ttyUSB0 on GNU/Linux or COM3 on Windows. The parameter baudrate can be one of the standard values: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200. These are well supported on all platforms. Standard values above 115200, such as: 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000 also work on many platforms and devices. Non-standard values are also supported on some platforms (GNU/Linux, MAC OSX >= Tiger, Windows). Though, even on these platforms some serial ports may reject non-standard values. Possible values for the parameter timeout which controls the behavior of: • timeout = None: wait forever / until requested number of bytes are received • timeout = 0: non-blocking mode, return immediately in any case, returning zero or more, up to the requested number of bytes • timeout = x: set timeout to x seconds (float allowed) returns immediately when the requested number of bytes are available, otherwise wait until the timeout expires and return all bytes that were received until then.
Is blocking by default, unless write_timeout is set. For possible values refer to the list for timeout above. Note that enabling both flow control methods ( xonxoff and rtscts) together may not be supported.
It is common to use one of the methods at once, not both. Dsrdtr is not supported by all platforms (silently ignored).
Setting it to None has the effect that its state follows rtscts. Also consider using the function instead of creating Serial instances directly. Note For compatibility reasons, no error is reported when applying or fails on POSIX due to EINVAL (22) or ENOTTY (25).