Hi, I have a GPS that sends me data through a connection TCP

the data it sends me are in ASCII, and I have to convert it to HEX

for example in python I'm doing this 

    BUFFER_SIZE = 1024
    conn, addr = s.accept()
    data = conn.recv(BUFFER_SIZE)
    data.encode("hex")
    conn.close()
    print data

and it works.

but in GO, 

  buf := make([]byte, 1024)
  reqLen, err := conn.Read(buf)
  if err != nil {
    fmt.Println("Error: ", err.Error())
  }

  fmt.Println("buf: ", buf) 
  fmt.Println("buf str: ", string(buf)) 
  var str string = ""
  for i:=0; i< len(buf); i++{
    str += strconv.FormatUint(uint64(buf[i]), 16)
  }
  fmt.Println("str: ", str) 

or if I use io, error2 :=ioutil.ReadAll(connection) i do not get the exact 
data that it sends me in any way







-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to