tarm / serial

BSD 3-Clause "New" or "Revised" License
1.6k stars 451 forks source link

Having 0x10 set causes arduino to reset when serial message is sent #88

Open ASoggyToaster opened 5 years ago

ASoggyToaster commented 5 years ago
func setCommState(h syscall.Handle, baud int, databits byte, parity Parity, stopbits StopBits) error {
    var params structDCB
    params.DCBlength = uint32(unsafe.Sizeof(params))

    params.flags[0] = 0x01  // fBinary
    params.flags[0] |= 0x10 // Assert DSR

Having 0x10 set causes arduino to reset when serial message is sent when connecting via windows. I modified my copy of the library to remove this line.

func setCommState(h syscall.Handle, baud int, databits byte, parity Parity, stopbits StopBits) error {
    var params structDCB
    params.DCBlength = uint32(unsafe.Sizeof(params))

    params.flags[0] = 0x01  // fBinary
    //params.flags[0] |= 0x10 // Assert DSR

Currently using it in this project: https://github.com/ASoggyToaster/Max7219

ASoggyToaster commented 5 years ago

Submitted a PR: https://github.com/tarm/serial/pull/89

donotnoot commented 5 years ago

jeez I wasted so much time yesterday trying to figure out why my Arduino was resetting when I sent data using this library. Thanks for finding out wha the problem is.

Happens in OS X too. I would not say this is a library problem specifically but it would be great to make this behaviour configurable.

ASoggyToaster commented 5 years ago

Agreed - Probably shouldn't have submitted this as a PR per se, but having it open - I think - is helpful to others who may experience the same issue.

In this instance I made the quick and dirty change that suited my usecase, but glad it helped you as well @donotnoot !