The usual Read, Write and Close functions to send and receive data from the The port object implements the io.ReadWriteCloser interface, so we can use The configuration can be changed at any time with the SetMode function: The following snippets shows how to declare a configuration for 57600_E71: In the example above only the speed is changed so the port is opened using 115200_N81. If not specified the default options are 9600_N81, The Open function needs a "mode" parameter that specifies the configuration Port, err := serial.Open("/dev/ttyUSB0", mode) The serial port can be opened with the Open function: It is possible to get the list of available serial ports with the The canonical import for this library is go.bug.st/serial.v1 so the import line Package serial is a cross-platform serial library for the go language. The software is release under a BSD 3-clause license If you come from the version v0 and want to see the full list of API changes, please check this pull request: There are some API improvements, in particular object naming is now more idiomatic, class names are less redundant (for example serial.SerialPort is now called serial.Port), some internal class fields, constants or enumerations are now private and some methods have been moved into the proper interface. If you want to contribute to the development of this library, you must clone this git repository directly into your src folder under src/go.bug.st/serial.v1 and checkout the branch v1. A cross-platform serial library for go-lang.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |