func finaliserModbusRTUConnection(obj *ModbusRTUConnection) { log.Print("Cleaning libmodbus structure") C.modbus_close(obj.ctx) C.modbus_free(obj.ctx) if obj.hook != nil { obj.rwCtlChan <- (-1) } }
// The modbus_close() function shall close the connection established with the backend set in the context. func (this *RtuConnection) Close() error { if this.connected { C.modbus_close(this.ctx) return nil } else { return errors.New("Not connected") } }