goburrow / modbus

Fault-tolerant implementation of modbus protocol in Go (golang)
BSD 3-Clause "New" or "Revised" License
936 stars 366 forks source link

[SOLVED] Cannot wring single Coil #57

Closed Serhioromano closed 4 years ago

Serhioromano commented 4 years ago

I've managed to read all data I need. Now I start writing. I use this function

bts2, _ := StringToInt64(task.Val)
var set uint16
if bts2 == 0 {
    set = 0x0000
} else {
    set = 0xFF00
}
result, err = m.Client.WriteSingleCoil(i, set)
i++
if err != nil {
    fmt.Println(err)
}

But I hav EOF error.

What do I do wrong?

i is 0 and 1 2 in a cycle

Serhioromano commented 4 years ago

Looks like WriteSingleRegister acts the same.

Serhioromano commented 4 years ago

My bad. Works now.