2
\$\begingroup\$

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.

enter image description here

When I trigger the signal I am trying to understand I get the following:

(purple timings in drawing are approximations)

enter image description here

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

    }
}

\$\endgroup\$
6
  • 4
    \$\begingroup\$ your dump code sees to only print the number of bytes found in serial port's buffer \$\endgroup\$ Dec 12, 2021 at 22:49
  • 1
    \$\begingroup\$ Looks like 8 bit data with a single stop bit and no parity. \$\endgroup\$
    – Andy aka
    Dec 12, 2021 at 22:50
  • \$\begingroup\$ By serial communication, I take it you mean UART at 9600 baud. Have you tried enabling/disabling both parity and 9-bit mode and seeing what you receive then? You can also just follow it through by eye on your display, looking for START and STOP bit positions. (Too late for me to look at it myself.) \$\endgroup\$
    – TonyM
    Dec 12, 2021 at 22:51
  • 7
    \$\begingroup\$ I get 0x55 0xAA 0xF0 0xF0 by hand decoding (9600,8,n,1) \$\endgroup\$ Dec 12, 2021 at 22:57
  • 2
    \$\begingroup\$ extend the top time interval to 5.2 ms ... looks like AA55F0F0F0 or 55AA0F0F0F \$\endgroup\$
    – jsotola
    Dec 12, 2021 at 23:03

1 Answer 1

0
\$\begingroup\$

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

    }
}
```
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.