Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rebase upstream #1

Merged
merged 69 commits into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
86b770d
Enumerator: Fixed go:generate comment
albenik Jun 30, 2017
eae1344
Merge pull request #36 from Lobaro/v1
cmaglie Jul 28, 2017
c702e0a
Added OSX environment to travis builds
cmaglie Aug 19, 2018
3ee4586
Splitted usb_darwing.go in two different build units based on go version
cmaglie Aug 19, 2018
3c7a545
Removed -fconstant-cfstrings CGO build flag
cmaglie Aug 19, 2018
ef634e5
Removed duplicated methods on (nowadays) equivalent type C.io_*_t
cmaglie Aug 19, 2018
75aa16d
CFRef are no more internally represented as pointer but as integers
cmaglie Aug 19, 2018
ee147ff
Added Release method to CFStringRef
cmaglie Aug 19, 2018
71fe05a
Added Release method to CFTypeRef
cmaglie Aug 19, 2018
cdac3b3
Removed extra parenthesis
cmaglie Aug 19, 2018
6085517
Made error variable explicit in search loop
cmaglie Aug 19, 2018
338c399
Factored out C.IORegistryEntryCreateCFProperty method
cmaglie Aug 19, 2018
de1714d
Added portlist cmd-line utility
cmaglie Aug 19, 2018
e423395
Fixed wrong build tags... oops
cmaglie Aug 19, 2018
1c2446b
Implementing compatibility with go latest
cmaglie Aug 19, 2018
d759e28
Merge pull request #51 from bugst/osx-fix
cmaglie Aug 23, 2018
d3b8f81
Added go1.11 to travis build
cmaglie Aug 27, 2018
219de06
Fixed darwin build for go1.10+
cmaglie Aug 27, 2018
5f7892a
Merge pull request #52 from bugst/osx-fix-again
cmaglie Aug 27, 2018
24a6610
Updated license years
cmaglie Dec 2, 2019
df95023
Introducing go.mod for dep management
cmaglie Dec 2, 2019
f2a9ea9
Updates to readme
cmaglie Dec 2, 2019
15b0a66
Switch to gh-actions (WIP 1/2) (#67)
cmaglie Dec 3, 2019
96546e1
Added some cross-os builds
cmaglie Dec 3, 2019
88e0816
Fixed enumerator build for openbsd (unsupported operation)
cmaglie Dec 3, 2019
d1a463e
Updated build-passing badge
cmaglie Dec 3, 2019
6a673bf
Transparently handle EINTR during Read
cmaglie Dec 3, 2019
900c828
fixed API procSetupDiGetDeviceRegistryPropertyW
giacomoberlin Aug 16, 2017
4df0da8
completed retrievePortDetailsFromDevInfo
giacomoberlin Aug 16, 2017
f0d91f6
Product in PortDetails struct
giacomoberlin Aug 16, 2017
820cffa
Added doc for new USB Product field (windows-only)
cmaglie Apr 18, 2020
9f6eea0
Fixing getPortList on windows without any ports
martinzak-zaber Mar 21, 2019
f7a06a7
Merge remote-tracking branch 'origin/v1'
cmaglie Apr 18, 2020
1131ba5
Do not return -1 from Read() and Write()
Feb 2, 2019
1b760a8
allow Close() to be called from other goroutine than Read
angri Sep 15, 2017
6500d68
Added test to detect correct behaviour in Close and Read ops
cmaglie Apr 18, 2020
545e830
Allow multiple calls to close
niondir Nov 27, 2017
f0282e0
Use mutex on Close() to avoid data races on windows
niondir Nov 30, 2017
66bfced
Added test for port double close
cmaglie Apr 18, 2020
49ab90e
Updates to readme
cmaglie Apr 19, 2020
640e755
Wait for socat to be ready before running full test.
QuLogic Apr 20, 2020
f88d900
changed the example_test.go so it stops reading when "\n\r" is received
lukasbeckercode May 8, 2020
b015421
removed empty line
lukasbeckercode May 8, 2020
578b2ec
only check for newline instead of newline and carraiage return
lukasbeckercode May 8, 2020
eb474d2
Use golang.org/x/sys/unix provided ioctl functions
maddie Sep 10, 2020
00e63fc
small cosmetic fix
cmaglie May 10, 2020
57b513a
add support for darwin arm64
tobiaskohlbau Feb 7, 2021
be77090
update goselect to get riscv support
cbrake Feb 19, 2021
e18766f
update go generate
polomsky May 9, 2020
b62cd23
Added support for macosx 10.11+
cmaglie Feb 26, 2021
b6c28f7
Merge pull request #101 from cmaglie/big-sur-support
cmaglie Feb 26, 2021
233eb2a
Refresh run of go generate with the latest mksyscall
cmaglie Feb 26, 2021
388e793
Merge pull request #102 from cmaglie/go-generate-rerun
cmaglie Feb 26, 2021
7183520
run of go-fmt
cmaglie Jan 6, 2021
57ac200
windows: improved serial number detection on composite USB devices
cmaglie Jan 6, 2021
383ed1c
Merge pull request #103 from cmaglie/windows-improve-usb-sernum-disc
cmaglie Feb 26, 2021
f355dbf
windows: correcly signal PortClosed error on blocked Read()
cmaglie Mar 12, 2017
a63b288
linux: detect port disconnection during Read
cmaglie Jul 27, 2017
2cb14f0
SetReadTimeout: unix implementation
cmaglie May 10, 2020
23dbc8b
SetReadTimeout: windows implementation
cmaglie May 10, 2020
01c367d
Merge pull request #109 from cmaglie/timeouts
cmaglie Jun 29, 2021
cff9b23
Allow setting custom baudrates on serial ports (mac and linux version)
cmaglie Jun 30, 2021
8ed18bb
Fixed custom baud rate settings for MacOSX
cmaglie Jun 30, 2021
9d74cb0
Added *bsd placeholders
cmaglie Jun 30, 2021
13b6f1a
Merge pull request #111 from cmaglie/custom-baudrate
cmaglie Jul 1, 2021
0213833
Fixed build for linux/ppc64le
cmaglie Jul 13, 2021
37dba3a
Merge pull request #113 from cmaglie/fix-ppc64lebuild
cmaglie Jul 20, 2021
9cebdc6
Small update to docs
cmaglie Jul 20, 2021
adc54fb
Updated license years
cmaglie Jul 20, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: test

on:
push:
branches:
- master
pull_request:

jobs:
native-os-build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v1
- uses: actions/setup-go@v1
with:
go-version: "1.13"
- name: Build native
run: GOARCH=amd64 go build -v ./...
shell: bash
- name: Install socat
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install socat
shell: bash
- name: Run unit tests
run: go test -v -race ./...
shell: bash
- name: Cross-build for 386
if: matrix.os != 'macOS-latest'
run: GOARCH=386 go build -v ./...
shell: bash
- name: Cross-build for arm
if: matrix.os != 'macOS-latest'
run: GOARCH=arm go build -v ./...
shell: bash

cross-os-build:
strategy:
matrix:
go-os-pairs:
- "freebsd amd64"
- "openbsd amd64"
- "openbsd 386"
- "openbsd arm"
- "linux ppc64le"

runs-on: "ubuntu-latest"

steps:
- uses: actions/checkout@v1
- uses: actions/setup-go@v1
with:
go-version: "1.13"
- name: Cross-build
run: |
set ${{ matrix.go-os-pairs }}
GOOS=$1 GOARCH=$2 go build -v ./...
shell: bash
40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Copyright (c) 2014-2016, Cristian Maglie.
Copyright (c) 2014-2021, Cristian Maglie.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
30 changes: 11 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
[![Build Status](https://travis-ci.org/bugst/go-serial.svg?branch=v1)](https://travis-ci.org/bugst/go-serial)
[![Build Status](https://github.com/bugst/go-serial/workflows/test/badge.svg)](https://github.com/bugst/go-serial/actions?workflow=test)

# go.bug.st/serial.v1
# go.bug.st/serial

A cross-platform serial library for go-lang.

## Documentation and examples

See the godoc here: https://godoc.org/go.bug.st/serial.v1
See the godoc here: https://godoc.org/go.bug.st/serial

## Development
## go.mod transition

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`.
This library now support `go.mod` with the import `go.bug.st/serial`.

```
cd $GOPATH
mkdir -p src/go.bug.st/
git clone https://github.com/bugst/go-serial.git -b v1 src/go.bug.st/serial.v1
go test go.bug.st/serial.v1
```
If you came from the pre-`go.mod` era please update your import paths from `go.bug.st/serial.v1` to `go.bug.st/serial` to receive new updates. Anyway, the latest `v1` release should still be avaiable using the old import.

## What's new in v1
## Credits

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 come from the version v0 and want to see the full list of API changes, please check this pull request:

https://github.com/bugst/go-serial/pull/5/files
:sparkles: Thanks to all awesome [contributors]! :sparkles:

## License

The software is release under a BSD 3-clause license
The software is release under a [BSD 3-clause license]

https://github.com/bugst/go-serial/blob/v1/LICENSE
[contributors]: https://github.com/bugst/go-serial/graphs/contributors
[BSD 3-clause license]: https://github.com/bugst/go-serial/blob/master/LICENSE

10 changes: 5 additions & 5 deletions doc.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
//
// Copyright 2014-2017 Cristian Maglie. All rights reserved.
// Copyright 2014-2021 Cristian Maglie. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//

/*
Package serial is a cross-platform serial library for the go language.

The canonical import for this library is go.bug.st/serial.v1 so the import line
The canonical import for this library is go.bug.st/serial so the import line
is the following:

import "go.bug.st/serial.v1"
import "go.bug.st/serial"

It is possible to get the list of available serial ports with the
GetPortsList function:
Expand Down Expand Up @@ -84,7 +84,7 @@ cable or a microcontroller development board) is possible to retrieve
the USB metadata, like VID/PID or USB Serial Number, with the
GetDetailedPortsList function in the enumerator package:

import "go.bug.st/serial.v1/enumerator"
import "go.bug.st/serial/enumerator"

ports, err := enumerator.GetDetailedPortsList()
if err != nil {
Expand All @@ -110,4 +110,4 @@ Unfortunately the USB enumeration package for darwin (MacOSX) requires cgo
to access the IOKit framework. This means that if you need USB enumeration
on darwin you're forced to use cgo.
*/
package serial // import "go.bug.st/serial.v1"
package serial
12 changes: 3 additions & 9 deletions enumerator/doc.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
//
// Copyright 2014-2017 Cristian Maglie. All rights reserved.
// Copyright 2014-2021 Cristian Maglie. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//

/*
Package enumerator is a golang cross-platform library for USB serial port discovery.

WARNING: this library is still beta-testing code! please consider the library
and the API as *unstable*. Beware that, even if at this point it's unlike to
happen, the API may be subject to change until this notice is removed from
the documentation.

This library has been tested on Linux, Windows and Mac and uses specific OS
services to enumerate USB PID/VID, in particular on MacOSX the use of cgo is
required in order to access the IOKit Framework. This means that the library
cannot be easily cross compiled for GOOS=darwing targets.

cannot be easily cross compiled for darwin/* targets.
*/
package enumerator // import "go.bug.st/serial.v1/enumerator"
package enumerator
11 changes: 7 additions & 4 deletions enumerator/enumerator.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//
// Copyright 2014-2017 Cristian Maglie. All rights reserved.
// Copyright 2014-2021 Cristian Maglie. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//

package enumerator // import "go.bug.st/serial.v1/enumerator"
package enumerator

//go:generate go run ../extras/mksyscall_windows.go -output syscall_windows.go usb_windows.go
//go:generate go run golang.org/x/sys/windows/mkwinsyscall -output syscall_windows.go usb_windows.go

// PortDetails contains detailed information about USB serial port.
// Use GetDetailedPortsList function to retrieve it.
Expand All @@ -18,7 +18,10 @@ type PortDetails struct {
SerialNumber string

// Manufacturer string
// Product string

// Product is an OS-dependent string that describes the serial port, it may
// be not always available and it may be different across OS.
Product string
}

// GetDetailedPortsList retrieve ports details like USB VID/PID.
Expand Down
11 changes: 7 additions & 4 deletions enumerator/example_getdetailedportlist_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
//
// Copyright 2014-2017 Cristian Maglie. All rights reserved.
// Copyright 2014-2021 Cristian Maglie. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//

package enumerator_test

import "fmt"
import "log"
import "go.bug.st/serial.v1/enumerator"
import (
"fmt"
"log"

"go.bug.st/serial/enumerator"
)

func ExampleGetDetailedPortsList() {
ports, err := enumerator.GetDetailedPortsList()
Expand Down
Loading