Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always returns [65] #70

Closed
5k3105 opened this issue Oct 24, 2017 · 2 comments
Closed

Always returns [65] #70

5k3105 opened this issue Oct 24, 2017 · 2 comments

Comments

@5k3105
Copy link

5k3105 commented Oct 24, 2017

on windows 7.
Using Termite:
Port: COM1
Baud rate: 115200
Data bits: 8
Stop bits: 1
Parity: none
Flow control: none

  • Append LF
TEMPS?
AC/DC Temperature 1 = 56 C
AC/DC Temperature 2 = 51 C
Control Brd Temp = 39 C
DC/AC Temperature = 39 C
DC2 Temperature = 55.18 C
DC2 Temperature 2 = 51.18 C
Battery Temperature = 29.8 C

Code below gives [65] though:

λ telem_serial.exe
2017/10/24 23:47:58 %q[65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
buf len:  1
package main

import (
	"github.com/tarm/serial"
	"log"
)

func main() {
	c := &serial.Config{Name: "COM1", Baud: 115200}
	s, err := serial.OpenPort(c)
	if err != nil {
		log.Fatal(err)
	}

	err = s.Flush()
	if err != nil {
		log.Fatal(err)
	}

	cmd := []byte("TEMPS?\r\n")
	n, err := s.Write(cmd)
	if err != nil {
		log.Fatal(err)
	}

	buf := make([]byte, 128)
	n, err = s.Read(buf)
	if err != nil {
		log.Fatal(err)
	}
	log.Print("%q", buf) //buf[:n])
	println("buf len: ", n)
}
@5k3105
Copy link
Author

5k3105 commented Oct 25, 2017

Actually, if I send it a different command, it gives me the first letter of the response. So it is returning correct data, just only one byte of it.

Any ideas?

@5k3105
Copy link
Author

5k3105 commented Oct 26, 2017

Got same issue using github.com/knieriem/serport however, https://github.com/jacobsa/go-serial worked correctly.

@5k3105 5k3105 closed this as completed Oct 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant