<commit_before>package zwave

import "fmt"

type NodeList struct {
	Version      uint8
	Capabilities byte
	Nodes        []byte
	ChipType     byte
	ChipVersion  byte
}

// @todo functions to parse capabilities flags

func isBitSet(mask byte, pos uint) bool {
	return mask&(1<<pos) == 1
}

func (n *NodeList) Unmarshal(frame *ZFrame) {
	n.Version = frame.Payload[1]
	n.Capabilities = frame.Payload[2]
	n.Nodes = frame.Payload[4:33]
	n.ChipType = frame.Payload[33]
	n.ChipVersion = frame.Payload[34]
}

func (n *NodeList) GetNodeIds() []int {
	nodes := []int{}
	nodeNum := 1
	fmt.Println(len(n.Nodes))
	for i := 0; i < 29; i++ {
		for j := uint(0); j < 8; j++ {
			if isBitSet(n.Nodes[i], j) {
				nodes = append(nodes, nodeNum)
			}

			nodeNum++
		}
	}

	return nodes
}<commit_msg>fix node list parsing<commit_after>package zwave

type NodeList struct {
	Version      uint8
	Capabilities byte
	Nodes        []byte
	ChipType     byte
	ChipVersion  byte
}

// @todo functions to parse capabilities flags

func isBitSet(mask byte, pos uint) bool {
	return mask&(1<<(7-pos)) > 0
}

func (n *NodeList) Unmarshal(frame *ZFrame) {
	n.Version = frame.Payload[1]
	n.Capabilities = frame.Payload[2]
	n.Nodes = frame.Payload[4:33]
	n.ChipType = frame.Payload[33]
	n.ChipVersion = frame.Payload[34]
}

func (n *NodeList) GetNodeIds() []int {
	nodes := []int{}
	nodeNum := 1

	for i := 0; i < 29; i++ {
		for j := uint(0); j < 8; j++ {
			if isBitSet(n.Nodes[i], j) {
				nodes = append(nodes, nodeNum)
			}

			nodeNum++
		}
	}

	return nodes
}
{'fraction_non_alphanumeric': 0.14630960156760286, 'fraction_numerical': 0.024167210973220117, 'mean_word_length': 3.291316526610644, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '466178', 'n_tokens_mistral': 642, 'n_tokens_neox': 584, 'n_words': 156}