jacobsa / go-serial

A Go library for dealing with serial ports.
Apache License 2.0
631 stars 121 forks source link

SYS_IOCTL: invalid argument on Mac OS 10.10 #10

Closed HStangl closed 7 years ago

HStangl commented 9 years ago

When trying the sample code with Mac OS 10.10, I get the following error: serial.Open: SYS_IOCTL: invalid argument

Some digging around showed that the call to setTermios() in open_darwin.go fails.

I'm using a Delock USB to Serial adapter with FTDI chipset.

ereOn commented 7 years ago

@jacobsa Any news on this ?

I actually have the same issue. I'm using a "virtual" serial port created with socat.

If I comment these lines:

        if errno2 != 0 {
        return nil, os.NewSyscallError("SYS_IOCTL", errno2)
    }

    if r2 != 0 {
        return nil, errors.New("Unknown error from SYS_IOCTL.")
    }

The error is ignored and the device works as expected. I assume this is because socat's virtual socket doesn't support the kIOSSIOSPEED IOCTL on OSX.

From the issues log, I can see this was introduced as #7.

For the record, here is the socat command line I used:

socat -d -d -d pty,raw,link=$HOME/dev/ttyS0 tcp:192.168.0.3:3002

I would be willing to make a PR for that, but I'm not sure which way is best:

Thank you for the good work.

jacobsa commented 7 years ago

Thanks for the details. Are you able to reliably detect "this isn't a thing that is supported by this virtual socket"? I.e. does it return something like ENOSYS? If so, maybe ignore that?

ereOn commented 7 years ago

@jacobsa Sorry it took me so long to answer. I got caught up in many things at work and this basically used all of my free-time.

I came up with a PR (#25) that solves this issue. Let me know what you think and if I need to make some changes. I obviously tested it on OSX and I can confirm it works (at least on my machine ;)).

Thanks again for the good work !

P.S : I notice you don't have Continuous Integration enabled. If that is something you are interested in, I can help in that regard too. Just let me know.

jacobsa commented 7 years ago

Thanks very much; please do feel free to set up CI if you like.

ereOn commented 7 years ago

@jacobsa You may want to close this issue too :)