Comments (2)
Hi, I have enjoyed using your serial library so far. But unfortunately I'm having this exact same issue on my own project. It's most unfortunate I can't easily create a pipeline to compile for all platforms using a single make command.
dan@DAN-DESKTOP:/mnt/c/Users/danie/repos/gps-atlas$ make build-macos
export GOOS=darwin && \
export GOARCH=amd64 && \
export GPSATLAS_BIN_PATH=bin/macos/gps-atlas && \
make build
make[1]: Entering directory '/mnt/c/Users/danie/repos/gps-atlas'
CGO_ENABLED=0 \
GO111MODULE=on \
go build \
-installsuffix "static" \
-ldflags="-X 'main.Version=$(cat version)'" \
-o bin/macos/gps-atlas \
$(find cmd/app/*.go)
# github.com/tarm/serial
/home/dan/go/pkg/mod/github.com/tarm/[email protected]/serial.go:128:28: undefined: Port
/home/dan/go/pkg/mod/github.com/tarm/[email protected]/serial.go:139:9: undefined: openPort
Makefile:8: recipe for target 'build' failed
make[1]: *** [build] Error 2
make[1]: Leaving directory '/mnt/c/Users/danie/repos/gps-atlas'
Makefile:29: recipe for target 'build-macos' failed
make: *** [build-macos] Error 2
dan@DAN-DESKTOP:/mnt/c/Users/danie/repos/gps-atlas$
from serial.
Hi @tsteinholz
This package does aim to be cross platform, but cross-compiling (with gox or manually) is tricky right now. I think native compilation should work on all of the *bsd platforms. For windows in particular, both native and cross compiling should work like this:
$ GOOS=windows go install github.com/tarm/serial
$ ls -l $GOPATH/pkg/windows_amd64/github.com/tarm
total 72
-rw-r--r--. 1 tarm tarm 72410 Jan 30 20:22 serial.a
Specifically the issue with cross-compiling for posix platforms is that tarm/serial uses cgo+termios.h to keep things portable. The termios.h interface abstracts some of the syscall and ioctl differences in serial handling between different platforms. Take a look at the "build constraints" and cgo code here:
https://github.com/tarm/serial/blob/master/serial_posix.go#L1-L9
You might be able to make it work by passing the -cgo option to gox, but cross-compiling cgo code may be tricky and I have not tried it myself.
I would be interested/open to syscall+ioctl based solutions. Those would likely allow cross compiling more easily, but also would be much more closely tied to each architecture/platform.
Patches welcome!
from serial.
Related Issues (20)
- Can't compile on MacOS HOT 3
- List Available Serial Ports
- Single byte []byte{0x0f} is not transmitted
- Add SetReadTimeout(readTimeout time.Duration) function.
- Add SendBreak method
- How to set DTR RST enable
- Unable to read AT command response on windows 10 machine using 8 Port USB Modem Pool HOT 2
- Timeout problem with io.Reader
- Can I use multiple Serial ports in one code for simultaneously reading? HOT 1
- Connecting to existing port crashes PC
- Gen2 License plate recognition is not working HOT 1
- How catch Lost Serial port(for example USB virtual rs-232 unplug) HOT 1
- lost data via bufio.Read HOT 2
- [Question] How To Send Break Signal? HOT 1
- Problem with syncing 3 receiving bytes HOT 1
- all serials HOT 4
- There is no error ReadTimeout HOT 2
- not clear buffer splitting when reading HOT 4
- Reading serial ERROR_OPERATION_ABORTED (995) HOT 1
- 为什串口有数据时,读取的数据总是将一帧发送数据的第一字节和剩余的字节数,分2次才能完全的读到? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serial.