Open captcha1 opened 6 years ago
FYI , on a Atheros MIPS 24Kc machine running OpenWRT 17.01.2 , I get :
TCSETS2 = 0x8030542B BOTHER = 0x00001000 NCCS = 23
... though there seems to be 2 files named termbits.h with 2 different values for NCCS :
$ cd lede-sdk-17.01.4-ar71xx-generic_gcc-5.4.0_musl-1.1.16.Linux-x86_64/staging_dir/toolchain-mips_24kc_gcc-5.4.0_musl-1.1.16/include $ grep NCCS asm/ |grep define
asm-generic/termbits.h:#define NCCS 19 asm/termbits.h:#define NCCS 23
... so that looks like another source of bugs ...
I did a test, and the speed gets set correctly when NCCS=23
Did you manage to make go-serial working with openwrt?
Yes ...
It's probably better to fix it by using "cgo", but a workaround is to hard code for OpenWRT :
TCSETS2 = 0x8030542B
BOTHER = 0x00001000
NCCS = 23
On Thu, Apr 5, 2018 at 1:40 PM, julioSab notifications@github.com wrote:
Did you manage to make go-serial working with openwrt?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jacobsa/go-serial/issues/37#issuecomment-379069513, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ9ihDfLKuZLxojcCSMidJpuiXyUOALjks5tloEigaJpZM4SXQNk .
The following code works under mips and arm CPU, it should work on other linux too.
env GOOS=linux GOARCH=arm GOARM=5 go build -ldflags "-s -w" -o server-arm server.go env GOOS=linux GOARCH=mips go build -ldflags "-s -w" mem.go
PC linux is not tested yet. Referenced different headers made this works.
#if defined(__mips__)
# define NCCS 23
#elif defined(__sparc__)
# define NCCS 17
#else
# define NCCS 19
#endif
The change to the file serial/open_linux.go
Please reference https://github.com/philipgreat/go-serial/blob/master/serial/open_linux.go
func nccs() int {
if runtime.GOARCH == "mips" {
return 23
}
if runtime.GOARCH == "mipsle" {
return 23
}
if runtime.GOARCH == "spark" {
return 17
}
if runtime.GOARCH == "sparc64" {
return 17
}
return 19
}
const (
kTCSETS2 = unix.TCSETS2 //0x8030542B
kBOTHER = unix.BOTHER//0x00001000
kNCCS = nccs()
)
@philipgreat plan to push a PR for this fix?
@philipgreat also your fork fails to build for me here on 1.11, reporting:
# github.com/philipgreat/go-serial/serial
../github.com/philipgreat/go-serial/serial/open_linux.go:62:2: const initializer nccs() is not a constant
The code was out of sync.
Hi @philipgreat what do you mean? I was just building against your package and the package was failing to build. It looks like go doesn’t allow a constant to be defined as a function, or maybe only if that function can be determined to return a constant.
I run a wrong test, and I am trying to find out a more dynamic way to address this issue.
It seems like the golang idiomatic way is to create different build files that defined the same per platform constant, or a function to return the value with a runtime check, but that wasn’t a constant.
On Mon, Jan 7, 2019 at 1:08 PM Philip Z notifications@github.com wrote:
I run a wrong test, and I am trying to find out a more dynamic way to address this issue.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jacobsa/go-serial/issues/37#issuecomment-452026905, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJ-AOa6wlqbGdhXsTp8VMer8Z0Ss_6Hks5vA40ogaJpZM4SXQNk .
Anyone looking at this still? I ran into this bug again today and of course since January I forgot about the issue and was trying to debug it for a half hour...
Oh, last commit in this project is Jan 2018 so it looks dead. Anyone know of a supported serial library for go?
const ( kTCSETS2 = unix.TCSETS2 //0x8030542B kBOTHER = unix.BOTHER//0x00001000 kNCCS = 23 // 23 is the value fix for MIPS. most of the OpenWrt routers equipped with MIPS cpu. )
Please use 23 for MIPS cpu. The compile environment values are
env GOOS=linux GOARCH=mips GOMIPS=softfloat
To make this dynamic is not supported in golang with nccs(), another way is adding a new file just for linux and arm CPU.
@philipgreat don't get me wrong, I appreciate that you figured out the values. I'm looking for a maintained library however, one with a number of eyes on it, regular updates, pull requests handled etc. I may end up forking to do it myself or we could work together to do so. I see you have a MIPSLE only library, thoughts on expanding it to conditionally support the different patterns using compile time checks or cgo as others have suggested?
I initiated a PR for conditional compilation.
Philip Zhang 邮箱:philip_chang@163.com |
---|
Signature is customized by Netease Mail Master
On 08/05/2019 08:04, Chris Morgan wrote:
@philipgreat don't get me wrong, I appreciate that you figured out the values. I'm looking for a maintained library however, one with a number of eyes on it, regular updates, pull requests handled etc. I may end up forking to do it myself or we could work together to do so. I see you have a MIPSLE only library, thoughts on expanding it to conditionally support the different patterns using compile time checks or cgo as others have suggested?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
Pretty sure this is a go-serial bug (due to TCSETS2 being hard coded ? ) :
On OpenWRT, I get
error opening port:%!(EXTRA *os.SyscallError=SYS_IOCTL: inappropriate ioctl for device)
... could be because OpenWRT uses musl (not glibc).
More details , doing "strace" on OpenWRT, shows :
ioctl(5, _IOC(_IOC_READ, 0x54, 0x2b, 0x2c), 0x9116c90) = -1 ENOTTY (Not a tty)
FYI, to cross compile for MIPS (Atheros Soc) on OpenWRT, do :
export GOARCH=mips export GOMIPS=softfloat # requires the recently released go1.10 to get the softfloat code generator