tarm / serial

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Connecting to existing port crashes PC

manojbshekaris opened this issue · comments

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)
  }