the SetCharsAt function does not work. I tried converting from string to a byte slice, writing to plc, and reading back using GetCharsAt. The values return all zeros.
ive found the solution below to work
//SetCharsAt Set Array of char (S7 ARRAY OF CHARS)
func (s7 *Helper) SetCharsAt(buffer []byte, pos int, value string) {
copy(buffer[pos:pos+len(value)], []byte(value))
//buffer = append(buffer[:pos], append([]byte(value), buffer[pos:]...)...)
}
the SetCharsAt function does not work. I tried converting from string to a byte slice, writing to plc, and reading back using GetCharsAt. The values return all zeros.
ive found the solution below to work
//SetCharsAt Set Array of char (S7 ARRAY OF CHARS) func (s7 *Helper) SetCharsAt(buffer []byte, pos int, value string) { copy(buffer[pos:pos+len(value)], []byte(value)) //buffer = append(buffer[:pos], append([]byte(value), buffer[pos:]...)...) }