
To send a string "10,20,30" and prints the response on the screen. This example prints the list of serial ports and use the first one This means that if you need USB enumeration Using the relay module with Teraterm is just as easy. For example, here is the response for ver command. Connect the device to a USB port on the host system Install driver. Unfortunately the USB enumeration package for darwin (MacOSX) requires cgo goSerial Using this product involves the following simple steps. Contribute to bugst/go-serial development by creating an account on GitHub. This library tries to avoid the use of the "C" package (and consequently the need A cross-platform serial library for go-lang. Ports, err := enumerator.GetDetailedPortsList()įmt.Printf("Found port: %s\n", port.Name)įmt.Printf(" USB ID %s:%s\n", port.VID, port.PID)įmt.Printf(" USB serial %s\n", port.SerialNumber)įor details on USB port enumeration see the documentation of the specific package. GetDetailedPortsList function in the enumerator package: The USB metadata, like VID/PID or USB Serial Number, with the If a port is a virtual USB-CDC serial port (for example an USB-to-RS232Ĭable or a microcontroller development board) is possible to retrieve 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:

So the first step is to grab that, and follow the along with the Golang installation instructions.
#GOSERIAL EXAMPLE HOW TO#
The following snippets shows how to declare a configuration for 57600_E71: The veritable Dave Cheney maintains unofficial ARM builds of Go which are compatible with the Raspberry PI.

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 so the import line Package serial is a cross-platform serial library for the go language.
