tarm / serial

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

Connecting to existing port crashes PC #119

Open manojbshekaris opened 3 years ago

manojbshekaris commented 3 years ago

Hey I tried to open bluetooth module HC-05(com7), that has been already connected to PC. from the code, I cannot open an already opened port. If I try to explicitly specify this COM7 (for me, at the time of development) and write to bluetooth, the bluetooth crashes. I did not dig deep in, but also the PC crashed. I am using Windows 10.

  func main() {
      c := &serial.Config{Name: "COM7", Baud: 9600, ReadTimeout: time.Millisecond * 500}
      s, err := serial.OpenPort(c)
      if err != nil {
          log.Fatal(err)
      }
      fmt.Println("writing")

      n, err := s.Write([]byte("F"))
      if err != nil {
          log.Fatal(err)
      }
      fmt.Println(n)
  }