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

mips error: serial.Open: SYS_IOCTL: inappropriate ioctl for device #27

Open
kexin-open opened this issue Aug 2, 2017 · 1 comment
Open

Comments

@kexin-open
Copy link

kexin-open commented Aug 2, 2017

code:

     options := serial.OpenOptions{
		PortName: "/dev/ttyS1",
		BaudRate: 9600,
		DataBits: 8,
		StopBits: 1,
		MinimumReadSize: 4,
	}
       
        port, err := serial.Open(options)
	if err != nil {
		fmt.Printf("serial.Open: %v\n", err)
		return
	}

env:
GOOS=linux GOARCH=mipsle go1.8.3 cpu:mt7688

error:
serial.Open: SYS_IOCTL: inappropriate ioctl for device

thanks

@philipgreat
Copy link

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.

https://github.com/mojo-runtime/lib-linux/blob/6dbfa74d17beda9be9c6e3b595c76f8df3cbb077/c/struct-termios.h

#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() 
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants