I am trying to decode a data stream. This signal comes out of an STC 8H1K16 micro-controller. It is from the pin labeled TxD is the picture.
When I trigger the signal I am trying to understand I get the following:
(purple timings in drawing are approximations)
I thought it was a serial communication so I tried connecting it to an FTDI chip and dumping what I receive. When I measure the pulse I got ~103uS so I assume it is 9600 baud. But the data I get out is inconsistent so I don't think it is working
Serial Dump Code:
func main() {
// https://github.com/tarm/serial/blob/master/serial.go
c := &serial.Config{
Name: "/dev/tty.usbserial-AM00FHIL",
Baud: 9600,
//Parity: serial.ParityOdd,
//StopBits: serial.Stop1,
Size: 8,
//ReadTimeout: time.Millisecond * 500,
}
s, err := serial.OpenPort(c)
if err != nil {
log.Fatal(err)
}
for {
i++
buf := make([]byte, 128)
n, err = s.Read(buf)
if err != nil {
log.Fatal(err)
}
fmt.Printf(" %x", n)
}
}
Any ideas for what format this signal is?
More context:
I have a Vevor TV lift that has a wired remote. I want to connect this to Home Assistant but I need to understand this signal. I can try and just mirror the signal but would like to actually know its format if at all possible.
Answer
As pointed out by @Jasen I was only printing the len and not the buffer. Here is the working dump code:
package main
import (
"fmt"
"log"
"github.com/tarm/serial"
)
func main() {
// https://github.com/tarm/serial/blob/master/serial.go
c := &serial.Config{
Name: "/dev/tty.usbserial-AM00FHIL",
Baud: 9600,
//Parity: serial.ParityOdd,
//StopBits: serial.Stop1,
Size: 8,
//ReadTimeout: time.Millisecond * 500,
}
s, err := serial.OpenPort(c)
if err != nil {
log.Fatal(err)
}
for {
buf := make([]byte, 128)
n, err := s.Read(buf)
if err != nil {
log.Fatal(err)
}
//fmt.Printf("\n(%x): ", n)
for i := 0; i < n; i++ {
if buf[i] == 0x55 {
fmt.Printf("\n")
}
fmt.Printf(" 0x%.2x", buf[i])
}
}
}
AA55F0F0F0
or55AA0F0F0F
\$\endgroup\$