Closed KiddoV closed 1 year ago
According to the manual, break signals are just two bytes, a 255 byte followed by a 243 byte.
This macro sends IAC BREAK(255 243) to the host system on the TELNET console.
So, you should be able to replicate a break signal by sending those bytes.
@kroppt thanks for the info. Can you give some code example on how to send those bytes? I appreciate it!
See https://pkg.go.dev/go.bug.st/serial#section-documentation for all the setup.
Then, when you are writing to the serial port, send the two bytes:
n, err := port.Write([]byte{255, 243})
Thanks! I will try that.
@kroppt Is there anyway that I can get the syscall.Handle
without modify the lib? I want to try to set comm break like this:
https://github.com/ricorx7/go-serial/blob/be02e536a880/syscall_windows.go#L65
func SetCommBreak(handle syscall.Handle) (err error) {
r1, _, e1 := syscall.Syscall(procSetCommBreak.Addr(), 1, uintptr(handle), 0, 0)
if r1 == 0 {
if e1 != 0 {
err = error(e1)
} else {
err = syscall.EINVAL
}
}
return
}
Not sure how to get the Handle
from outside.
No, the type windowsPort
is unexported.
Do you have any suggestion of how I can use the SetCommBreak
from syscall.NewLazyDLL
with my serial.Port
instance?
No. That would be the same as the code snippet you posted.
I don't have a way to put a scope on the output, but the suggested solution of sending 255,243 doesn't appear to work in all cases. I have an FTDI serial chip on a linux system. When I send a break using the snippet below, I'm able to see the expected results, but when I send 255,243 I don't.
unix.Syscall(unix.SYS_IOCTL, mySerialPortFile.Fd(), uintptr(unix.TCSBRKP), uintptr(0))
In my use case I need to reset a DS2480 chip & one way to do this is to send a break for 2ms+.
@schmidtw interesting, I will give it a try. Also sending 255, 243 doesn't work for me as well.
Looks like in this pull request: #137
Sadly it doesn't support Windows 🥲
@KiddoV please give #145 a try.
Fixed by #145
Thank you for the great package. I would like to send a break signal to the port. How do I accomplish this? It like when using TeraTerm you send the port a break signal. Thank you!