Exemplo n.º 1
0
// Print the address for debugging
func (c *Codeword) Adress() string {
	bytes := utils.MSBBitsToBytes(c.Payload[0:17], 8)
	addr := uint(bytes[1])
	addr += uint(bytes[0]) << 8

	return fmt.Sprintf("%X:%s%s", addr,
		utils.TernaryStr(bool(c.Payload[18]), "1", "0"),
		utils.TernaryStr(bool(c.Payload[19]), "1", "0"))

}
Exemplo n.º 2
0
// Print the codeword contents and type to terminal. For debugging.
func (c *Codeword) Print() {

	payload := ""
	var color *color.Color = blue

	switch c.Type {

	case CodewordTypeAddress:
		payload = c.Adress()
		color = red

	case CodewordTypeMessage:
		payload = ""
		color = green

	default:
		color = blue

	}

	parity := utils.TernaryStr(c.ValidParity, "", "*")
	color.Printf("%s %s %s ", c.Type, payload, parity)
	corr := c.BitCorrections
	if corr > 0 {
		color.Printf("%d bits corrected", corr)
	}

	println("")
}